首页 文章

使用Cross_Val_score的原因

提问于
浏览
0

我对使用cross_val_score的原因感到困惑 .

根据我的理解,cross_val_score告诉我的模型是'overfitting'还是'underfitting' . 而且,它不训练我的模型 .

因为我只有1个特征,所以它是tfidf(稀疏矩阵) . 如果它不合适,我不知道该怎么办 .

Q1: Did I use it in wrong order? I've seen both 'cross->fit' and 'fit->cross' examples.

Q2: What did the scores in '#print1' tell me? Does it mean I have to train my model k-times (with the same training set) where k is the k-fold that give the best score?

我的代码现在:

model1=GaussianNB(priors=None)

score=cross_val_score(model1, X_train.toarray(), y_train,cv=3,scoring='accuracy')

# print1
print (score.mean())

model1.fit(X_train.toarray(),y_train)
predictions1 = model1.predict(X_test.toarray()) #held out data  

# print2
print (classification_report(predictions1,y_test))

1 回答

  • 0

    Here是关于交叉验证的一些信息 .

    订单( cross 然后 fit )对我来说似乎没问题 .

    首先,您要评估模型在已知数据上的性能 . 取所有CV分数的平均值很有意思,但也许最好留下原始分数,看看你的模型是否在某些集合上不起作用 .

    如果您的模型有效,那么您可以在火车上设置它 fit 并在测试仪上设置 predict .

    训练相同的模型 k 次不会改变任何东西 .

相关问题