GithubHelp home page GithubHelp logo

ceccode / income-prediction Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 854 KB

Prediction model to determine whether a person makes over 50K a year

License: MIT License

Dockerfile 0.08% Python 0.17% Jupyter Notebook 99.76%

income-prediction's Introduction

Income prediction

Machine Learning Zoomcamp midterm project: https://github.com/alexeygrigorev/mlbookcamp-code/tree/master/course-zoomcamp/07-midterm-project.

Income classification

Prediction task is to determine whether a person makes over 50K a year.

Dataset

Notebook

TLDR; Use the API

Predict if a certain person income is up to 50K using /predict API.

Endpoint:

API:

  • /heartbeat
  • /predict

Predict API

curl --location --request POST 'https://ml-zoomcamp-midterm-project.herokuapp.com/predict' \
--header 'Content-Type: application/json' \
--data-raw '{
    "age": 45,
    "workclass": "private",
    "fnlwgt": 209642,
    "education": "masters",
    "education-num": 14,
    "marital-status": "married-civ-spouse",
    "occupation": "exec-managerial",
    "relationship": "husband",
    "race": "white",
    "sex": "male",
    "capital-gain": 0,
    "capital-loss": 0,
    "hours-per-week": 45,
    "native-country": "italy"
}'

Or download Postman collection: Income Prediction.postman_collection.json

Run locally with docker

Docker

docker build -t income-prediction ./src
docker run -it -p 9696:9696 income-prediction:latest

Predict

curl --location --request POST 'http://localhost:9696/predict' \
--header 'Content-Type: application/json' \
--data-raw '{
    "age": 45,
    "workclass": "private",
    "fnlwgt": 209642,
    "education": "masters",
    "education-num": 14,
    "marital-status": "married-civ-spouse",
    "occupation": "exec-managerial",
    "relationship": "husband",
    "race": "white",
    "sex": "male",
    "capital-gain": 0,
    "capital-loss": 0,
    "hours-per-week": 45,
    "native-country": "italy"
}'

Run locally without docker

Python required. For more see: https://packaging.python.org/tutorials/installing-packages/.

in /src dir:

pip install pipenv
pipenv install
pipenv shell
python predict.py

Install libomp required by xgboot:

MacOS:

brew install libomp

Ubuntu

RUN apt-get update && apt-get install -y libgomp1

Deploy to heroku and Run

Heroku account needed. Install heroku cli.

Docker file

Update docker file:

#ENTRYPOINT ["gunicorn", "--bind=0.0.0.0:9696", "predict:app"] 
ENTRYPOINT ["gunicorn", "predict:app"]

login

heroku login
heroku container:login

create app in heroku

heroku create your-app-name

Push docker image to Heroku

heroku container:push web -a your-app-name

Deploy container on Heroku

heroku container:release web -a your-app-name

Launch app

Test is up: https://your-app-name-xyz.herokuapp.com/heartbeat

Predict

Consume /predict API:

curl --location --request POST 'http://ml-zoomcamp-midterm-project.herokuapp.com/predict' \
--header 'Content-Type: application/json' \
--data-raw '{
    "age": 45,
    "workclass": "private",
    "fnlwgt": 209642,
    "education": "masters",
    "education-num": 14,
    "marital-status": "married-civ-spouse",
    "occupation": "exec-managerial",
    "relationship": "husband",
    "race": "white",
    "sex": "male",
    "capital-gain": 0,
    "capital-loss": 0,
    "hours-per-week": 45,
    "native-country": "italy"
}'

Postman collection

Download postman collection

and import it in your postman account to run it.

LICENSE

LICENSE

income-prediction's People

Contributors

ceccode avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.