Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarwanDebbiche/c771ca0130de3948ac6ea6924ba50e01 to your computer and use it in GitHub Desktop.
Save MarwanDebbiche/c771ca0130de3948ac6ea6924ba50e01 to your computer and use it in GitHub Desktop.
Flask Iris Classifier API - Second Part
@app.route('/predict-species-proba', methods=['POST'])
def predict_species_proba():
flower = {}
for feature in iris_classifier_features:
flower[feature] = [request.form[feature]]
flower = pd.DataFrame(flower)
probas = iris_classifier.predict_proba(flower[iris_classifier_features])[0, :].tolist()
species_proba = {}
for idx, species in enumerate(['setosa', 'versicolor', 'virginica']):
species_proba[species] = probas[idx]
return json.dumps(species_proba)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment