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

evaluate.py 938 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
29
30
31
  1. import sklearn.metrics as metrics
  2. import pickle
  3. import json
  4. import numpy as np
  5. import pandas as pd
  6. def evaluate():
  7. print("Model Evaluation")
  8. x_test = np.load("data/processed_data/x_test.npy")
  9. y_test = np.load("data/processed_data/y_test.npy")
  10. scaling_model = pickle.load(open("data/scaling_model.pkl", "rb"))
  11. x_te_scale = scaling_model.transform(x_test)
  12. print("done")
  13. model = pickle.load(open("data/gbrt_model.pkl", "rb"))
  14. predictions = model.predict(x_te_scale)
  15. prediction_csv = pd.DataFrame({"target_labels": y_test,
  16. "predicted_labels": predictions})
  17. prediction_csv.to_csv("data/prediction.csv", index=False)
  18. mse = metrics.mean_squared_error(y_test, predictions)
  19. r2 = metrics.r2_score(y_test, predictions)
  20. with open("scores.json", "w") as fd:
  21. json.dump({"mse": mse, "r2": r2}, fd, indent=4)
  22. if __name__ == '__main__':
  23. evaluate()
Tip!

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

Comments

Loading...