GithubHelp home page GithubHelp logo

rest-api-ml-model's Introduction

REST-API-ML-Model

Deploy simple machine learning model as Rest API in Python. The case the we used is Sentiment Analysis on Movie Reviews in Kaggle competition to predict whether sentimen of a comment in Rotten Tomatoes review is good or not. Dataset can be found here.

Use

We can test the API using request function in Jupyter Notebook.

url = 'http://127.0.0.1:5000/'
params ={'query': 'that movie was boring'}
response = requests.get(url, params)
response.json()
Output: {'confidence': 0.128, 'prediction': 'Negative'}

Or using HTTPie in terminal.

$ http http://127.0.0.1:5000/ query=='that movie was boring'
HTTP/1.0 200 OK
Content-Length: 58
Content-Type: application/json
Date: Fri, 31 Aug 2018 18:49:25 GMT
Server: Werkzeug/0.14.1 Python/3.6.3
{
    "confidence": 0.128,
    "prediction": "Negative"
}

File Structure

User use this file structure for API.

.
├── README.md
	├── app.py  # Flask REST API script
	├── build_model.py  # script to build and pickle the classifier
	├── model.py  # script for the classifier class object
	├── util.py  # helper functions
	├── requirements.txt
	└── lib/
		├── data/  # data from Kaggle
		│   ├── sampleSubmission.csv
		│   ├── test.tsv
		│   └── train.tsv
		└── models/  # pickled models for import into API script
    		├── SentimentClassifier.pkl
    		└── TFIDFVectorizer.pkl

rest-api-ml-model's People

Contributors

christofel04 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.