Giter Club home page Giter Club logo

ml-api's Introduction

Deploying your Machine Learning Model

Code and instructions for techniques to quickly and easily deploy your machine learning model.

In this repo, you will find the code and instructions for this article. It is advised to read through the article whilst coding along using the jupyter notebooks in the notebooks folder.

This repo and the corresponding article describe several methods for creating a production-ready API:

  • FastAPI + Uvicorn
  • OpenAPI (Swagger) + ReDoc
  • Docker
  • Heroku

ml-api's People

Contributors

maartengr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ml-api's Issues

Bad request when using curl

First thanks for your great article in Medium!
I have a problem when implementing your code.

I use your test code as test_api.py:

import requests
to_predict_dict = {'satisfaction_level': 0.38,
                   'last_evaluation': 0.53,
                   'number_project': 2,
                   'average_montly_hours': 157,
                   'time_spend_company': 3,
                   'Work_accident': 0,
                   'promotion_last_5years': 0,
                   'sales': 'support',
                   'salary': 'low'}

url = 'http://127.0.0.1:8000/predict'
r = requests.post(url, json=to_predict_dict)
print(r.json())

It return prediction after excuting.

$ python test_api.py
{'prediction': 1}

And the server log seems work well

INFO:     127.0.0.1:49703 - "POST /predict HTTP/1.1" 200 OK

But when I use the Swagger interface, it returns {"detail":"There was an error parsing the body"}ใ€‚

image

Using the curl is the same error.

$ curl -X POST "http://127.0.0.1:8000/predict" -H "accept: application/json" -H "Content-Type: application/json; charset=UTF-8" -d "{'satisfaction_level': 0.38, 'last_evaluation': 0.53, 'number_project': 2, 'average_montly_hours': 157, 'time_spend_company': 3, 'Work_accident': 0, 'promotion_last_5years': 0, 'sales': 'support', 'salary': 'low'}"
{"detail":"There was an error parsing the body"}% 

Where is the problem and how to solve it?
Thanks!

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.