This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Примечание: проверки на обратимость ковариационных матриц отсутствуют | |
import numpy as np | |
def mahalanobis(point_from, point_to, inverse_covariance_matrix): | |
delta = point_from - point_to | |
return max(np.float64(0), np.dot(np.dot(delta, inverse_covariance_matrix), delta)) ** 0.5 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def prekopcsac_lemire(class_): | |
m, n = class_.shape | |
r = np.corrcoef(class_, rowvar=False) | |
# CALC standardized class_ | |
mean_vec = class_.mean(axis=0) | |
std_vec = class_.std(axis=0, ddof=1) | |
smx = (class_ - np.tile(mean_vec, (m, 1))) / np.tile(std_vec, (m, 1)) |