time segments aggregateΒΆ

path: mlstars.custom.timeseries_preprocessing.time_segments_aggregate

description: this primitive creates an equi-spaced time series by aggregating values over fixed specified interval.

see json.

argument

type

description

parameters

X

numpy.ndarray or pandas.DataFrame

n-dimensional sequence of values

time_column

str

column of X that contains time values

hyperparameters

interval

int

integer denoting time span to compute aggregation of

method

str

string describing aggregation method or list of strings describing multiple aggregation methods. If not given, mean is used

output

X

numpy.ndarray

sequence of aggregated values, one column for each aggregation method

index

numpy.ndarray

sequence of index values (first index of each aggregated segment)

In [1]: from mlstars import load_primitive

In [2]: primitive = load_primitive('mlstars.custom.timeseries_preprocessing.time_segments_aggregate',
   ...:     arguments={"time_column": "timestamp", "interval":10, "method":'mean'})
   ...: 

In [3]: df = pd.DataFrame({
   ...:     'timestamp': list(range(50)),
   ...:     'value': [1] * 50})
   ...: 

In [4]: X, index = primitive.produce(X=df)

In [5]: pd.DataFrame({"timestamp": index, "value": X[:, 0]})
Out[5]: 
   timestamp  value
0          0    1.0
1         10    1.0
2         20    1.0
3         30    1.0
4         40    1.0