Update inference.py
Browse files- inference.py +15 -15
inference.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
import pickle
|
| 4 |
-
from datetime import datetime
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
self.min_date = pd.to_datetime("2024-01-01") # Reference date
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import pandas as pd
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
def load_model():
|
| 5 |
+
with open("model/expense_forecaster_model.pkl", "rb") as f:
|
| 6 |
+
model = pickle.load(f)
|
| 7 |
+
return model
|
|
|
|
| 8 |
|
| 9 |
+
def predict(data):
|
| 10 |
+
model = load_model()
|
| 11 |
+
df = pd.DataFrame([data])
|
| 12 |
+
prediction = model.predict(df)
|
| 13 |
+
return prediction.tolist()
|
| 14 |
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
example_input = {"income": 5000, "previous_expenses": 3000, "month": 12} #example data, change this to match your feature names.
|
| 17 |
+
prediction = predict(example_input)
|
| 18 |
+
print(f"Prediction: {prediction}")
|