Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Last active June 2, 2022 08:01
Show Gist options
  • Save Abhayparashar31/46f9f4c28248afdd4632bbfd035d680b to your computer and use it in GitHub Desktop.
Save Abhayparashar31/46f9f4c28248afdd4632bbfd035d680b to your computer and use it in GitHub Desktop.
mse [] ## Regression Problem
accuracy_scores = [] ## Classification Problem
""" Train and Test Data Created Using Cross Validation"""
for train_index,test_index in kFold.split(X,y):
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
print("Train Index:", train_index, "|", "Test Index:", test_index)
##### MODEL TRAINING #####
model.fit(X_train,y_train)
predictions = model.predict(X_test) ## Predictions
##### MODEL VALIDATION ####
""" Regression Problems """
from sklearn.metrics import mean_squared_error
mse.append(mean_squared_error(y_test,predictions))
""" Classification Problems """
accuracy_scores.append(accuracy_score(predictions,y_test))
""" Classification """
print('Accuracy Scores:', accuracy_scores)
print('Average Accuracy:', np.mean(accuracy_scores))
""" Regression """
print('MSE:', mse)
print('Average MSE:', np.mean(mse))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment