Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # split data into train+validation set and test set
  2. X_trainval, X_test, y_trainval, y_test = train_test_split(dataset.data, dataset.target)
  3. # split train+validation set into training and validation sets
  4. X_train, X_valid, y_train, y_valid = train_test_split(X_trainval, y_trainval)
  5. # train on classifier
  6. clf.fit(X_train, y_train)
  7. # evaluate the classifier on the test set
  8. score = svm.score(X_valid, y_valid)
  9. # combined training & validation set and evaluate it on the test set
  10. clf.fit(X_trainval, y_trainval)
  11. test_score = svm.score(X_test, y_test)
  12.  
  13. import numpy as np
  14. from sklearn import metrics
  15. y = np.array([1, 1, 2, 2])
  16. scores = np.array([0.1, 0.4, 0.35, 0.8])
  17. fpr, tpr, thresholds = metrics.roc_curve(y, scores, pos_label=2)
  18.  
  19. print(fpr)
  20.  
  21. print(tpr)
  22.  
  23. print(thresholds)
  24.  
  25. y_preds = clf.predict(X_test)
  26.  
  27. from sklearn.metrics import roc_curve, auc
  28.  
  29. fpr, tpr, thresholds = roc_curve(y, y_preds, pos_label=1)
  30. auc_roc = auc(fpr, tpr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement