pdmlabs.evaluation.vus.models.distance#

Classes of distance measure for model type A

Classes

DTW([method])

The function class for dynamic time warping measure

EDRS([method, ep, vol])

The function class for edit distance on real sequences

Euclidean([power, neighborhood, window, norm])

The function class for Lp euclidean norm :2: (WARNING/2) Title underline too short. The function class for Lp euclidean norm ---------- Power int, optional (default=1) The power of the lp norm. For power = k, the measure is calculagted by |x - y|_k :4: (WARNING/2) Inline substitution_reference start-string without end-string. neighborhood int, optional (default=max (100, 10*window size)) The length of neighborhood to derivete the normalizing constant D which is based on the difference of maximum and minimum in the neighborhood minus window. window: int, optional (default = length of input data) The length of the subsequence to be compaired :10: (WARNING/2) Definition list ends without a blank line; unexpected unindent. pdmlabs.evaluation.vus.models.distance.decision_scores_

Fourier([power])

The function class for Fourier measure good for contextual anomolies ---------- power: int, optional (default = 2) Lp norm for dissimiarlity measure considered .. attribute:: decision_scores_.

Garch([p, q, mean, vol])

The function class for garch measure :2: (WARNING/2) Title underline too short. The function class for garch measure ---------- p, q int, optional (default=1, 1) The order of the garch model to be fitted on the residual mean string, optional (default='zero' ) The forecast conditional mean. vol: string, optional (default = 'garch') he forecast conditional variance. :9: (WARNING/2) Definition list ends without a blank line; unexpected unindent. pdmlabs.evaluation.vus.models.distance.decision_scores_

Mahalanobis([probability])

The function class for Mahalanobis measure :2: (WARNING/2) Title underline too short. The function class for Mahalanobis measure ---------- Probability boolean, optional (default=False) Whether to derive the anomoly score by the probability that such point occurs neighborhood int, optional (default=max (100, 10*window size)) The length of neighborhood to derivete the normalizing constant D which is based on the difference of maximum and minimum in the neighborhood minus window. :8: (WARNING/2) Definition list ends without a blank line; unexpected unindent. pdmlabs.evaluation.vus.models.distance.decision_scores_

SSA_DISTANCE([method, e])

The function class for SSA measure good for contextual anomolies ---------- method : string, optional (default='linear' ) The method to fit the line and derives the SSA score e: float, optional (default = 1) The upper bound to start new line search for linear method .. attribute:: decision_scores_.

TWED([gamma, v])

Function class for Time-warped edit distance(TWED) measure

class pdmlabs.evaluation.vus.models.distance.DTW(method='L2')#

Bases: object

The function class for dynamic time warping measure

Avaliable “L2”, “L1”, and custom

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X1, X2, start_index)#

Obtain the SSA similarity score. :param X1: the reference timeseries :type X1: numpy array of shape (n, ) :param X2: the tested timeseries :type X2: numpy array of shape (n, ) :param index: :type index: int, :param current index for the subseqeuence that is being measured:

Returns:

score

Return type:

float, the higher the more dissimilar are the two curves

set_param()#

update the parameters with the detector that is used since the FFT measure doens’t need the attributes of detector or characteristics of X_train, the process is omitted.

class pdmlabs.evaluation.vus.models.distance.EDRS(method='L1', ep=False, vol=False)#

Bases: object

The function class for edit distance on real sequences

Avaliable “L2”, “L1”, and custom

ep: float, optiona (default = 0.1)

the threshold value to decide Di_j

votboolean, optional (default = False)

whether to adapt a chaging votilities estimaed by garch for ep at different windows.

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X1, X2, start_index)#

Obtain the SSA similarity score. :param X1: the reference timeseries :type X1: numpy array of shape (n, ) :param X2: the tested timeseries :type X2: numpy array of shape (n, ) :param index: :type index: int, :param current index for the subseqeuence that is being measured:

Returns:

score

Return type:

float, the higher the more dissimilar are the two curves

set_param()#

update the ep based on the votalitiy of the model

class pdmlabs.evaluation.vus.models.distance.Euclidean(power=1, neighborhood=100, window=20, norm=False)#

Bases: object

The function class for Lp euclidean norm#

Powerint, optional (default=1)

The power of the lp norm. For power = k, the measure is calculagted by |x - y|_k

neighborhoodint, optional (default=max (100, 10*window size))

The length of neighborhood to derivete the normalizing constant D which is based on the difference of maximum and minimum in the neighborhood minus window.

window: int, optional (default = length of input data)

The length of the subsequence to be compaired

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X, Y, index)#

