cloud450 commited on
Commit
ba5a6f4
·
verified ·
1 Parent(s): 541ac41

Upload 7 files

Browse files
Dockefile.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY . .
9
+
10
+ EXPOSE 7860
11
+
12
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
acceleration.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4ed75c52585a15c752132a593588f3d5fb4f180c1d25a7c64ef892bd0d92ab0
3
+ size 953
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import joblib
3
+ import pandas as pd
4
+
5
+ app = FastAPI()
6
+
7
+ # Load models once at startup
8
+ future_spend_model = joblib.load("future_spend_7d.pkl")
9
+ spike_model = joblib.load("spike_probability.pkl")
10
+ acc_model = joblib.load("acceleration.pkl")
11
+ FEATURES = joblib.load("model_features.pkl")
12
+
13
+ @app.get("/")
14
+ def root():
15
+ return {"status": "ML backend running"}
16
+
17
+ @app.post("/predict")
18
+ def predict(payload: dict):
19
+ X = pd.DataFrame([payload], columns=FEATURES)
20
+
21
+ future_spend = future_spend_model.predict(X)[0]
22
+ spike_prob = spike_model.predict_proba(X)[0][1]
23
+ acceleration = acc_model.predict(X)[0]
24
+
25
+ return {
26
+ "future_7d_spend": round(float(future_spend), 2),
27
+ "spike_probability": round(float(spike_prob), 3),
28
+ "acceleration": round(float(acceleration), 2)
29
+ }
future_spend_7d.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31b0529daec826eafe8adfdd15bd61ea237b8e6747f8718356964e2c3231d607
3
+ size 318177
model_features.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ed6118cb1dd9cc034817aca085764f0cf2d9aa49182b2bae5207f78bfaf86e7
3
+ size 112
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ pandas
4
+ numpy
5
+ scikit-learn
6
+ joblib
spike_probability.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef336462e09127807cc10265ccefb29548a85d584306aa0a9bbdc810973f7fa3
3
+ size 1263