Scale the data before learning to normalize the output
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user