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) query = "SELECT game_date, game_number, park_id FROM games ORDER BY game_date" all_games = db_conn.selectall(query) for game in all_games: game_result, training_data = pull_training_data(db_conn, str(game[0]), game[1], game[2]) """ 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/", "./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') """