Deepanshu1230 commited on
Commit ·
6781ab1
1
Parent(s): f949434
Add model,pipeline,and requirements
Browse files- model.joblib +3 -0
- pipeline.py +20 -0
- requirements.txt +3 -0
model.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa8d861f56ce8f4a6d2b26ec201dfc436450b8ce791983242ac88658cb7d9a1a
|
| 3 |
+
size 184161
|
pipeline.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
class Pipeline:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
# Load the trained model once when the API starts
|
| 7 |
+
self.model = joblib.load("model.joblib")
|
| 8 |
+
|
| 9 |
+
def __call__(self, inputs):
|
| 10 |
+
"""
|
| 11 |
+
inputs: List[dict] containing feature names and values
|
| 12 |
+
Example:
|
| 13 |
+
[
|
| 14 |
+
{"pH": 7.2, "Hardness": 200, "Chloramines": 8.1, ...}
|
| 15 |
+
]
|
| 16 |
+
"""
|
| 17 |
+
# Convert JSON list into DataFrame
|
| 18 |
+
df = pd.DataFrame(inputs)
|
| 19 |
+
predictions = self.model.predict(df)
|
| 20 |
+
return {"predictions": predictions.tolist()}
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
scikit-learn
|
| 3 |
+
joblib
|