问题描述
我的数据如下所示。它具有333行和2列。显然,第一行是异常。
ndf:
+---+---------+-------------+
| | ROW_CNT | TOT_SALE |
+---+---------+-------------+
| 0 | 45 | 1411.27 |
+---+---------+-------------+
| 1 | 47754 | 1596200.68 |
+---+---------+-------------+
| 2 | 105894 | 3750304.55 |
+---+---------+-------------+
| 3 | 372953 | 14368324.86 |
+---+---------+-------------+
| 4 | 389915 | 14899302.85 |
+---+---------+-------------+
我正在使用以下功能来检测数据集中2列的异常:
def outlier_func(df):
model = IsolationForest(behaviour='new',n_estimators=1000,max_samples='auto',contamination='auto',max_features=1.0)
model.fit(df[['ROW_CNT','TOT_SALE']])
df['scores'] = model.decision_function(df[['ROW_CNT','TOT_SALE']])
df['anomaly'] = model.predict(df[['ROW_CNT','TOT_SALE']])
anomaly = df.loc[df['anomaly'] == -1]
anomaly_index = list(anomaly.index)
return anomaly
outlier_func(ndf)
我想念的是它没有正确检测到异常。任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)