Last active
May 31, 2019 08:52
-
-
Save mmmaillot/8ef53e669acf82d849a29b932285b0a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import datasets | |
from sklearn.linear_model.logistic import LogisticRegression | |
import bottle | |
from bottle import request | |
iris_ds = datasets.load_iris() | |
# deux premières features pour simplifier | |
X = iris_ds.data[:, :2] | |
y = iris_ds.target | |
lr = LogisticRegression() | |
lr.fit(X, y) | |
app = bottle.Bottle() | |
@app.post('/iris') | |
def classify_iris(): | |
iris = request.json | |
print(iris) | |
predict = int(lr.predict([iris])[0]) | |
print(predict) | |
return {"iris_class": predict} | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', | |
port=8980) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST localhost:8980/iris -H "Content-Type: application/json" -d "[5.9, 3.0]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment