Shortcuts

modelzoo.sklearn

modelzoo.sklearn.deploy(model: sklearn.base.BaseEstimator, model_name: Optional[str] = None, resources_config: Optional[modelzoo.resources_config.ResourcesConfig] = None, api_key: Optional[str] = None, wait_until_healthy: bool = True) → None

Deploy a scikit-learn model to your zoo.

Note

This function will serialize a model as a joblib file to a temporary directory on the filesystem before uploading it to Model Zoo.

Parameters
  • model – A scikit-learn model object to deploy.

  • model_name – Optional string name of the model. If not provided, a random name will be generated. Model name must be unique across all of a user’s models.

  • resources_config – An optional modelzoo.ResourcesConfig that specifies the resources (e.g. memory, CPU) to use for the model. Defaults to modelzoo.ResourcesConfig().

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

  • wait_until_healthy – If True (default), this function will refrain from returning until the model has reached a HEALTHY state.

Returns

The name of the created model.

modelzoo.sklearn.predict(model_name: str, input_value: numpy.ndarray, return_prediction: bool = True, return_probabilities: bool = False, api_key: Optional[str] = None) → Dict[str, Any]

Send a prediction to a scikit-learn model.

Parameters
  • model_name – String name of the model.

  • input_value – A numpy.ndarray to use for prediction. The input data should conform to the shape expected by the model.

  • return_prediction – Boolean (default: True) that specifies whether to return the prediction, e.g. the result from model.predict().

  • return_probabilities – Boolean (default: False) that specifies whether to return a full dictionary of class names to probabilities , e.g. the result from model.predict_proba().

  • api_key – Will override the environment api key, if present.

Returns

An output dictionary containing one or both of the following, depending on whether return_prediction and/or return_probabilities were specified.

  • "prediction"

    A list of predictions, e.g. the value returned by model.predict.

  • "probabilities"

    A list of dictionaries representing label probabilities, e.g. similar to the value returned by model.predict_proba. Each dictionary maps class label strings to the respective probability for that label.