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