Skip to content

Instantly share code, notes, and snippets.

@amandaiglesiasmoreno
Created November 22, 2021 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandaiglesiasmoreno/e0928eae6e1bc3bccad408b9ad00ccd6 to your computer and use it in GitHub Desktop.
Save amandaiglesiasmoreno/e0928eae6e1bc3bccad408b9ad00ccd6 to your computer and use it in GitHub Desktop.
# test the accuracy of each model using default hyperparameters
results = []
names = []
scoring = 'accuracy'
for name, model in models:
# fit the model with the training data
model.fit(X_train, y_train).predict(X_test)
# make predictions with the testing data
predictions = model.predict(X_test)
# calculate accuracy
accuracy = accuracy_score(y_test, predictions)
# append the model name and the accuracy to the lists
results.append(accuracy)
names.append(name)
# print classifier accuracy
print('Classifier: {}, Accuracy: {})'.format(name, accuracy))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment