【发布时间】:2019-07-20 00:55:45
【问题描述】:
我正在尝试使用 sklearn 中的隔离森林检测乳腺癌数据集中的异常情况。我正在尝试将 Iolation Forest 应用于混合数据集,当我拟合模型时它会给我带来价值错误。
这是我的数据集: https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer/
这是我的代码:
from sklearn.model_selection import train_test_split
rng = np.random.RandomState(42)
X = data_cancer.drop(['Class'],axis=1)
y = data_cancer['Class']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 20)
X_outliers = rng.uniform(low=-4, high=4, size=(X.shape[0], X.shape[1]))
clf = IsolationForest()
clf.fit(X_train)
这是我得到的错误:
ValueError: 无法将字符串转换为浮点数:'30-39'
是否可以对分类数据使用隔离森林?如果是,我该怎么做?
【问题讨论】:
标签: python scikit-learn categorical-data outliers anomaly-detection