Download handler.py from Vamshiboss8055/iris-classifier1: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/Vamshiboss8055/iris-classifier1/resolve/main/handler.py
- Command line
-
hf download hf://Vamshiboss8055/iris-classifier1/handler.py
-
curl -L -o handler.py https://huggingface.co/Vamshiboss8055/iris-classifier1/resolve/main/handler.py
481 Bytes
| 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]) | |
| } | |