Files
baseball-nn/main.py

61 lines
1.9 KiB
Python

import numpy as np # helps with the math
import matplotlib.pyplot as plt # to plot error during training
from data.get_data import pull_training_data
from data.db_connect import Database
from data.build_weather import get_weather, get_sun_and_moon_phase
from data.stats_importer import Importer
# input data
inputs = np.array([[0, 0, 1, 0],
[0, 0, 1, 1],
[0, 0, 0, 0],
[1, 1, 0, 0],
[1, 1, 1, 1],
[1, 1, 0, 1]])
# output data
outputs = np.array([[0], [0], [0], [1], [1], [1]])
if __name__ == '__main__':
#db_file = "./database/baseball.db"
#db_conn = Database(db_file)
#pull_training_data(db_conn, "20240602", 0, "BAL12")
print(get_sun_and_moon_phase(39.283889, -76.621667, "20240602"))
"""
build_db_path = "./data/sql/build_db.sql"
fill_parks_path = "./data/sql/prefill_parks.sql"
fill_teams_path = "./data/sql/prefill_teams.sql"
db_conn.run_sql_file(build_db_path)
db_conn.run_sql_file(fill_parks_path)
db_conn.run_sql_file(fill_teams_path)
imp = Importer(db_conn)
imp.parse_all_data("./data/stats/to_import", "./data/stats/imported/")
"""
"""
else:
# create neural network
NN = NeuralNetwork(inputs, outputs)
# train neural network
NN.train()
# create two new examples to predict
example = np.array([[1, 1, 1, 0]])
example_2 = np.array([[0, 0, 1, 1]])
# print the predictions for both examples
print(NN.predict(example), ' - Correct: ', example[0][0])
print(NN.predict(example_2), ' - Correct: ', example_2[0][0])
# plot the error over the entire training duration
plt.figure(figsize=(15,5))
plt.plot(NN.epoch_list, NN.error_history)
plt.xlabel('Epoch')
plt.ylabel('Error')
plt.savefig('plot.png')
"""