Skip to main content

MLflow XGBoost flavour with probabilities

Project description

mlflow-xgboost-proba

Release Build status codecov Commit activity License

MLflow XGBoost flavour with probabilities

This package implements mlflow_xgboost_proba MLflow flavour, which allows to run predict_proba method of xgboost models during inference with MLflow mlflow models serve CLI command.

Implementation is based on mlflow.xgboost module, which is copied and modified to have the wrapper with predict_proba method and predict method calling predict_proba by default.

The API of the module is identical to mlflow.xgboost, only without support of autologging.

Usage

Install package with pip install mlflow-xgboost-proba.

Prepare XGBoost model and save as MLflow model:

from xgboost import XGBClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

import mlflow_xgboost_proba

# Prepare training dataset
data = load_iris()
X_train, X_test, y_train, y_test = train_test_split(data["data"], data["target"], test_size=0.2)
# Prepare XGBoost model
xgb_model = XGBClassifier(n_estimators=2, max_depth=2, learning_rate=1, objective="binary:logistic")
xgb_model.fit(X_train, y_train)
# Save XGBoost model as MLflow model
mlflow_xgboost_proba.save_model(xgb_model, "mlflow_xgb_iris_classifier")

Run model inference with the probabilities using MLflow:

mlflow models serve --model-uri mlflow_xgb_iris_classifier --env-manager local

Repository initiated with fpgmaas/cookiecutter-poetry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlflow_xgboost_proba-0.2.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

mlflow_xgboost_proba-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file mlflow_xgboost_proba-0.2.0.tar.gz.

File metadata

  • Download URL: mlflow_xgboost_proba-0.2.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1021-azure

File hashes

Hashes for mlflow_xgboost_proba-0.2.0.tar.gz
Algorithm Hash digest
SHA256 477ccc5f0315dc4114b5c418f10c412af1686738d9014d0ec71217d9fcc48a5c
MD5 a24705547cd2b9a7210e27fb7444ddff
BLAKE2b-256 6e4d70fe6405178f7a000de23e78687ef9f91abae2fd0acf3f6997773345c42f

See more details on using hashes here.

File details

Details for the file mlflow_xgboost_proba-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mlflow_xgboost_proba-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fa78428834208a8b7e116f0acb8528e2572663e613c455f59ebbae5b88c9369
MD5 aa511142501484c57fe5c317f47eede4
BLAKE2b-256 8ae76bd6456c54f91a97bcb3d32c82ddcc902899f4a361d5d56ea04c03c7c47f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page