Example: custom Python model
Exposes a plain Python object as a REST API - no ML framework and no serialized model file,
only a predict-like method.
Source: examples/custom-python-model/
Requirements
- Python 3.8+
pymlup(no extra needed)
Run
git clone https://github.com/nxexox/pymlup.git
cd pymlup/examples/custom-python-model
pip install -r requirements.txt
python run.py
model.py
defines MyModel, a plain Python class with a predict(self, X) method.
run.py passes
an instance of it straight to mlup.UP(ml_model=...) - no file, no pickling.
Test API
curl -X POST http://localhost:8009/predict \
-H "Content-Type: application/json" \
-d '{"X": [[1, 2], [3, 4]]}'
Expected result
{"predict_result": [3, 7]}
See the full README for this example on GitHub.