Spaces:
Runtime error
Runtime error
Create src/model.py
Browse files- src/model.py +15 -0
src/model.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sklearn.ensemble import RandomForestClassifier
|
| 2 |
+
|
| 3 |
+
model = RandomForestClassifier()
|
| 4 |
+
|
| 5 |
+
def train_model(df):
|
| 6 |
+
"""Train the AI model."""
|
| 7 |
+
df["target"] = (df["close"].pct_change() > 0.05).astype(int) # Label: 1 if price increased by >5%
|
| 8 |
+
features = df[["close", "volume"]].dropna()
|
| 9 |
+
target = df["target"].dropna()
|
| 10 |
+
model.fit(features[:-1], target)
|
| 11 |
+
|
| 12 |
+
def predict_growth(latest_data):
|
| 13 |
+
"""Predict explosive growth."""
|
| 14 |
+
return model.predict([latest_data])
|
| 15 |
+
|