我正在尝试使用sklearn中的Isolation Forest检测乳腺癌数据集中的异常。我正在尝试将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:无法将字符串转换为float:'30 -39'
是否可以对分类数据使用隔离林?如果是,我该怎么做