pdmlabs.evaluation.vus.utils.stat_models#
A collection of statistical models code copied from pyod documentation yzhao062/pyod
Functions
Utility function to calculate row-wise euclidean distance of two matrix. |
|
|
Utility function to calculate pearson matrix (row-wise). |
|
Utility function to calculate the weighted Pearson correlation of two samples. |
- pdmlabs.evaluation.vus.utils.stat_models.pairwise_distances_no_broadcast(X, Y)#
Utility function to calculate row-wise euclidean distance of two matrix. Different from pair-wise calculation, this function would not broadcast. For instance, X and Y are both (4,3) matrices, the function would return a distance vector with shape (4,), instead of (4,4). :param X: First input samples :type X: array of shape (n_samples, n_features) :param Y: Second input samples :type Y: array of shape (n_samples, n_features)
- Returns:
distance – Row-wise euclidean distance of X and Y
- Return type:
array of shape (n_samples,)
- pdmlabs.evaluation.vus.utils.stat_models.pearsonr_mat(mat, w=None)#
Utility function to calculate pearson matrix (row-wise). :param mat: Input matrix. :type mat: numpy array of shape (n_samples, n_features) :param w: Weights. :type w: numpy array of shape (n_features,)
- Returns:
pear_mat – Row-wise pearson score matrix.
- Return type:
numpy array of shape (n_samples, n_samples)
- pdmlabs.evaluation.vus.utils.stat_models.wpearsonr(x, y, w=None)#
Utility function to calculate the weighted Pearson correlation of two samples. See https://stats.stackexchange.com/questions/221246/such-thing-as-a-weighted-correlation for more information :param x: Input x. :type x: array, shape (n,) :param y: Input y. :type y: array, shape (n,) :param w: Weights w. :type w: array, shape (n,)
- Returns:
scores – Weighted Pearson Correlation between x and y.
- Return type:
float in range of [-1,1]