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

live.py 729 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
  1. import pandas as pd
  2. import numpy as np
  3. from tutorial import shared
  4. from tutorial import prepare_data
  5. import sys
  6. from scipy.sparse import dok_matrix, lil_matrix
  7. import numpy as np
  8. def construct_datapoint(text):
  9. data_dict = {col:[np.nan] for col in shared.all_raw_cols}
  10. data_dict[shared.col_body] = [text]
  11. return pd.DataFrame(data_dict)
  12. if __name__ == "__main__":
  13. text = sys.argv[1]
  14. df = construct_datapoint(text)
  15. print(df)
  16. pipeline = shared.load(shared.pipeline_pkl)
  17. df = prepare_data.map_dataframe(df, pipeline)
  18. df = df.drop(columns=[shared.col_id, shared.col_label])
  19. print(df)
  20. clf = shared.load(shared.classifier_pkl)
  21. y_pred = clf.predict(df.sparse.to_coo())
  22. print(y_pred)
Tip!

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

Comments

Loading...