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

random_forrest.py 1.1 KB

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
27
28
29
30
  1. import plac
  2. from sklearn.ensemble import RandomForestClassifier
  3. from utils import evaluate_model, print_results, save_results, log_experiment, read_data, read_params
  4. @plac.annotations(
  5. data_path=("Path to source data", "option", "i", str),
  6. n_estimators=("Path to save trained Model", "option", "e", str),
  7. max_samples=("Path to save trained Model", "option", "s", str),
  8. out_path=("Path to save trained Model", "option", "o", str)
  9. )
  10. def main(data_path='data/features/', out_path='data/models/r_forrest/', n_estimators=10, max_samples=30):
  11. X_train, X_test, y_train, y_test = read_data(data_path)
  12. name = 'RandomForrest'
  13. params = read_params('params.yaml', 'forrest')
  14. model = RandomForestClassifier(**params)
  15. model.fit(X_train, y_train)
  16. accuracy, c_matrix, fig = evaluate_model(model, X_test, y_test)
  17. print_results(accuracy, c_matrix, name)
  18. save_results(out_path, model, fig)
  19. log_experiment(out_path, params=params,
  20. metrics=dict(accuracy=accuracy, confusion_matrics=c_matrix))
  21. if __name__ == '__main__':
  22. plac.call(main)
Tip!

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

Comments

Loading...