Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.