Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def evaluation(X_train, Y_train, X_test, Y_test, models):
  2. '''
  3. Runs test data through all models. Prints confusion matrices and classification reports.
  4.  
  5. Parameters: training set and test set, array of models
  6. Returns: none
  7. '''
  8. for name, model in models:
  9. model.fit(X_train, Y_train)
  10. pred = model.predict(X_test)
  11. print('\n\n\n%s Accuracy: %.2f' % (name, accuracy_score(Y_test, pred)))
  12. labels = np.unique(Y_test)
  13. confusion = confusion_matrix(Y_test, pred, labels=labels)
  14. print('\nConfusion Matrix:')
  15. print(pd.DataFrame(confusion, index=labels, columns=labels))
  16. print('\nClassification Report:')
  17. print(classification_report(Y_test, pred))
  18. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement