python - 每次运行都发现不同的异常 - 隔离森林
问题描述
我使用 sklearn 和 Python 构建了一个隔离森林,每次运行模型来查找异常时,我得到的结果都略有不同。
我的数据有 100 行,每次我在第 90-100 行中得到 4-8 个异常的不同组合,有谁知道为什么会这样?
谢谢您的帮助。我附上了一些我用过的代码。
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=0)
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
model = IsolationForest(n_estimators = 100, max_samples = 'auto',
contamination = 'auto')
model.fit(df[['label']])
anomaly = df.loc[df['anomaly']==-1]
解决方案
推荐阅读
- python-wheel - 如何使用 Azure Synapse Analytics 将自定义 python 库导入 apache spark 池?
- android - 在 android/flutter 中实现一个粘性服务
- javascript - postgres - windows docker容器的密码身份验证失败
- javascript - 如何制作类似于推特帖子的数字增量动画,如计数器
- ruby-on-rails - 如何在没有矩阵格式信息的情况下截断 ActionText 输出
- laravel - livewire alpine flatpickr 变空
- python - 如何正确实现动量和衰减 - SGD
- serilog - 我怎样才能让 Serilog 知道日志记录在哪里?
- matlab - Matlab脚本编辑——模型识别
- vba - 使用 Excel 中的 2 列值创建文件夹