def fit(self, X, y=None):
"""Fit the model according to the given training data.
Parameters
----------
X : array-like of shape (n_samples, n_features)
Samples.
Returns
-------
self : detector
Return self.
"""
X = check_array(X)
if not self.assume_normalized:
self._normalizer = Normalizer().fit(X)
X = self._normalizer.transform(X)
mean = np.mean(X, axis=0)
self.mean_direction_ = mean / np.linalg.norm(mean)
self.y_score_ = self.anomaly_score(X)
df, loc, scale = chi2.fit(self.y_score_)
self.threshold_ = chi2.ppf(1.0 - self.fpr, df, loc, scale)
return self
评论列表
文章目录