Scale the data before learning to normalize the output

This commit is contained in:
2026-02-18 18:33:21 -08:00
parent a81e3a992d
commit 7a4fc2cda4
7 changed files with 240 additions and 212 deletions
+7 -6
View File
@@ -2,6 +2,8 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datapuller
import features
import joblib
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from sklearn.model_selection import train_test_split
@@ -20,13 +22,12 @@ def TrainAI(include_pull):
# Load the dataset
dataset = pd.read_parquet(os.path.join(DATA_DIR, "stocks.parquet"))
# Replace Infinity with 0 -> This fixes the AI mental breakdown
dataset['Volume_Chg'] = dataset['Volume_Chg'].replace([np.inf, -np.inf], 0)
# Create the X, Y vareables
X, Y, X_Scaler, Y_Scaler = features.Prepare(dataset)
# Remove indicators and set the target
X = dataset.drop('Target_Close', axis=1)
X = dataset.drop('Target_Direction', axis=1)
Y = dataset['Target_Close']
# Save the scalers for future use
joblib.dump(X_Scaler, os.path.join(DATA_DIR, "feature_scaler.pkl"))
joblib.dump(Y_Scaler, os.path.join(DATA_DIR, "target_scaler.pkl"))
# Show the datatypes
print(dataset.dtypes)