import pandas as pd from simpful import * from rules import * from data_filters import * from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score from sklearn.preprocessing import LabelEncoder from sklearn.metrics import classification_report # Ostatnie 5 spotkań #Forma: 0-6 punktow = słaba, średnia 6-10, dobra 10-15 punktow #Bilans bramek ujemny dodatni #Strzały 6- mało pomiędzy średnio 12 - dużo #Posiadanie piłki słabe 30-40, średnie = 40-55, dobre = 56-64 #Podania ponizej 300-400 słabo powyżej 500 dużo if __name__ == "__main__": df = pd.read_csv('df_full_premierleague.csv') result = last5Matches('10/11', 'Stoke City', '2010-10-02', df) #print(result.to_markdown()) #print(result) result = last5Matches('10/11', 'Blackburn Rovers', '2010-10-02', df) #print(result.to_markdown()) #print(result) print(calculatePoints(result,'Blackburn Rovers')) print(calculateGoalDifference(result, 'Blackburn Rovers')) # df = generateTrainingData(df) # df = add_column(df, categorize_passes, "c_away_passes", "away_passes") # df = add_column(df, categorize_passes, "c_home_passes", "home_passes") # df = add_column(df, categorize_possesion, "c_away_possession", "away_possession") # df = add_column(df, categorize_possesion, "c_home_possession", "home_possession") # df = add_column(df, categorize_shots, "c_away_shots", "away_shots") # df = add_column(df, categorize_shots, "c_home_shots", "home_shots") # print(df.columns) df = add_column(df, get_method(df, True, categorize_points, last5Matches), "c_home_form_5m") df = add_column(df, get_method(df, False, categorize_points, last5Matches), "c_away_form_5m") df = add_column(df, get_method(df, True, categorize_diff, last5Matches), "c_home_diff_5m")#categorize_diff df = add_column(df, get_method(df, False, categorize_diff,last5Matches), "c_away_diff_5m") df = add_column(df, get_method(df, True, categorize_aggression, last5Matches), "c_home_aggression_5m")#categorize_diff df = add_column(df, get_method(df, False, categorize_aggression,last5Matches), "c_away_aggression_5m") df = add_column(df, get_method(df, True, categorize_points, seasonMatches), "c_home_form_season") df = add_column(df, get_method(df, False, categorize_points, seasonMatches), "c_away_form_season") df = add_column(df, get_method(df, True, categorize_diff, seasonMatches), "c_home_diff_season")#categorize_diff df = add_column(df, get_method(df, False, categorize_diff,seasonMatches), "c_away_diff_season") df = add_column(df, get_method(df, True, categorize_aggression, seasonMatches), "c_home_aggression_season")#categorize_diff df = add_column(df, get_method(df, False, categorize_aggression,seasonMatches), "c_away_aggression_season") df = generateFuzzyLogicData(df) label_encoder = LabelEncoder() df['season'] = label_encoder.fit_transform(df['season']) df['c_home_result'] = get_result_list(df,True) df['c_away_result'] = get_result_list(df,True) temp = df[['home_team', 'away_team']].stack() temp[:] = temp.factorize()[0] df[['home_team', 'away_team']] = temp.unstack() X = df.drop(['result_full', 'date', 'c_home_result', 'c_away_result'], axis=1) y = df['c_home_result'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) model = RandomForestClassifier(n_estimators=100, random_state=42) model.fit(X_train, y_train) y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred) print(f'Dokładność modelu: {accuracy}') accuracy = accuracy_score(y_test, y_pred) print(f'Dokładność modelu: {accuracy}') print(classification_report(y_test, y_pred)) result = last5Matches('10/11', 'Manchester United', '2010-12-16', df) print(calculatePoints(result,'Manchester United')) print(calculateGoalDifference(result, 'Manchester United')) print(categorize_fuzzy_passes(450,50))