小编Mar*_*yan的帖子

如何修复 X ​​没有有效的功能名称,但 IsolationForest 配备了功能名称 warnings.warn(

这是我的代码:

import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.ensemble import IsolationForest

data = pd.read_csv('marks1.csv', encoding='latin-1',
                   on_bad_lines='skip', index_col=0, header=0
                   )

random_state = np.random.RandomState(42)

model = IsolationForest(n_estimators=100, max_samples='auto', contamination=float(0.2)
                        , random_state=random_state)

model.fit(data[['Mark']])

random_state = np.random.RandomState(42)

data['scores'] = model.decision_function(data[['Mark']])

data['anomaly_score'] = model.predict(data[['Mark']])

data[data['anomaly_score'] == -1].head()
Run Code Online (Sandbox Code Playgroud)

错误:

C:\Program Files\Python39\lib\site-packages\sklearn\base.py:450: UserWarning: X 没有有效的功能名称,但 IsolationForest 配备了功能名称 warnings.warn(

python pandas scikit-learn

10
推荐指数
1
解决办法
2万
查看次数

标签 统计

pandas ×1

python ×1

scikit-learn ×1