Spaces:
Sleeping
Sleeping
File size: 609 Bytes
7109650 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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)
|