-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_pipeline.py
More file actions
29 lines (20 loc) · 845 Bytes
/
Copy pathrun_pipeline.py
File metadata and controls
29 lines (20 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
from sklearn.model_selection import train_test_split
from pipeline.feature_engineering import build_features
from pipeline.train_rf_model import train_random_forest
from pipeline.evaluate import feature_importance, plot_predictions
def run(asset="BTC"):
path = f"data/processed/{asset.lower()}_sentiment_aligned.csv"
df = pd.read_csv(path, parse_dates=["date"])
X, y, features = build_features(df)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, shuffle=False
)
model, rmse, mae = train_random_forest(
X_train, X_test, y_train, y_test, asset=asset
)
feature_importance(model, features)
plot_predictions(y_test, model.predict(X_test), asset=asset, n = 100)
if __name__ == "__main__":
run("BTC")
# run("NIFTY") # enable once ready-