hier ist der Code, den ich auf einem linearen Regressionsmodell Kreuzvalidierung durchführen verwenden und auch die Details zu erhalten:
from sklearn.model_selection import cross_val_score
scores = cross_val_score(clf, X_Train, Y_Train, scoring="neg_mean_squared_error", cv=10)
rmse_scores = np.sqrt(-scores)
Wie gesagt in this Buch auf Seite 108 dies ist der Grund, warum wir -score verwenden:
Scikit-Learn cross-validation features expect a utility function (greater is better) rather than a cost function (lower is better), so the scoring function is actually the opposite of the MSE (i.e., a negative value), which is why the preceding code computes -scores before calculating the square root.
und das Ergebnis verwendet diese einfache Funktion sichtbar zu machen:
def display_scores(scores):
print("Scores:", scores)
print("Mean:", scores.mean())
print("Standard deviation:", scores.std())
Ich benutze Python3, und ich habe die folgende Fehlermeldung: ImportError: Kein Modul mit dem Namen 'sklearn.model_selection'. Irgendwelche Hinweise? – Ryo
Welche scikit-learn Version verwendest du? Die model_selection-Modul-Funktionalität, die im cross_validation-Modul verwendet wurde – Elisha
Ich verwende '0.17.1' – Ryo