https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_val_score.html#sklearn.model_selection.cross_val_score
是否可以强制使用分层k折?我怎么知道使用了k折?
最佳答案
用这个:
cross_val_score(estimator, X, y, cv=YOURCHOICE)
例:
from sklearn import datasets, linear_model
from sklearn.model_selection import cross_val_score
diabetes = datasets.load_diabetes()
from sklearn.model_selection import StratifiedKFold
X = diabetes.data[:150]
y = diabetes.target[:150]
lasso = linear_model.Lasso()
skf = StratifiedKFold(n_splits=2)
results = cross_val_score(lasso, X, y, cv=skf)
关于python - 强制sklearn交叉val分数使用分层k折?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59002684/