Derive the decision score based on the given distance measure :param X: The real input samples subsequence. :type X: numpy array of shape (n_samples, ) :param Y: The estimated input samples subsequence. :type Y: numpy array of shape (n_samples, ) :param Index: :type Index: int :param the index of the starting point in the subsequence:

Returns:

score – dissimiarity score between the two subsquence

Return type:

float

set_param()#
class pdmlabs.evaluation.vus.models.distance.Fourier(power=2)#

Bases: object

The function class for Fourier measure good for contextual anomolies ———- power: int, optional (default = 2)

Lp norm for dissimiarlity measure considered

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X2, X3, start_index)#

Obtain the SSA similarity score. :param X2: the reference timeseries :type X2: numpy array of shape (n, ) :param X3: the tested timeseries :type X3: numpy array of shape (n, ) :param index: :type index: int, :param current index for the subseqeuence that is being measured:

Returns:

score

Return type:

float, the higher the more dissimilar are the two curves

set_param()#

update the parameters with the detector that is used since the FFT measure doens’t need the attributes of detector or characteristics of X_train, the process is omitted.

class pdmlabs.evaluation.vus.models.distance.Garch(p=1, q=1, mean='zero', vol='garch')#

Bases: object

The function class for garch measure#

p, qint, optional (default=1, 1)

The order of the garch model to be fitted on the residual

meanstring, optional (default=’zero’ )

The forecast conditional mean.

vol: string, optional (default = ‘garch’)

he forecast conditional variance.

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X, Y, index)#

Derive the decision score based on the given distance measure :param X: The real input samples subsequence. :type X: numpy array of shape (n_samples, ) :param Y: The estimated input samples subsequence. :type Y: numpy array of shape (n_samples, ) :param Index: :type Index: int :param the index of the starting point in the subsequence:

Returns:

score – dissimiarity score between the two subsquences

Return type:

float

set_param()#

update the parameters with the detector that is used

class pdmlabs.evaluation.vus.models.distance.Mahalanobis(probability=False)#

Bases: object

The function class for Mahalanobis measure#

Probabilityboolean, optional (default=False)

Whether to derive the anomoly score by the probability that such point occurs

neighborhoodint, optional (default=max (100, 10*window size))

The length of neighborhood to derivete the normalizing constant D which is based on the difference of maximum and minimum in the neighborhood minus window.

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(X, Y, index)#

Derive the decision score based on the given distance measure :param X: The real input samples subsequence. :type X: numpy array of shape (n_samples, ) :param Y: The estimated input samples subsequence. :type Y: numpy array of shape (n_samples, ) :param Index: :type Index: int :param the index of the starting point in the subsequence:

Returns:

score – dissimiarity score between the two subsquence

Return type:

float

norm_pdf_multivariate(x)#

multivarite normal density function

normpdf(x)#

univariate normal

set_param()#

update the parameters with the detector that is used

class pdmlabs.evaluation.vus.models.distance.SSA_DISTANCE(method='linear', e=1)#

Bases: object

The function class for SSA measure good for contextual anomolies ———- method : string, optional (default=’linear’ )

The method to fit the line and derives the SSA score

e: float, optional (default = 1)

The upper bound to start new line search for linear method

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

Linearization(X2)#

Obtain the linearized curve. :param X2: the time series curve to be fitted :type X2: numpy array of shape (n, ) :param e: :type e: float, integer, or numpy array :param weights to obtain the:

Returns:

fit

Return type:

parameters for the fitted linear curve

measure(X2, X3, start_index)#

Obtain the SSA similarity score. :param X2: the reference timeseries :type X2: numpy array of shape (n, ) :param X3: the tested timeseries :type X3: numpy array of shape (n, ) :param e: :type e: float, integer, or numpy array :param weights to obtain the:

Returns:

score

Return type:

float, the higher the more dissimilar are the two curves

set_param()#

update the parameters with the detector that is used. Since the SSA measure doens’t need the attributes of detector or characteristics of X_train, the process is omitted.

class pdmlabs.evaluation.vus.models.distance.TWED(gamma=0.1, v=0.1)#

Bases: object

Function class for Time-warped edit distance(TWED) measure

Avaliable “L2”, “L1”, and custom

gamma: float, optiona (default = 0.1)

mismatch penalty

vfloat, optional (default = False)

stifness parameter

decision_scores_#

The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.

Type:

numpy array of shape (n_samples,)

detector#

the anomaly detector that is used

Type:

Object classifier

measure(A, B, start_index)#

Obtain the SSA similarity score. :param X1: the reference timeseries :type X1: numpy array of shape (n, ) :param X2: the tested timeseries :type X2: numpy array of shape (n, ) :param index: :type index: int, :param current index for the subseqeuence that is being measured:

Returns:

score

Return type:

float, the higher the more dissimilar are the two curves

set_param()#

No need