Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flask Iris Classifier API
from flask import Flask
from flask import request
import joblib
import pandas as pd
import json
with open("iris_classifier.joblib", "rb") as f:
iris_classifier = joblib.load(f)
with open("iris_classifier_features.joblib", "rb") as f:
iris_classifier_features = joblib.load(f)
app = Flask(__name__)
@app.route('/predict-species', methods=['POST'])
def predict_species():
flower = {}
for feature in iris_classifier_features:
flower[feature] = [request.form[feature]]
flower = pd.DataFrame(flower)
species = iris_classifier.predict(flower[iris_classifier_features])
return species[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.