predictions = df.copy()
y = df['gt']
noiter = 10
hits = 0
tpred = 0
for i in range(noiter):
Xtrain, Xtest, ytrain, ytest = train_test_split(df,test_size=0.3,random_state=noiter)
model = xgb.XGBClassifier()
model.fit(X_train,y_train)
pred_i = model.predict(X_test)
newcol = 'npred_' + str(noiter)
pred.loc[test.index,newcol] = pred_i
#now to calculate the misclassification rate
if pred_i != 'NaN':
tpred = tpred + 1
if pred_i == test['gt']:
hits = hits + 1
pred['missclassrate'] = hits/tpred
答案 0 :(得分:0)
您可以获取混淆矩阵以确定假阳性和阴性:
from sklearn.metrics import confusion_matrix
print confusion_matrix(ytest, pred_i)