SHARE
TWEET

Untitled

a guest Jun 27th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top