I want to have the formula of the model in order to use it in other languages/projects. Is there a way to export the formula from the model?
I will use sklearn linear regression model.
What I want to do eventually: given a formula f(), and data set 'd', I will have java script code that will give me predictions on d based on f().
The formula can be described essentially by the learned coefficients. The coefficients can be obtained using the attributes coef_
and intercept_
. The dot product between the coefficients and the input vector plus the intercept gives the output of the model.
The actual code that implements this "formula" in scikit-learn is something like:
return safe_sparse_dot(X, self.coef_.T,
dense_output=True) + self.intercept_
which should not be too difficult for you to port over to your other project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With