Found an error in the code for this:
–> 2 from sklearn.externals.six import StringIO
raises an error message which goes away and then runs OK if you replace with:
from six import StringIO
How do we “save” a tree model for ongoing, future use?
You gave an example of using “predict” inside the code for new data.
How can we save that model and then call predict with new data, maybe even from a regular Python window?
Found an error in the code for this:
–> 2 from sklearn.externals.six import StringIO
raises an error message which goes away and then runs OK if you replace with:
from six import StringIO
Thanks for catching that… it must have changed in a recent Anaconda update. I’ll upload a corrected notebook to the course materials in a minute.
How do we “save” a tree model for ongoing, future use?
You gave an example of using “predict” inside the code for new data.
How can we save that model and then call predict with new data, maybe even from a regular Python window?
Thanks for the great courses.
There’s no special way to do it; you’d just “pickle” the model to store it as you would with any Python object, and then reload it. There’s an example at https://stackoverflow.com/questions/26139826/save-a-decision-tree-model-in-scikit