本文整理匯總了Python中sklearn.covariance.EllipticEnvelope.fit_predict方法的典型用法代碼示例。如果您正苦於以下問題:Python EllipticEnvelope.fit_predict方法的具體用法?Python EllipticEnvelope.fit_predict怎麽用?Python EllipticEnvelope.fit_predict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.covariance.EllipticEnvelope
的用法示例。
在下文中一共展示了EllipticEnvelope.fit_predict方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: elliptic_envelope
# 需要導入模塊: from sklearn.covariance import EllipticEnvelope [as 別名]
# 或者: from sklearn.covariance.EllipticEnvelope import fit_predict [as 別名]
def elliptic_envelope(df, modelDir, norm_confidence=0.95):
from sklearn.covariance import EllipticEnvelope
from scipy.stats import normaltest
if "ds" in df.columns:
del df["ds"]
model = EllipticEnvelope()
test_stats, p_vals = normaltest(df.values, axis=0)
normal_cols = p_vals >= (1 - norm_confidence)
df = df.loc[:, normal_cols]
if df.shape[1] == 0:
return None
df.outlier = model.fit_predict(df.values)
df.outlier = df.outlier < 0 # 1 if inlier, -1 if outlier
return df