SKLearn server

Model Information

Basic

Model URI Structure

<model uri>
└── model.joblib
  1. model.joblib: The model file should be saved by the joblib format. For more information, please see scikit-learn Model persistence document

How It Works

You can check the detailed code in the Github. Here, we demonstrate by the pseudo-code.

Load the model

def __init__(self, model_uri):
    model_file = load_from_model_uri(model_uri)
    self._joblib = joblib.load(model_file)

Predict

def predict(self, X):
    return self._joblib.predict_proba(X)

Example

The example uses the scikit-learn iris dataset

Test Request

curl -X POST http://localhost:5000/api/v1.0/predictions \
    -H 'Content-Type: application/json' \
    -d '{ "data": {"tensor": {"shape": [1, 4], "values": [5.3, 3.5, 1.4, 0.2]}} }'

Test Result

{"data":{"names":["t:0","t:1","t:2"],"tensor":{"shape":[1,3],"values":[0.8700986370655746,0.1298937698872714,7.593047154034911e-06]}},"meta":{}}

Last updated