| import joblib | |
| import numpy as np | |
| model = joblib.load("model.joblib") | |
| labels = ["setosa", "versicolor", "virginica"] | |
| def predict(inputs): | |
| features = np.array([[ | |
| inputs["sepal_length"], | |
| inputs["sepal_width"], | |
| inputs["petal_length"], | |
| inputs["petal_width"] | |
| ]]) | |
| probs = model.predict_proba(features)[0] | |
| idx = probs.argmax() | |
| return { | |
| "class": labels[idx], | |
| "confidence": float(probs[idx]) | |
| } | |