# gluonts.transform.sampler module¶

class gluonts.transform.sampler.BucketInstanceSampler(scale_histogram: gluonts.dataset.stat.ScaleHistogram)[source]

This sample can be used when working with a set of time series that have a skewed distributions. For instance, if the dataset contains many time series with small values and few with large values.

The probability of sampling from bucket i is the inverse of its number of elements.

Parameters

scale_histogram – The histogram of scale for the time series. Here scale is the mean abs value of the time series.

class gluonts.transform.sampler.ContinuousTimePointSampler(num_instances: int)[source]

Bases: object

Abstract class for “continuous time” samplers, which, given a lower bound and upper bound, sample “points” (events) in continuous time from a specified interval.

class gluonts.transform.sampler.ContinuousTimeUniformSampler(num_instances: int)[source]

Implements a simple random sampler to sample points in the continuous interval between a and b.

class gluonts.transform.sampler.ExpectedNumInstanceSampler(num_instances: float)[source]

Keeps track of the average time series length and adjusts the probability per time point such that on average num_instances training examples are generated per time series.

Parameters

num_instances – number of training examples generated per time series on average

class gluonts.transform.sampler.InstanceSampler[source]

Bases: object

An InstanceSampler is called with the time series and the valid index bounds a, b and should return a set of indices a <= i <= b at which training instances will be generated.

The object should be called with:

Parameters
• ts – target that should be sampled with shape (dim, seq_len)

• a – first index of the target that can be sampled

• b – last index of the target that can be sampled

Returns

Selected points to sample

Return type

np.ndarray

class gluonts.transform.sampler.TestSplitSampler[source]

Sampler used for prediction. Always selects the last time point for splitting i.e. the forecast point for the time series.

class gluonts.transform.sampler.UniformSplitSampler(p: float)[source]

Samples each point with the same fixed probability.

Parameters

p – Probability of selecting a time point