Databricks, save a logistic regression to an object to be able to call it from another notebook

Viewed 82

I fitted to my data a logistic regression, in another notebook i am trying to predict the probabilities of the previously fitted function.

I would not like to call the all notebook and run everything every single time, i just would like to save the fitted logreg in an object or something like that and only call that in the other notebook on databriks.

This is my function:

log_test_var = logreg.fit(X_train, y_train)

from "gaming" notebook And I would like to save this log_test_var somewhere to predict my X column values from clean_text notebook

y_pred = log_test_var.predict(X)

Thanks

1 Answers

Unfortunately, it is not possible to call particular variable directly.

Workaround:-

Use %run function to call a notebook inside another notebook.

In below screenshot you can see I have created variable in parent notebook.

enter image description here

To access variable from parent notebook, I have used %run notebook_name

enter image description here

This method is suitable if you want to define a notebook that holds all the constant variables or a centralized shared function library. And you want to refer to them in the calling or child notebook.

You can refer this article by PAVAN BANGAD

Related