Upload inference.py with huggingface_hub
Browse files- inference.py +21 -0
inference.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Load the ARIMA model
|
| 5 |
+
with open("arima_model.pkl", "rb") as f:
|
| 6 |
+
model = pickle.load(f)
|
| 7 |
+
|
| 8 |
+
def predict_stock(input_data):
|
| 9 |
+
"""
|
| 10 |
+
input_data: dictionary with structure like {"feature": value}
|
| 11 |
+
For ARIMA, usually you just forecast next n steps.
|
| 12 |
+
"""
|
| 13 |
+
# Example: forecasting next n steps
|
| 14 |
+
n_steps = input_data.get("steps", 5)
|
| 15 |
+
forecast = model.forecast(steps=n_steps)
|
| 16 |
+
return forecast.tolist()
|
| 17 |
+
|
| 18 |
+
# Example usage
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
data = {"steps": 10}
|
| 21 |
+
print(predict_stock(data))
|