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.3.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlflow_xgboost_proba-0.3.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-1022-azure

File hashes

Hashes for mlflow_xgboost_proba-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9f9b8c13ad1fb9ee535de56bb2229bfc3f2adef6ed582b1b78235c64ae9ae2a8
MD5 3c8e38021e04c390abd171e1492b2c1f
BLAKE2b-256 6360823ed719a0362799a16dd99a6c24016ac467fb8b594232566ef81084e227

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlflow_xgboost_proba-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c842d6afb88cc83497ea3e57d088e4a5f77315c428c6585090073ae90f21bd
MD5 8632c559d3676dde57937fb8fc376a2f
BLAKE2b-256 154f101d2fa105216f15afef1c3cfa15c5971752c49c458dab92931236957ec9

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