distancematrix.generator.znorm_euclidean
¶
Module Contents¶
Classes¶
Class capable of efficiently calculating parts of the z-normalized distance matrix between two series, |
|
Helper class that provides a standard way to create an ABC using |
- class distancematrix.generator.znorm_euclidean.ZNormEuclidean(noise_std=0.0, rb_scale_factor=2.0)¶
Bases:
distancematrix.generator.abstract_generator.AbstractGenerator
Class capable of efficiently calculating parts of the z-normalized distance matrix between two series, where each entry in the distance matrix equals the euclidean distance between 2 z-normalized (zero mean and unit variance) subsequences of both series.
This generator can handle streaming data.
Subsequences with standard deviation <= 1e-6 will be treated as flat sequences to avoid problems with numerical stability.
- prepare_streaming(self, m, series_window, query_window=None)¶
Create a bound generator that supports streaming data. The generator will need to receive data before any distances can be calculated.
- Parameters
m – the size of the subsequences used to calculate distances between series and query
series_window – number of values to keep in memory for series, the length of the horizontal axis of the distance matrix will be equal to (series_window - m + 1)
query_window – number of values to keep in memory for query, the length of the vertical axis of the distance matrix will be equal to (query_window - m + 1), or None to indicate a self-join.
- Returns
a bound generator that supports streaming
- prepare(self, m, series, query=None)¶
Create a bound non-streaming generator for the given series and query sequences.
- Parameters
m – the size of the subsequences used to calculate distances between series and query
series – 1D array, used as the horizontal axis of a distance matrix
query – 1D array, used as the vertical axis of a distance matrix, or None to indicate a self-join
- Returns
a bound generator
- class distancematrix.generator.znorm_euclidean.BoundZNormEuclidean(m, series, query, self_join, noise_std, series_mu, series_std, series_std_nz, query_mu, query_std, query_std_nz)¶
Bases:
distancematrix.generator.abstract_generator.AbstractBoundStreamingGenerator
Helper class that provides a standard way to create an ABC using inheritance.
- append_series(self, values)¶
Adds more data points to the series sequence (and the query in case of a self-join). Older data points will be dropped if the series would become larger than the foreseen capacity.
- Parameters
values – 1D array, the new values to append to the series
- Returns
None
- append_query(self, values)¶
Adds more data points to the query sequence. Older data points will be dropped if the query would become larger than the foreseen capacity.
- Parameters
values – 1D array, the new values to append to the query
- Returns
None
- calc_diagonal(self, diag)¶
- calc_column(self, column)¶
- calc_single(self, row, column, dot_prod=None)¶
Calculates a single point of the distance matrix.
- Parameters
row – index of the subsequence in the query series
column – index of the subsequence in the data series
dot_prod – the dotproduct of the subsequences, if provided, this method can run in constant time
- Returns
z-normalised distance of the 2 subsequences