Vamshiboss8055 commited on
Commit
6664106
·
verified ·
1 Parent(s): f802f83

Initial Iris inference API

Browse files
Files changed (3) hide show
  1. handler.py +21 -0
  2. model.joblib +3 -0
  3. requirements.txt +3 -0
handler.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ import numpy as np
3
+
4
+ model = joblib.load("model.joblib")
5
+ labels = ["setosa", "versicolor", "virginica"]
6
+
7
+ def predict(inputs):
8
+ features = np.array([[
9
+ inputs["sepal_length"],
10
+ inputs["sepal_width"],
11
+ inputs["petal_length"],
12
+ inputs["petal_width"]
13
+ ]])
14
+
15
+ probs = model.predict_proba(features)[0]
16
+ idx = probs.argmax()
17
+
18
+ return {
19
+ "class": labels[idx],
20
+ "confidence": float(probs[idx])
21
+ }
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0cdf06e4de7d0c545424af5b7df04989dcf05f4bcc2e295ef444193d82aee315
3
+ size 186737
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ scikit-learn
2
+ joblib
3
+ numpy