GithubHelp home page GithubHelp logo

sales_prediction_api's Introduction

Deploy a ML model using Flask

Based on: https://github.com/abhinavsagar/machine-learning-deployment

The app deploys a simple machine learning model to predict sales in the third month based on the sales in the first two months.

Run the app and make a query

With Docker

Run

$ docker run -dp 8080:8080 staeff/salespredictionapi

open http://localhost:8080/ in a browser or make a curl request:

$ curl -X POST -H "Content-Type: application/json" -d '{"rate":5, "sales_in_first_month":200,"sales_in_second_month":400}' http://localhost:8080/results

Without Docker

$ python3 -m venv .venv; source ./.venv/bin/activate
(.venv) $ pip install -r requirements.txt
(.venv) $ python app.py
# in another terminal window
(.venv) $ python request.py
523.8530977224776

When the flask process is running you can also open http://127.0.0.1:5000/ and enter data into the website.

or use curl:

$ curl -X POST -H "Content-Type: application/json" -d '{"rate":5, "sales_in_first_month":200,"sales_in_second_month":400}' http://localhost:5000/results

Repo contents

  • app.py — a Flask app that receives inputs through website or API call, computes the predicted value based on our model and returns it.

  • HTML/CSS — frontend code for the flask app

  • request.py — makes an example API call

  • model.py — computes a linear regression model to predict sales in the third month based on the sales in the first two months. No need to run this. The model is already stored in the repo.

sales_prediction_api's People

Contributors

staeff avatar

Watchers

 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.