Skip to content

Create a new data science project

Orges Leka edited this page Dec 3, 2017 · 5 revisions

Suppose you want to create a new data science prediction project and deploy it on the server.

You could start as follows: (This assumes that you have already run source export_WEBSCIKITMODELSPATH.sh)

create_project.py boston4

This will create: boston4/fit_boston4.py boston4/boston4_model.py

Start by modifying fit_boston4.py so that you read your data-files, create a scikit-learn model and then save it. Then modify boston4_model.py. Change the method predict() as you wish. You may want to transform your data when a POST request comes to the server at your model.

When you are finished and happy with your model, run in the directory boston4/ the script fit_boston4.py. This will create boston4_model.pkl

Now it is time to check if the model you have written is pickle-compatible or not. To see this, run from the directory boston4/ the script: check_model.py boston4 If everything goes fine, you should see the metadata of your model. Otherwise you have to change either fit_boston4.py or boston4_model.py.

Suppose everything went fine and your model is ready to deploy: Copy manually (this will change hopefully in future, as I want to write a script deploy_model.py to do this automatically) the files boston4_model.py and boston4_model.pkl to the WEBSCIKITMODELSPATH, which should be the

{root-path of your webscikit-installation}/examples/models/

So you run the command from inside the boston4/ directory:

cp boston4.p* {root-path of your webscikit-installation}/examples/models/.

Then in the last step curl that you want to upload to the server: (This assumes, that ./webserver.py is running)

curl -X GET 'http://localhost:8000/loadModelAtURL?url=/boston4&model=boston4_model.pkl'

Now you should see at stats that your model is uploaded:

curl -X GET 'http://localhost:8000/stats'

Clone this wiki locally