Created
January 24, 2024 06:12
-
-
Save wibowotangara/db7f17c6d400157a416b70c34bfb05ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import KFold | |
from sklearn.model_selection import cross_val_score | |
model = RandomForestClassifier() | |
k_fold = KFold(n_splits=5, shuffle=True, random_state=42) | |
scores = cross_val_score(model, X_train, Y_train, cv=k_fold, scoring='accuracy') | |
for i, score in enumerate(scores, 1): | |
print(f'Fold {i}: Accuracy = {score:.4f}') | |
print(f'Mean Accuracy: {np.mean(scores):.4f}') | |
print(f'Standard Deviation: {np.std(scores):.4f}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment