Make each AI task seperate for faster testing

This commit is contained in:
2026-02-26 21:39:41 -08:00
parent 79ee297e61
commit 7567496e1c
3 changed files with 13 additions and 32 deletions
+6 -22
View File
@@ -1,20 +1,13 @@
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
from keras import Sequential, layers, optimizers, losses
from keras import Sequential, layers, optimizers
from keras.callbacks import ReduceLROnPlateau
def TrainAI(include_pull):
if (include_pull):
# Pull New Data
datapuller.pull()
def TrainAI():
# Get the CWD for pathing due to being called from C#
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -23,6 +16,9 @@ def TrainAI(include_pull):
# Load the dataset
dataset = pd.read_parquet(os.path.join(DATA_DIR, "stocks.parquet"))
# Use external featuers to make sure loaded is the same
dataset = features.MakeFeatures(dataset)
# Create the X, Y vareables
X, Y, X_Scaler, Y_Scaler = features.Prepare(dataset)
@@ -75,18 +71,6 @@ def TrainAI(include_pull):
callbacks=[reduce_lr] # Reduce the learning_rate every run
)
# Predict
test_predictions = dnn_model.predict(test_features).flatten()
a = plt.axes(aspect='equal')
plt.scatter(test_labels, test_predictions)
plt.xlabel('True Values')
plt.ylabel('Predictions')
lims = [0, 50]
plt.xlim(lims)
plt.ylim(lims)
_ = plt.plot(lims, lims)
# Current Test Results: 0.3382711112499237
test_results = dnn_model.evaluate(
test_features, test_labels, verbose=0
@@ -97,6 +81,6 @@ def TrainAI(include_pull):
dnn_model.save(os.path.join(DATA_DIR, "model.keras"))
if __name__ == "__main__":
TrainAI(True)
TrainAI()
# Last train Predicted Target_Close: [0.0022113274317234755, 0.0021446370519697666, 0.0022628342267125845, 0.002175702480599284, 0.0021452796645462513, 0.0020838389173150063, 0.0017336219316348433, 0.002210840117186308, 0.0021144403144717216, 0.0021278387866914272, 0.0021266420371830463, 0.002261851681396365, 0.002108299173414707, 0.002121902070939541, 0.0022294146474450827]