transitive-bullshit/scikit-learn-ts

Fit persistence

glutamate opened this issue · 0 comments

Hi, this project looks incredible. Every time I compare sklearn with JS ML libraries, the python equivalents are much faster and more robust. I am looking to integrate sklearn with Saltcorn, an open-source no-code builder I wrote.

Is there a way to persist model fits? in python i can pickle a fit, save to database or file, and pickle.loads when it is time to make a prediction. Example:

# fit
clf = Pipeline(steps=[('preprocessor', ...),
                      ('classifier', LinearRegression())])

clf.fit(df_x, df_y)

str1=pickle.dumps(clf)

# load and predict
clf2 = pickle.loads(str1)
pred=clf2.predict(pandas.DataFrame.from_dict(...))

Is there a way to get the underlying python object as a blob or as JSON ? and to construct the JS object again?