def select_seasons(current_english_season, seasons): """ Takes the current english season, and a list of seasons available. Returns a list of seasons selected. """ print("\nSeason select") options = [ "Load current season", "Load all seasons", "Load selected seasons", "Exit" ] selection = c.general_menu(options) if selection == "Load current season": return [c.get_season_key(current_english_season)] elif selection == "Load all seasons": return list(seasons.keys()) elif selection == "Load selected seasons": selected_seasons = c.multi_pick(list(seasons.keys())) """seasons_to_return = [] for sel in selected_seasons: seasons_to_return.append(seasons[sel]) return seasons_to_return""" return selected_seasons elif selection == "Exit": return "exit"
def generate_predictions(prediction_type, prediction_method): c.predictions_df = predictive_methods[prediction_type][prediction_method]( c.fixtures) if type(c.predictions_df) == str: print("\nNo games were found that met the search requirements") else: c.predictions_df["Date"] = pd.to_datetime(c.predictions_df["Date"], dayfirst=True) date_range = (c.predictions_df["Date"].min().strftime("%d-%m-%Y") + " - " + c.predictions_df["Date"].max().strftime("%d-%m-%Y")) predictions_file = (prediction_type + " - " + prediction_method + " - predictions - " + date_range + ".csv") if ((not os.path.exists(c.unprocessed_predictions_dir + predictions_file)) and (not os.path.exists(c.old_preprocessed_predictions_dir + predictions_file))): print("Would you like to export this to a csv file?") ans = c.general_menu(["Yes", "No"]) if ans == "Yes": c.predictions_df.to_csv(c.unprocessed_predictions_dir + predictions_file) print("done") else: print("These predictions have already been saved.") print( "They are in either the unprocessed_predictions or the preprocessed_predictions folder.\n" )
def display_results(): print("\n Display Results") selection = c.general_menu([ "Last 1 game", "Last x games", "All results for current season", "All resulst for defined seasons", "Back" ]) if selection == "Last 1 game": results_last_1_game() elif selection == "Last x games": results_last_x_games() elif selection == "All results for current season": results_season() elif selection == "All results for defined seasons": results_defined_seasons() elif selection == "Back": return
def generate_predictions(): print("\nGenerate Predictions") print("\nSelect a prediction type.") prediction_type = c.general_menu(list(pf.predictive_methods.keys())) print("\nSelect a predictive method.") prediction_methods = c.multi_pick( list(pf.predictive_methods[prediction_type].keys()), []) for prediction_method in prediction_methods: #TESTING DEBUG print("\nGenerating predictions for type: ", prediction_type, "method: ", prediction_method) #END OF TESTING DEBUG #Take the selected type and method and pass it to a function to run the #method and create a scv file. pf.generate_predictions(prediction_type, prediction_method)
def display_fixtures(): print("\nDisplay Fixtures") selection = c.general_menu([ "Display all upcoming fixtures", "Display fixtures for specific teams", "Back" ]) if selection == "Display all upcoming fixtures": print("\nDisplay all upcoming fixtures") c.display_fixtures() elif selection == "Display fixtures for specific teams": print("\nDisplay fixtures for specific teams") print("\nSelect teams") teams = c.multi_pick(c.fixture_team_list) c.display_fixtures(teams=teams) return elif selection == "Back": return
def main_menu(): while True: print("\nMain Menu") selection = c.general_menu([ "Display results", "Display fixtures", "Generate next game predictions", "Display predictions", "Prediction analysis options", "Back" ]) if selection == "Display results": display_results() elif selection == "Display fixtures": display_fixtures() elif selection == "Generate next game predictions": generate_predictions() elif selection == "Display predictions": display_predictions() elif selection == "Prediction analysis options": analysis() elif selection == "Back": return
def analysis(): print("\nPrediction Analysis Options") selection = c.general_menu([ "Process prediction files", "Test a predictive function", "Review tested predictive methods" ]) if selection == "Process prediction files": files = [] for a, b, filename in os.walk(c.unprocessed_predictions_dir): files.append(filename) if len(files) < 1: print("There are no unprocessed prediction files") else: print("\nSelect files to process") selected_files = c.multi_pick(files[0], []) #files[0] is the list of files pa.process_prediction_files(selected_files) elif selection == "Test a predictive function": print("\nSelect a prediction type:") prediction_type = c.general_menu(list(pf.predictive_methods.keys())) print("\nSelect predictive methods:") prediction_methods = c.multi_pick( list(pf.predictive_methods[prediction_type].keys()), []) predictive_functions = [] for prediction_method in prediction_methods: predictive_functions.append( pf.predictive_methods[prediction_type][prediction_method]) print("\nSelect leagues:") #Empty lists below for no selected items to prevent a bug where an item #from a previous list is somehow added to the selected items. leagues = c.multi_pick(list(c.leagues.keys()), []) print("\nSelect seasons") #Only allow the selection of seasons where all leagues are available available_seasons = [] for season in list(c.loaded_seasons.keys()): if season in c.seasons_with_all_leagues: available_seasons.append(season) seasons = c.multi_pick(available_seasons, []) #Get list of league codes rather than names league_codes = [] for l in leagues: league_codes.append(c.leagues[l]) #Get list of season codes rather than names season_codes = [] for s in seasons: season_codes.append(c.loaded_seasons[s]) for predictive_function in predictive_functions: pa.win_draw_test_method(predictive_function, leagues=league_codes, seasons=season_codes) elif selection == "Review tested predictive methods": pass