问题描述
由于该类的文档不是很清楚.我不明白我给它带来了什么价值.
这是我的代码:
clf = LinearSVC(random_state = seed,** params)cvscore = cross_val_score(clf,功能,标签)
我不确定这是否正确,或者我是否需要提供X_train和y_train而不是功能和标签.
谢谢
即使使用cross_val_score,分离测试集和训练集也是一个好主意.其背后的原因是知识泄漏.基本上,这意味着当您同时使用训练集和测试集时,会将信息从测试集泄漏到模型中,从而使模型带有偏见,从而导致错误的预测.
在同一问题上,博客文章详细./p>
参考文献:
As the documentation of the class is not very clear. I don't understand what value I give it.
This is my code:
clf = LinearSVC(random_state=seed, **params)
cvscore = cross_val_score(clf, features, labels)
I am not sure if this is correct or if I need to give X_train and y_train instead of features and labels.
Thanks
It is always a good idea to seperate the test set and training set, even while using cross_val_score. The reason behind this is knowledge leaking. It basically means that when you use both training and test sets, you are leaking information from test set into your model, thereby making your model biased, leading to incorrect predictions.
Here is detailed blog post on the same issue.
References:
- Reddit post on cross-validation
- Cross_val_Score example showing correct way of using it
- A similar question on stats.stackexchange
这篇关于我是要给cross_val_score()整个数据集,还是只给训练集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!