Skip to main content

MLup logo


Linters and testing PyPI version Downloads

Introduction

MLup is a library for easy and fast running of ML models in production.

All you need is to deliver the model file to the server (a config is optional) — pymlup turns it into a FastAPI web application with one CLI command. No web app code to write or maintain.

  • Pure Python, no required framework-specific glue code;
  • Uses FastAPI for the web layer;
  • Works with any Python object that exposes a predict-like method, plus native (de)serialization support for scikit-learn, lightgbm, tensorflow, torch and onnx models.

Requirements

Python 3.8+ (3.12, 3.13, 3.14 supported; the tensorflow extra requires Python <3.14 until TensorFlow publishes 3.14 wheels).

Installation

pip install pymlup

With an ML backend extra:

pip install "pymlup[scikit-learn]"  # For scikit-learn
pip install "pymlup[lightgbm]"      # For microsoft lightgbm
pip install "pymlup[tensorflow]"    # For tensorflow
pip install "pymlup[torch]"         # For torch
pip install "pymlup[onnx]"          # For onnx models: torch, tensorflow, sklearn, etc...

Quick start

From a clean environment to a working prediction API in about five minutes, using scikit-learn as the example.

1. Create a virtual environment and install pymlup with the scikit-learn extra:

python3 -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install "pymlup[scikit-learn]"

2. Train and save a tiny model. Save this as train_model.py and run it:

# train_model.py
import pickle
from sklearn.tree import DecisionTreeClassifier

X = [[0, 0], [1, 1], [2, 2], [3, 3]]
y = [0, 0, 1, 1]

model = DecisionTreeClassifier().fit(X, y)

with open("model.pkl", "wb") as f:
    pickle.dump(model, f)
python train_model.py

3. Start the API:

mlup run -m ./model.pkl

4. Check it's alive (in another terminal):

curl http://localhost:8009/health
{"status":200}

5. Call the model:

curl -X POST http://localhost:8009/predict \
  -H "Content-Type: application/json" \
  -d '{"X": [[1, 1], [3, 3]]}'
{"predict_result":[0,1]}

6. Explore the interactive API docs. Open http://localhost:8009/docs in your browser for the Swagger UI, auto-generated from your model's predict signature — you can try /predict right there.

Stop the server with Ctrl+C.

Already have a serialized model (onnx, joblib, lightgbm, torch, tensorflow, ...) instead of training a new one? Point mlup run -m at it directly (install the matching extra from Installation) — see the full documentation for every supported format and config option.

Any Python object, no ML framework required

pymlup doesn't require a serialized model file at all — any Python object with a predict-like method works:

import mlup

class MyAnyModelForExample:
    def predict(self, X):
        return X

up = mlup.UP(ml_model=MyAnyModelForExample())
up.ml.load()
up.run_web_app(daemon=True)

Open http://localhost:8009/docs to try it, or call it from the same script — this needs pip install requests separately, it's not a pymlup dependency:

import requests
response = requests.post('http://localhost:8009/predict', json={'X': [[1, 2, 3], [4, 5, 6]]})
print(response.json())

up.stop_web_app()

Supported ML frameworks

Work tested with machine learning model frameworks (links to tests):

Support and tested with machine learning libraries:

Documentation

The full documentation — Python API, CLI reference, config file format, storages, binarizers, data transformers, web app architectures/API, application life cycle — lives at mlup.org (source: docs/).

Useful links

Metrics

MLup PyPi download statistics: https://pepy.tech/project/pymlup

Downloads Downloads Downloads

Download files

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

Source Distribution

pymlup-0.3.1.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymlup-0.3.1-py3-none-any.whl (60.9 kB view details)

Uploaded Python 3

File details

Details for the file pymlup-0.3.1.tar.gz.

File metadata

  • Download URL: pymlup-0.3.1.tar.gz
  • Upload date:
  • Size: 44.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for pymlup-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d802c63ea7e87468e0dea99f8a9d03d80bd59a1c239c486e6eeca77fcc9287aa
MD5 1cee05e2d86c5cc791eeaab4d6722bca
BLAKE2b-256 34645692a55e3ca33083d1ac59f65310679f30e83dfcbd9ec266ad1cf879a09f

See more details on using hashes here.

File details

Details for the file pymlup-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pymlup-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 60.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for pymlup-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 551f85f2b4cc8541c7502986440f8adf1e9c63391e0a7b512ff6b4d7a9b7957e
MD5 9399e839695dab798a804f722f1b4598
BLAKE2b-256 4d1c22ee675441d4893efde677fa58f69015aafa4b4bd176d212443df3157a15

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page