An open API service indexing awesome lists of open source software.

https://github.com/thomd/spam-detection-with-fastapi-on-azure

Train a spam-detection model with SciKit-Learn and deploy as FastAPI app on Azure Container Instance
https://github.com/thomd/spam-detection-with-fastapi-on-azure

azure docker machine-learning python

Last synced: 26 days ago
JSON representation

Train a spam-detection model with SciKit-Learn and deploy as FastAPI app on Azure Container Instance

Awesome Lists containing this project

README

          

# Spam Detection with SciKit-Learn, FastAPI on Azure Container Instance

## Dataset

The UCI [SMS Spam Collection](https://data.world/uci/sms-spam-collection) is a public
set of SMS labeled messages that have been collected for mobile phone spam research.

## Setup

Create environment:

conda create --name spam
conda activate spam
conda install --yes --file requirements.txt

Train spam classifier model:

python train.py

For local testing, start server and open SwaggerUI

uvicorn app:app --reload
open http://localhost:8000/docs

Test local endpoint:

curl http://localhost:8000/predict?message=I want your Money

## Build Docker Image

Build docker image and run docker container:

docker build -t spam .
docker run -d --rm --name spam -p 80:80 spam

## Deploy as Azure Container Instance

Use Azure Container Instances (ACI) to run serverless Docker containers in Azure.

Create Azure Container Registry (ACR):

az login
az group create -n -l
az acr create -g -n --sku Basic --admin-enabled true
az acr list -g -o table

Upload docker image to ACR

docker tag spam .azurecr.io/spam:v1
az acr login -n
docker push .azurecr.io/spam:v1

Create container (find username and password here: Portal > Container Registry > Access Keys)

az container create -g -n --image .azurecr.io/spam:v1 --dns-name-label --ports 80
az container show -g -n --query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}"
az container logs -g -n

Open SwaggerUI

open http://..azurecontainer.io

Delete resource group

az group delete -n