I have built a very simple machine learning model, and I’d like to include it in my electron app. (For context, the model scores short-response answers to math questions.) The model is built with scikit-learn, CountVectorizer, pandas, etc. (the usual). I’ve seen a lot of good information online about spawning child processes to run the script, but I assume that I need to package python and the requisite modules in the standalone app. How could one do this?
Since the Python is a core part of your application, and considering the fact that many users of machine learning models will already have Python installed, you could expand on the idea of a task runner script to take a full survey of the local Python environment. If the user has all of the relevant packages and the right version of Python, you could give them a prompt asking if they want to download a new interpreter or use their own. If they want to use their own, you can have the task runner create a
virtualenv folder (or even make that optional).
Another option is to use a Python framework that functions like Electron. I know of two, CEF Python (extensive feature set, very powerful, with a lot of high-end users which means that there should be a lot of robust examples out in the wild) and Eel (small, low overhead, perfect for prototyping).
Great answer. Thank you. Given how simple my model is, I’ll give brain.js a whirl and then return to these ideas if that doesn’t give me what I need.