interpreTS.core.features package#
Submodules#
interpreTS.core.features.feature_length module#
- interpreTS.core.features.feature_length.calculate_length(data)[source]#
Calculate the number of data points in a time series.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the length feature is to be calculated.
- Returns:
The number of data points in the provided time series.
- Return type:
int
- Raises:
TypeError – If the data is not a valid time series type.
ValueError – If the data contains NaN values or is not one-dimensional.
Examples
>>> import pandas as pd >>> data = pd.Series([1, 2, 3, 4, 5]) >>> calculate_length(data) 5
interpreTS.core.features.feature_mean module#
- interpreTS.core.features.feature_mean.calculate_mean(data)[source]#
Calculate the mean value of a time series.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the mean value is to be calculated.
- Returns:
The mean value of the provided time series.
- Return type:
float
- Raises:
TypeError – If the data is not a valid time series type.
ValueError – If the data contains NaN values.
Examples
>>> import pandas as pd >>> data = pd.Series([1, 2, 3, 4, 5]) >>> calculate_mean(data) 3.0
interpreTS.core.features.feature_peak module#
- interpreTS.core.features.feature_peak.calculate_peak(data, start=None, end=None)[source]#
Calculate the local maximum of a time series within an optional range.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the maximum value is to be calculated.
start (int, str, or None, optional) – The starting index, timestamp, or position for slicing the data. If None, the series starts from the beginning.
end (int, str, or None, optional) – The ending index, timestamp, or position for slicing the data. If None, the series ends at the last value.
- Returns:
The local maximum of the specified range in the provided time series.
- Return type:
float
- Raises:
TypeError – If the data is not a valid time series type.
ValueError – If the data contains NaN values.
Examples
>>> import pandas as pd >>> data = pd.Series([1, 2, 5, 4, 7]) >>> calculate_peak(data) 7.0 >>> calculate_peak(data, start=1, end=3) 5.0
interpreTS.core.features.feature_spikeness module#
- interpreTS.core.features.feature_spikeness.calculate_spikeness(data)[source]#
Calculate the spikeness (skewness) of a time series.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the spikeness is to be calculated.
- Returns:
The spikeness (skewness) of the provided time series.
- Return type:
float
- Raises:
TypeError – If the data is not a valid time series type or contains non-numeric values.
ValueError – If the data is empty.
Examples
>>> import pandas as pd >>> data = pd.Series([1, 2, 3, 4, 5]) >>> calculate_spikeness(data) 0.0
interpreTS.core.features.feature_std_1st_der module#
- interpreTS.core.features.feature_std_1st_der.calculate_std_1st_der(data)[source]#
Calculate the standard deviation of the first derivative of a time series.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the standard deviation of the first derivative is to be calculated.
- Returns:
The standard deviation of the first derivative of the provided time series. Returns np.nan if the input data is empty.
- Return type:
float
- Raises:
TypeError – If the data is not a valid time series type.
ValueError – If the data contains NaN values.
Examples
>>> data = pd.Series([1, 2, 3, 4, 5]) >>> calculate_std_1st_der(data) 0.0
interpreTS.core.features.feature_trough module#
- interpreTS.core.features.feature_trough.calculate_trough(data, start=None, end=None)[source]#
Calculate the local minimum of a time series within an optional range.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the minimum value is to be calculated.
start (int, str, or None, optional) – The starting index, timestamp, or position for slicing the data. If None, the series starts from the beginning.
end (int, str, or None, optional) – The ending index, timestamp, or position for slicing the data. If None, the series ends at the last value.
- Returns:
The local minimum of the specified range in the provided time series.
- Return type:
float
- Raises:
TypeError – If the data is not a valid time series type.
ValueError – If the data contains NaN values.
Examples
>>> data = pd.Series([1, 2, 5, 4, 3]) >>> calculate_trough(data) 1.0 >>> calculate_trough(data, start=1, end=3) 2.0
interpreTS.core.features.feature_variance module#
- interpreTS.core.features.feature_variance.calculate_variance(data, ddof=0)[source]#
Calculate the variance value of a time series with specified degrees of freedom.
- Parameters:
data (pd.Series or np.ndarray) – The time series data for which the variance is to be calculated.
ddof (int, optional) – Delta degrees of freedom. The divisor used in calculations is N - ddof, where N is the number of elements. A ddof of 1 provides the sample variance, and a ddof of 0 provides the population variance. Default is 1.
- Returns:
The variance of the provided time series with specified degrees of freedom.
- Return type:
float
- Raises:
TypeError – If the data is not numeric.
ValueError – If the data contains NaN values or is not one-dimensional.
Examples
>>> import pandas as pd >>> import numpy as np >>> data = pd.Series([10, 12, 14, 16, 18]) >>> calculate_variance(data) 10.0
>>> data = np.array([2, 4, 6, 8, 10]) >>> calculate_variance(data, ddof=0) 8.0
>>> data = pd.Series([5]) >>> calculate_variance(data) 0.0