import pandas as pd,numpy as np
import tsfresh
from tsfresh.feature_extraction.feature_calculators import set_property
@set_property("fctype", "simple")
def zero_value_percentage(x):
ratio = (x==0).sum()/x.shape[0]
return ratio`
fc_parameters = {'mean':None, 'standard_deviation':None, 'zero_value_percentage':None}
df_features = tsfresh.extract_features(data[['id','year_month','order_qty']], column_id='id', column_sort='year_month', default_fc_parameters=fc_parameters)
Error: 'module 'tsfresh.feature_extraction.feature_calculators' has no attribute 'zero_value_percentage''
Utility of custom function is to count no. of non zero points in timeseries as a %.
The documentation mentions to "add the feature calculator to the tsfresh.feature_extraction.feature_calculators submodule" at the end of Step 2 in the link for it to work.
How does one do that?
Dont know how to proceed
Step 1: Define the Custom Feature Calculator Function First, define your custom feature calculator function, which calculates the zero value percentage. You've already done this with the zero_value_percentage function.
Step 2: Register the Custom Feature Calculator To make your custom function available as a feature calculator in the tsfresh library, you need to register it with the feature_calculators submodule.
Step 3: Extract Features Using tsfresh Now that you have registered your custom feature calculator, you can use it with the tsfresh.extract_features function.
Note: Make sure that you have installed the latest version of tsfresh to access the register_function method.