iris_classify / app.py
exalth's picture
init
7109650
raw
history blame contribute delete
609 Bytes
from flask import Flask, request, jsonify
from flask_cors import CORS
import joblib
import numpy as np
app = Flask(__name__)
CORS(app)
# Load model
model = joblib.load("iris_decision_tree_model.pkl")
@app.route('/')
def home():
return "Model is ready!"
@app.route('/predict', methods=['POST'])
def predict():
data = request.get_json()
input_data = np.array(data['input']).reshape(1, -1)
prediction = model.predict(input_data)
classes = ['Setosa', 'Versicolor', 'Virginica']
return jsonify({'prediction': classes[prediction[0]]})
if __name__ == '__main__':
app.run(debug=True)