通过jupyter上的python 3,我创建了具有随机森林的预测模型。作为交叉验证,我将留一法应用于模型。使用留一法时,是否无法绘制ROC曲线?以下是我的代码。
import numpy as np
from sklearn.model_selection import train_test_split
data = np.loadtxt('*****.csv', delimiter=',',skiprows=1,dtype=float)
labels = data[:, 0:1]
features = data[:, 1:]
X_train, X_test, y_train, y_test = train_test_split(features, labels.ravel(), random_state=0)
from sklearn.ensemble import RandomForestClassifier
forest=RandomForestClassifier(n_estimators=100,random_state=7)
forest.fit(X_train,y_train)
from sklearn.model_selection import LeaveOneOut
from sklearn.model_selection import cross_val_score
loo=LeaveOneOut()
scores = cross_val_score(forest, features, labels.ravel(), cv=loo)