# Scikit-Learn runtime for MLServer
This package provides a MLServer runtime compatible with Scikit-Learn.
## Usage
You can install the runtime, alongside `mlserver`, as:
```bash
pip install mlserver mlserver-sklearn
```
For further information on how to use MLServer with Scikit-Learn, you can check
out this [worked out example](../../docs/examples/sklearn/README.md).
## Content Types
If no [content type](../../docs/user-guide/content-type) is present on the
request or metadata, the Scikit-Learn runtime will try to decode the payload as
a [NumPy Array](../../docs/user-guide/content-type).
To avoid this, either send a different content type explicitly, or define the
correct one as part of your [model's
metadata](../../docs/reference/model-settings).
## Model Outputs
The Scikit-Learn inference runtime exposes a number of outputs depending on the
model type.
These outputs match to the `predict`, `predict_proba` and `transform` methods
of the Scikit-Learn model.
| Output | Returned By Default | Availability |
| --------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `predict` | ✅ | Available on most models, but not in [Scikit-Learn pipelines](https://scikit-learn.org/stable/modules/compose.html). |
| `predict_proba` | ❌ | Only available on non-regressor models. |
| `transform` | ❌ | Only available on [Scikit-Learn pipelines](https://scikit-learn.org/stable/modules/compose.html). |
By default, the runtime will only return the output of `predict`.
However, you are able to control which outputs you want back through the
`outputs` field of your {class}`InferenceRequest
<mlserver.types.InferenceRequest>` payload.
For example, to only return the model's `predict_proba` output, you could
define a payload such as:
```{code-block} json
---
emphasize-lines: 10-12
---
{
"inputs": [
{
"name": "my-input",
"datatype": "INT32",
"shape": [2, 2],
"data": [1, 2, 3, 4]
}
],
"outputs": [
{ "name": "predict_proba" }
]
}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "mlserver-sklearn",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.12,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Seldon Technologies Ltd.",
"author_email": "hello@seldon.io",
"download_url": "https://files.pythonhosted.org/packages/20/84/64146775ae97d1bb5865b555a43eee2137611d95fa49245b0c7c27602311/mlserver_sklearn-1.6.1.tar.gz",
"platform": null,
"description": "# Scikit-Learn runtime for MLServer\n\nThis package provides a MLServer runtime compatible with Scikit-Learn.\n\n## Usage\n\nYou can install the runtime, alongside `mlserver`, as:\n\n```bash\npip install mlserver mlserver-sklearn\n```\n\nFor further information on how to use MLServer with Scikit-Learn, you can check\nout this [worked out example](../../docs/examples/sklearn/README.md).\n\n## Content Types\n\nIf no [content type](../../docs/user-guide/content-type) is present on the\nrequest or metadata, the Scikit-Learn runtime will try to decode the payload as\na [NumPy Array](../../docs/user-guide/content-type).\nTo avoid this, either send a different content type explicitly, or define the\ncorrect one as part of your [model's\nmetadata](../../docs/reference/model-settings).\n\n## Model Outputs\n\nThe Scikit-Learn inference runtime exposes a number of outputs depending on the\nmodel type.\nThese outputs match to the `predict`, `predict_proba` and `transform` methods\nof the Scikit-Learn model.\n\n| Output | Returned By Default | Availability |\n| --------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------- |\n| `predict` | \u2705 | Available on most models, but not in [Scikit-Learn pipelines](https://scikit-learn.org/stable/modules/compose.html). |\n| `predict_proba` | \u274c | Only available on non-regressor models. |\n| `transform` | \u274c | Only available on [Scikit-Learn pipelines](https://scikit-learn.org/stable/modules/compose.html). |\n\nBy default, the runtime will only return the output of `predict`.\nHowever, you are able to control which outputs you want back through the\n`outputs` field of your {class}`InferenceRequest\n<mlserver.types.InferenceRequest>` payload.\n\nFor example, to only return the model's `predict_proba` output, you could\ndefine a payload such as:\n\n```{code-block} json\n---\nemphasize-lines: 10-12\n---\n{\n \"inputs\": [\n {\n \"name\": \"my-input\",\n \"datatype\": \"INT32\",\n \"shape\": [2, 2],\n \"data\": [1, 2, 3, 4]\n }\n ],\n \"outputs\": [\n { \"name\": \"predict_proba\" }\n ]\n}\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Scikit-Learn runtime for MLServer",
"version": "1.6.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "049eebcd75898d53539c449a201dcc1e2f5b638822a14ada09ded06a02d3c324",
"md5": "100ffaf7a3c94d60dd612780c1c98dd8",
"sha256": "f42619f052dba8ec0a5d901d81aca91cf73300f6b71302d8430bce227a6e346d"
},
"downloads": -1,
"filename": "mlserver_sklearn-1.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "100ffaf7a3c94d60dd612780c1c98dd8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.12,>=3.9",
"size": 8013,
"upload_time": "2024-09-10T15:12:08",
"upload_time_iso_8601": "2024-09-10T15:12:08.816001Z",
"url": "https://files.pythonhosted.org/packages/04/9e/ebcd75898d53539c449a201dcc1e2f5b638822a14ada09ded06a02d3c324/mlserver_sklearn-1.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "208464146775ae97d1bb5865b555a43eee2137611d95fa49245b0c7c27602311",
"md5": "0d5781509a6f94ee2871158b7400eb11",
"sha256": "1939a3ca19ce69775c3ab4a8093010ee612763b81cda9ecb02de8ce925b154e6"
},
"downloads": -1,
"filename": "mlserver_sklearn-1.6.1.tar.gz",
"has_sig": false,
"md5_digest": "0d5781509a6f94ee2871158b7400eb11",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.12,>=3.9",
"size": 7025,
"upload_time": "2024-09-10T15:12:09",
"upload_time_iso_8601": "2024-09-10T15:12:09.898103Z",
"url": "https://files.pythonhosted.org/packages/20/84/64146775ae97d1bb5865b555a43eee2137611d95fa49245b0c7c27602311/mlserver_sklearn-1.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-10 15:12:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "mlserver-sklearn"
}