scores.MahalanobisScore

Returns the Mahalanobis distance to the training samples distribution.

Usage

Source

scores.MahalanobisScore()

Computes Mahalanobis distance-based confidence scores where low scores indicate samples similar to the training distribution (likely inliers) and high scores indicate samples deviating from the training distribution (likely outliers).

The Mahalanobis distance accounts for correlations in the training data by whitening the embeddings with the Cholesky factor of the training covariance matrix prior to computing Euclidean nearest-neighbour distances.

Parameters

k: int = 1

Number of nearest neighbors to use.

stat: (max, mean, median, min) = "max"

Statistic to aggregate distances across the k neighbors.

pca: TensorPCA or None = None

Optional PCA for dimensionality reduction prior to scoring.

save_index: bool or Path = False
Whether (and where) to save the HNSW index to disk.

Attributes

Name Description
ident str(object=’’) -> str
k int([x]) -> integer

ident

str(object=’’) -> str

ident: str = "mahalanobis"

str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.


k

int([x]) -> integer

k: int

int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

See Also