Upload model.py with huggingface_hub
Browse files
model.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
model = joblib.load("model.pkl")
|
| 6 |
+
|
| 7 |
+
def predict(input_data):
|
| 8 |
+
features = [
|
| 9 |
+
input_data["Pregnancies"],
|
| 10 |
+
input_data["Glucose"],
|
| 11 |
+
input_data["BloodPressure"],
|
| 12 |
+
input_data["SkinThickness"],
|
| 13 |
+
input_data["Insulin"],
|
| 14 |
+
input_data["BMI"],
|
| 15 |
+
input_data["DiabetesPedigreeFunction"],
|
| 16 |
+
input_data["Age"]
|
| 17 |
+
]
|
| 18 |
+
X = np.array(features).reshape(1, -1)
|
| 19 |
+
prediction = model.predict(X)[0]
|
| 20 |
+
return {"prediction": int(prediction)}
|