You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by utkarshtri1997 January 20, 2022
Hi, Firstly Thank you for building this good application for time-series calculation. Can you please help me in adding new features to MinimalExtractionParameters? Please reply ASAP.`@set_property("fctype", "simple")
def flor_ratio(x):
"""
The description of your feature
:param x: the time series to calculate the feature of
:type x: pandas.Series
:return: the value of this feature
:return type: bool, int or float
"""
Calculation of feature as float, int or bool
u=np.max(x)
v=np.min(x)
#flor_ratio = (u-v)/v
return (u-v)/v
fc_parameters = {
'median': None,
'mean': None,
'standard_deviation': None,
'root_mean_square': None,
'maximum': None,
'minimum': None,'flor_ratio':None
from sktime.transformations.panel.tsfresh import TSFreshRelevantFeatureExtractor
from tsfresh.feature_extraction import extract_features
transformer = TSFreshRelevantFeatureExtractor(kind_to_fc_parameters= fc_parameters)
extracted_features = transformer.fit_transform(X_train,y_train)
extracted_features
}` But this doesn't calculate the features I gave it to calculate.
The text was updated successfully, but these errors were encountered:
Hi @utkarshtri1997
sorry for the late answer. I know it can be frustrating waiting for an answer when you desperately need it. Please note however, that every contributor and maintainer of tsfresh does this in its free time and without compensation :) We always try to answer "ASAP" ;)
To your question:
There are a few small inconsistencies in your code example (by the way, you can help readability of the code by using the code formatting of GitHub markdown), where I am not sure if this was not just a copy-paste error from your original code, but I will point them out anyways:
You are using kind_to_fc_parameters with a dictionary without column names - so it looks like you actually wanted to use it with default_fc_parameters.
You included your new function flor_ratio into the dictionary as string literal, but in the documentation we describe it should be added as plain function (see here). Just remove the ' around it.
I do not have experience with sktime and it might be that the problem only occurs when using this package. But for me, this works correctly (using sktime's example dataset):
importnumpyasnpdefflor_ratio(x):
""" The description of your feature :param x: the time series to calculate the feature of :type x: pandas.Series :return: the value of this feature :return type: bool, int or float """# Calculation of feature as float, int or boolu=np.max(x)
v=np.min(x)
return (u-v)/vfc_parameters= {
'median': None,
'mean': None,
'standard_deviation': None,
'root_mean_square': None,
'maximum': None,
'minimum': None, flor_ratio:None
}
if__name__=="__main__":
fromsktime.transformations.panel.tsfreshimportTSFreshRelevantFeatureExtractorfromsktime.datasetsimportload_arrow_headX, y=load_arrow_head(return_X_y=True)
transformer=TSFreshRelevantFeatureExtractor(default_fc_parameters=fc_parameters)
extracted_features=transformer.fit_transform(X, y)
print(extracted_features)
Discussed in #923
Originally posted by utkarshtri1997 January 20, 2022
Hi, Firstly Thank you for building this good application for time-series calculation. Can you please help me in adding new features to MinimalExtractionParameters? Please reply ASAP.`@set_property("fctype", "simple")
def flor_ratio(x):
"""
The description of your feature
:param x: the time series to calculate the feature of
:type x: pandas.Series
:return: the value of this feature
:return type: bool, int or float
"""
Calculation of feature as float, int or bool
u=np.max(x)
v=np.min(x)
#flor_ratio = (u-v)/v
return (u-v)/v
fc_parameters = {
'median': None,
'mean': None,
'standard_deviation': None,
'root_mean_square': None,
'maximum': None,
'minimum': None,'flor_ratio':None
from sktime.transformations.panel.tsfresh import TSFreshRelevantFeatureExtractor
from tsfresh.feature_extraction import extract_features
transformer = TSFreshRelevantFeatureExtractor(kind_to_fc_parameters= fc_parameters)
extracted_features = transformer.fit_transform(X_train,y_train)
extracted_features
}` But this doesn't calculate the features I gave it to calculate.
The text was updated successfully, but these errors were encountered: