Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

modeling.py 888 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  1. from sklearn.ensemble import RandomForestClassifier
  2. from sklearn.metrics import roc_auc_score
  3. import pandas as pd
  4. from const import *
  5. import dagshub
  6. print(M_MOD_INIT, '\n' + M_MOD_LOAD_DATA)
  7. X_train = pd.read_csv(X_TRAIN_PATH)
  8. X_test = pd.read_csv(X_TEST_PATH)
  9. y_train = pd.read_csv(Y_TRAIN_PATH)
  10. y_test = pd.read_csv(Y_TEST_PATH)
  11. print(M_MOD_RFC)
  12. with dagshub.dagshub_logger() as logger:
  13. rfc = RandomForestClassifier(n_estimators=1, random_state=0)
  14. # log the model's parameters
  15. logger.log_hyperparams(model_class=type(rfc).__name__)
  16. logger.log_hyperparams({'model': rfc.get_params()})
  17. # Train the model
  18. rfc.fit(X_train, y_train.values.ravel())
  19. y_pred = rfc.predict(X_test)
  20. # log the model's performances
  21. logger.log_metrics({f'roc_auc_score': round(roc_auc_score(y_test, y_pred), 3)})
  22. print(M_MOD_SCORE, round(roc_auc_score(y_test, y_pred), 3))
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...