Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import numpy as np
  2. from sklearn import <model_name>
  3.  
  4. from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score, r2_score
  5. from sklearn.cross_validation import train_test_split
  6.  
  7. train_data, test_data, train_label, test_label = train_test_split(
  8. df['features'],
  9. df['label'],
  10. test_size=0.33,
  11. random_state=42
  12. )
  13.  
  14. model = <model_name>(iterations=2, depth=2, learning_rate=1, loss_function='RMSE', logging_level='Verbose')
  15.  
  16. model.fit(train_data, train_label,)
  17.  
  18. preds_class = model.predict(train_data)
  19.  
  20. print(" accuracy = ", accuracy_score(preds_class, train_label))
  21. print(" recall_score = ", recall_score(preds_class, train_label))
  22. print(" precision_score = ", precision_score(preds_class, train_label))
  23. print(" f1_score = ", f1_score(preds_class, train_label))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement