pyhctsa.calculator.FeatureCalculator¶
-
class pyhctsa.calculator.FeatureCalculator(config_path=
None)¶ A configuration-driven feature extraction calculator for time series data.
- feature_funcs¶
A dictionary mapping feature labels to their corresponding callable functions.
- Type:¶
dict
- Parameters:¶
- config_path : str or None, optional¶
Path to the YAML configuration file. If None, uses the default ‘hctsa.yaml’ configuration file in the package configurations directory.
Notes
Besides the operation’s own arguments, each entry of a feature’s
configslist may carry these meta keys (not passed to the function):zscore: True: z-score the series first (label gets no suffix; without it,_raw);abs: True: take the absolute value last (suffix_abs);preprocess: one more input transform, applied to the (z-scored) series beforeabs; its label suffix follows_abs. The values, with the hctsa input each reproduces:decimate_ac1e(suffix_dec):zscore(BF_PreProcess(x_z, 'decimate_ac1e')). The z-scored series is decimated to one sample per floored 1/e autocorrelation time and z-scored again. If that time cannot be determined (e.g. the ACF never falls to 1/e), or fewer than 3 samples would remain (or fewer than the operation’smin_length), the feature is NaN. Seepyhctsa.utils.decimate_ac1e();diff1(_diff1):diff(x_z);zscore_abs(_mag):zscore(abs(x_z));zscore_sign(_sign):zscore(sign(x_z)). (abs: Truealone isabs(x_z).)
select/exclude: keep or drop keys of a dict-valued output.
A feature’s entry (alongside
configs) may also givemin_length: the shortest series on which it is defined (an int, or an expression in its parameters such as"tau + 1"; see_MIN_LENGTH_NAMESPACEfor the helpers it may use). It applies to the series the function receives (afterzscore/preprocess); for a shorter series every output of that feature is NaN, so the set of feature columns never depends on the length. The minima are listed inmin_lengths.field_min_length(a mapping{field: int or expression}; a field name may contain{k}, an integer the expression can use) gives single fields of a dict output a larger minimum: below it that field alone is NaN (field_min_lengths).Examples
>>> fc = FeatureCalculator() # Load default configuration >>> x = np.random.randn(1000) >>> df = fc.extract(x)-
__init__(config_path=
None)¶ Initialises a FeatureCalculator instance.
Methods
__init__([config_path])Initialises a FeatureCalculator instance.
extract(data[, labels, verbose, distributor])Run the configured feature extractor over one or more time series and return a single tidy pandas.DataFrame.
save(path, values[, meta])Write
values(the DataFrame the lastextract()returned) together with itsquality,errorsandcalc_timetopath.