Hello QC Community!
I have a simple Sklearn Random Forest Model that I trained locally on my computer. I want to use it in my algorithm.
I understand there is an object store, but this is only for models trained in the cloud on the research notebook.
My ideal solution would be for me to save my model in Dropbox, and then download it in the algorithm. There have been previous threads about this, but none with a solution for my use case.
One solution I thought of was to serialize my model with one of the following packages.
- with sklearn-json
- with sklearn2pmml
- with sklearn-onnx
But it looks like none of these packages are listed as a supported library.
Has anybody done this successfully? If so, how did you do this?
Fred Painchaud
Hi Jonathan,
I read that you can persist your model via serialization, with pickle. See here :
Now, you would need to serialize as a string. So from what I am reading, don't use joblib. Make sure your output is a string and save that to a file.
Then you can most probably use QCAlgorithm's Download method and point it to your URI and get the string as output. The URI could I guess point to Dropbox, but make sure you add “?dl=1” at the end of the URI or in fact you will be downloading the web page showing your file to download, not the file itself.
And then use pickle to load.
Fred
P.S. Did not test. But if you did not, it's worth trying I'd say.
Jonathan Ng
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!