Created
August 8, 2019 16:37
-
-
Save MarwanDebbiche/c771ca0130de3948ac6ea6924ba50e01 to your computer and use it in GitHub Desktop.
Flask Iris Classifier API - Second Part
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
@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