Skip to content

Commit 3da2360

Browse files
authored
Issue #1062: Feature calculator return type documentation (#1070)
1 parent 61d1a1e commit 3da2360

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tsfresh/feature_extraction/feature_calculators.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def symmetry_looking(x, param):
307307
:param param: contains dictionaries {"r": x} with x (float) is the percentage of the range to compare with
308308
:type param: list
309309
:return: the value of this feature
310-
:return type: bool
310+
:return type: List[Tuple[str, bool]]
311311
"""
312312
if not isinstance(x, (np.ndarray, pd.Series)):
313313
x = np.asarray(x)
@@ -413,7 +413,7 @@ def agg_autocorrelation(x, param):
413413
autocorrelations. Further, n is an int and the maximal number of lags to consider.
414414
:type param: list
415415
:return: the value of this feature
416-
:return type: float
416+
:return type: List[Tuple[str, float]]
417417
"""
418418
# if the time series is longer than the following threshold, we use fft to calculate the acf
419419
THRESHOLD_TO_USE_FFT = 1250
@@ -468,7 +468,7 @@ def partial_autocorrelation(x, param):
468468
:param param: contains dictionaries {"lag": val} with int val indicating the lag to be returned
469469
:type param: list
470470
:return: the value of this feature
471-
:return type: float
471+
:return type: List[Tuple[str, float]]
472472
"""
473473
# Check the difference between demanded lags by param and possible lags to calculate (depends on len(x))
474474
max_demanded_lag = max([lag["lag"] for lag in param])
@@ -510,7 +510,7 @@ def augmented_dickey_fuller(x, param):
510510
statsmodels).
511511
:type param: list
512512
:return: the value of this feature
513-
:return type: float
513+
:return type: List[Tuple[str, float]]
514514
"""
515515

516516
@functools.lru_cache()
@@ -1081,7 +1081,7 @@ def fft_coefficient(x, param):
10811081
"abs", "angle"]
10821082
:type param: list
10831083
:return: the different feature values
1084-
:return type: pandas.Series
1084+
:return type: Iterator[Tuple[str, float]]
10851085
"""
10861086

10871087
assert (
@@ -1130,7 +1130,7 @@ def fft_aggregated(x, param):
11301130
"skew", "kurtosis"]
11311131
:type param: list
11321132
:return: the different feature values
1133-
:return type: pandas.Series
1133+
:return type: Iterator[Tuple[str, float]]
11341134
"""
11351135

11361136
assert {config["aggtype"] for config in param} <= {
@@ -1282,7 +1282,7 @@ def index_mass_quantile(x, param):
12821282
:param param: contains dictionaries {"q": x} with x float
12831283
:type param: list
12841284
:return: the different feature values
1285-
:return type: pandas.Series
1285+
:return type: List[Tuple[str, float]]
12861286
"""
12871287

12881288
x = np.asarray(x)
@@ -1341,7 +1341,7 @@ def linear_trend(x, param):
13411341
:param param: contains dictionaries {"attr": x} with x an string, the attribute name of the regression model
13421342
:type param: list
13431343
:return: the different feature values
1344-
:return type: pandas.Series
1344+
:return type: List[Tuple[str, float]]
13451345
"""
13461346
# todo: we could use the index of the DataFrame here
13471347
linReg = linregress(range(len(x)), x)
@@ -1372,7 +1372,7 @@ def cwt_coefficients(x, param):
13721372
:param param: contains dictionaries {"widths":x, "coeff": y, "w": z} with x array of int and y,z int
13731373
:type param: list
13741374
:return: the different feature values
1375-
:return type: pandas.Series
1375+
:return type: Iterator[Tuple[str, float]]
13761376
"""
13771377

13781378
calculated_cwt = {}
@@ -1413,7 +1413,7 @@ def spkt_welch_density(x, param):
14131413
:param param: contains dictionaries {"coeff": x} with x int
14141414
:type param: list
14151415
:return: the different feature values
1416-
:return type: pandas.Series
1416+
:return type: Iterator[Tuple[str, float]]
14171417
"""
14181418

14191419
freq, pxx = welch(x, nperseg=min(len(x), 256))
@@ -1458,7 +1458,7 @@ def ar_coefficient(x, param):
14581458
:param param: contains dictionaries {"coeff": x, "k": y} with x,y int
14591459
:type param: list
14601460
:return x: the different feature values
1461-
:return type: pandas.Series
1461+
:return type: List[Tuple[str, float]]
14621462
"""
14631463
calculated_ar_params = {}
14641464

@@ -2087,7 +2087,7 @@ def friedrich_coefficients(x, param):
20872087
a positive integer corresponding to the returned coefficient
20882088
:type param: list
20892089
:return: the different feature values
2090-
:return type: pandas.Series
2090+
:return type: List[Tuple[str, float]]
20912091
"""
20922092
# calculated is dictionary storing the calculated coefficients {m: {r: friedrich_coefficients}}
20932093
calculated = defaultdict(dict)
@@ -2171,7 +2171,7 @@ def agg_linear_trend(x, param):
21712171
:param param: contains dictionaries {"attr": x, "chunk_len": l, "f_agg": f} with x, f an string and l an int
21722172
:type param: list
21732173
:return: the different feature values
2174-
:return type: pandas.Series
2174+
:return type: Iterator[Tuple[str, float]]
21752175
"""
21762176
# todo: we could use the index of the DataFrame here
21772177

@@ -2228,7 +2228,7 @@ def energy_ratio_by_chunks(x, param):
22282228
:type x: numpy.ndarray
22292229
:param param: contains dictionaries {"num_segments": N, "segment_focus": i} with N, i both ints
22302230
:return: the feature values
2231-
:return type: list of tuples (index, data)
2231+
:return type: List[Tuple[str, float]]
22322232
"""
22332233
res_data = []
22342234
res_index = []
@@ -2275,7 +2275,7 @@ def linear_trend_timewise(x, param):
22752275
:param param: contains dictionaries {"attr": x} with x an string, the attribute name of the regression model
22762276
:type param: list
22772277
:return: the different feature values
2278-
:return type: list
2278+
:return type: List[Tuple[str, float]]
22792279
"""
22802280
ix = x.index
22812281

@@ -2390,7 +2390,7 @@ def matrix_profile(x, param):
23902390
and decides which feature of the matrix profile to extract
23912391
:type param: list
23922392
:return: the different feature values
2393-
:return type: pandas.Series
2393+
:return type: List[Tuple[str, float]]
23942394
"""
23952395
if mp is None:
23962396
raise ImportError(
@@ -2485,7 +2485,7 @@ def query_similarity_count(x, param):
24852485
`norm` (bool) to `False.
24862486
:type param: list
24872487
:return x: the different feature values
2488-
:return type: int
2488+
:return type: List[Tuple[str, int | np.nan]]
24892489
"""
24902490
res = {}
24912491
T = np.asarray(x).astype(float)

0 commit comments

Comments
 (0)