hs) along with Python SDK (
hydrosdk) _**_installed on your local machine. If you don't have them yet, please follow these guides first:
hsknow where the Hydrosphere platform runs, configure a new
hsparse and upload the model correctly. Make sure that the structure of your local model directory looks like this by the end of the model preparation section:
train.py- a training script for our model
requirements.txt- provides dependencies for our model
model.joblib- a model artifact that we get as a result of model training
src/func_main.py- an inference script that defines a function for making model predictions
serving.yaml- a resource definition file to let Hydrosphere know which function to call from the
func_main.pyscript and let the model manager understand model’s inputs and outputs.
logistic_regressionfolder, create a
requirements.txtfile and provide dependencies inside:
/model/filesdirectory inside the container, so we will look there to load the model.
/srcfolder of your model directory:
predict(or similar) method of your model and return your predictions:
func_main.pywe initialize our model outside of the serving function
infer.This process will not be triggered every time a new request comes in.
inferfunction takes the actual request, unpacks it, makes a prediction, packs the answer, and returns it. There is no strict rule for naming this function, it just has to be a valid Python function name.
func_main.pyfile, we have to provide a resource definition file. This file will define a function to be called, inputs and outputs of a model, a signature function, and some other metadata required for serving.
serving.yamlin the root of your model directory
serving.yamlwe also provide
model.joblibas payload files to our model:
logistic_regressionmodel directory run:
Released, then you can use it.
Add New Applicationbutton. In the opened window select the
logistic_regressionmodel, name your application
logistic_regressionand click the "Add Application" button.
training-data=<path_to_csv>field to the
serving.yamlfile. Run the following script to save training data used in previous steps as a
logistic_regressionapplication. To update it, we can go to the Application tab and click the "Update" button: