Skip to main content

Send a POST request to infer your ML model with FastAPI

Project description

Introduction

You may train the most awesome model in the world but if you can't deploy it then people can enjoy your work. Deoployment in ML has always been an issue that we never gets discussed in courses. It is assumed that you can just do this without any training. However, in my experience, I found it not as easy to deploy my models with much flexibility. That's why I decided to create serve-it-learn. The idea for the name purely from Vincent D. Warmerdam's brain fart.

Installation

I prefer conda but you do you. You need at least python 3.7

  1. Create environment (if you don't already have one) conda create -n serve_scikit_model python=3.7

  2. Activate it conda activate serve_scikit_model

  3. Install it pip install serveitlearn

Getting started

This is a dummy example. You need to add your own code to load the model and perform predictions.

from serveitlearn.decorator import app, predict, initalize

# Declare function that initalizes the model and any other data sources
@initalize
def my_initalization():
    pass

# Declare function that will make the prediction based on the query

@predict
def my_prediction(query_dict):
    pass

Full example

If you want to see a full example, then you have to take few more after installation because it requires loading scikit-learn model and I didn't release a pickle or joblib due to potiential security reasons.

The example, loads Iris dataset, trains a simple SVC model and deploys it using `serveitlearn.

$ git clone https://github.com/samarpan-rai/serveitlearn

$ cd serveitlearn/examples/

$ pip install -r requirements.txt

$ uviron

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

serveitlearn-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

serveitlearn-0.1.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file serveitlearn-0.1.1.tar.gz.

File metadata

  • Download URL: serveitlearn-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4

File hashes

Hashes for serveitlearn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5473dc1ed9f28b0f15ed49111a1fe5b53e7613ca88b51b87b97fc95d5246435
MD5 cf110902f1f5ee0f49e1ce9814dbfe72
BLAKE2b-256 82eeb5ad1b82d82037e59a435f4b084230b7e4a002657f62a67af1b303650ca1

See more details on using hashes here.

File details

Details for the file serveitlearn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: serveitlearn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4

File hashes

Hashes for serveitlearn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c7b58b3e8b36f3c5c8240652a3cd70c58e54344a124f67c7340dd7b24e0c6f9
MD5 33aed12f82aa031ad216db5dbf778421
BLAKE2b-256 3b97a369ebb9fb81d2bad8dbcf10fb5c785c517f8a4fcc297655fa5c8d3afeb0

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