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

logistic_regression.py 929 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
27
28
  1. import plac
  2. from sklearn.linear_model import LogisticRegression
  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. out_path=("Path to save trained Model", "option", "o", str)
  7. )
  8. def main(data_path='data/features/', out_path='data/models/logistic/'):
  9. X_train, X_test, y_train, y_test = read_data(data_path)
  10. name = 'LogisticRegression'
  11. params = read_params('params.yaml', 'logistic')
  12. model = LogisticRegression(**params)
  13. model.fit(X_train, y_train)
  14. accuracy, c_matrix, fig = evaluate_model(model, X_test, y_test)
  15. print_results(accuracy, c_matrix, name)
  16. save_results(out_path, model, fig)
  17. log_experiment(out_path, params=params,
  18. metrics=dict(accuracy=accuracy, confusion_matrics=c_matrix))
  19. if __name__ == '__main__':
  20. plac.call(main)
Tip!

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

Comments

Loading...