From 8cbb72de73a81172992e244c154509edfa0955a4 Mon Sep 17 00:00:00 2001 From: Piotr Kopycki Date: Mon, 27 Dec 2021 16:01:23 +0100 Subject: [PATCH] Logic update --- leagues-backup.csv | 55 ++++++++ leagues.csv | 110 ++++++++-------- main.py | 312 +++++++++++++++++++++++++-------------------- res.csv | 54 ++++++++ res2.csv | 54 ++++++++ 5 files changed, 391 insertions(+), 194 deletions(-) create mode 100644 leagues-backup.csv create mode 100644 res.csv create mode 100644 res2.csv diff --git a/leagues-backup.csv b/leagues-backup.csv new file mode 100644 index 0000000..f463abb --- /dev/null +++ b/leagues-backup.csv @@ -0,0 +1,55 @@ +leagueName;country;clubs;goalsPerMatch;avgMarketValueInMln;totalMarketValueInMln;teamsInChampionsLeague;teamsInEuropaLeague;teamsInConferenceLeague;famousPlayers +Premier League;England;20;2.78;453.95;9080.0;4;2;1;35 +LaLiga;Spain;20;2.45;246.89;4940.0;4;2;1;21 +Serie A;Italy;20;3.05;245.69;4910.0;4;2;1;17 +Bundesliga;Germany;18;3.04;233.67;4210.0;4;2;1;15 +Ligue 1;France;20;2.83;185.93;3720.0;3;2;1;10 +Liga Bwin;Portugal;18;2.66;64.83;1170.0;3;1;2;0 +Eredivisie;Netherlands;18;2.97;51.78;932.08;2;1;2;0 +Bundesliga;Austria;12;2.95;27.67;332.0;2;1;2;1 +Premiership;Scotland;12;2.52;22.98;275.78;2;1;2;0 +Premier Liga;Russia;16;2.69;60.99;975.8;2;1;2;0 +Premier Liga;Ukraine;16;2.67;28.07;449.18;2;1;2;0 +Super liga Srbije;Serbia;16;2.74;11.60;185.58;1;0;3;0 +Jupiler Pro League;Belgium;18;3.08;46.38;834.9;2;1;2;0 +Super League;Switzerland;10;3.30;28.59;285.93;1;0;3;0 +Protathlima Cyta;Cyprus;12;2.23;11.00;131.95;1;1;2;0 +1.HNL;Croatia;10;2.95;25.51;255.11;1;0;3;0 +Fortuna Liga;Czech Republic;16;3.08;15.60;249.63;2;1;2;0 +Super Lig;Turkey;20;2.63;46.27;925.45;2;1;2;0 +Super League 1;Greece;14;2.60;25.19;352.68;1;0;3;0 +Superligaen;Denmark;12;2.74;20.14;241.68;2;1;2;0 +Eliteserien;Norway;16;3.04;8.46;135.43;1;0;3;0 +Ligat ha'Al;Israel;14;2.38;8.88;124.38;1;0;3;0 +Allsvenskan;Sweden;16;2.63;11.33;181.29;1;0;3;0 +efbet Liga;Bulgaria;14;2.41;8.50;118.94;1;0;3;0 +Premyer Liqa;Azerbaijan;8;2.69;6.36;50.91;1;0;3;0 +Liga 1;Romania;16;2.12;12.31;196.89;1;0;3;0 +Ekstraklasa;Poland;18;2.76;14.16;254.90;1;0;3;0 +NB I.;Hungary;12;3.19;11.11;133.38;1;0;3;0 +Fortuna Liga;Slovakia;12;2.74;6.75;81.04;1;0;3;0 +Premier Liga;Kazakhstan;14;2.57;7.92;110.85;1;0;3;0 +Prva Liga;Slovenia;10;2.45;5.41;54.12;1;0;3;0 +Vysheyshaya Liga;Belarus;16;2.71;4.92;78.73;1;0;3;0 +Divizia Nationala;Moldova;8;3.26;4.96;39.67;1;0;3;0 +A Lyga;Lithuania;10;2.74;2.69;26.88;1;0;3;0 +Premijer Liga;Bosnia-Herzegovina;12;2.27;3.78;45.41;1;0;3;0 +Veikkausliiga;Finland;12;2.35;3.25;38.99;1;0;3;0 +BGL Ligue;Luxembourg;16;3.38;1.69;27.06;1;0;3;0 +Virsliga;Latvia;9;3.02;3.09;27.80;1;0;3;0 +BKT Superliga e Kosovës;Kosovo;10;2.11;2.34;22.43;1;0;2;0 +Premier Division;Republic of Ireland;10;2.54;1.35;13.46;1;0;3;0 +Premiership;Northern Ireland;12;2.85;1.96;23.50;1;0;3;0 +Kategoria Superiore;Albania;10;2.52;4.15;41.50;1;0;3;0 +Bardzragujn khumb;Armenia;10;2.45;4.08;40.79;1;0;3;0 +Betri-deildin;Faroe Islands;10;3.63;1.13;11.29;1;0;2;0 +Premium Liiga;Estonia;10;3.29;2.48;24.81;1;0;2;0 +Premier League;Malta;12;2.87;2.97;35.65;1;0;3;0 +Crystalbet Erovnuli Liga;Georgia;10;2.53;3.70;37.00;1;0;3;0 +Prva liga;North Macedonia;12;2.41;2.71;32.57;1;0;3;0 +Cymru Premier;Wales;12;2.78;1.13;13.57;1;0;3;0 +Gibraltar National League;Gibraltar;11;3.68;1.01;11.11;1;0;3;0 +Pepsi Max deild;Iceland;12;2.83;1.75;20.98;1;0;3;0 +1. CFL;Montenegro;10;2.46;2.69;26.90;1;0;3;0 +Primera Divisió;Andorra;8;2.80;1.38;11.05;1;0;2;0 +Camp. Sammarinese;San Marino;15;2.67;0.33;4.99;1;0;2;0 \ No newline at end of file diff --git a/leagues.csv b/leagues.csv index f463abb..e84a9f6 100644 --- a/leagues.csv +++ b/leagues.csv @@ -1,55 +1,55 @@ -leagueName;country;clubs;goalsPerMatch;avgMarketValueInMln;totalMarketValueInMln;teamsInChampionsLeague;teamsInEuropaLeague;teamsInConferenceLeague;famousPlayers -Premier League;England;20;2.78;453.95;9080.0;4;2;1;35 -LaLiga;Spain;20;2.45;246.89;4940.0;4;2;1;21 -Serie A;Italy;20;3.05;245.69;4910.0;4;2;1;17 -Bundesliga;Germany;18;3.04;233.67;4210.0;4;2;1;15 -Ligue 1;France;20;2.83;185.93;3720.0;3;2;1;10 -Liga Bwin;Portugal;18;2.66;64.83;1170.0;3;1;2;0 -Eredivisie;Netherlands;18;2.97;51.78;932.08;2;1;2;0 -Bundesliga;Austria;12;2.95;27.67;332.0;2;1;2;1 -Premiership;Scotland;12;2.52;22.98;275.78;2;1;2;0 -Premier Liga;Russia;16;2.69;60.99;975.8;2;1;2;0 -Premier Liga;Ukraine;16;2.67;28.07;449.18;2;1;2;0 -Super liga Srbije;Serbia;16;2.74;11.60;185.58;1;0;3;0 -Jupiler Pro League;Belgium;18;3.08;46.38;834.9;2;1;2;0 -Super League;Switzerland;10;3.30;28.59;285.93;1;0;3;0 -Protathlima Cyta;Cyprus;12;2.23;11.00;131.95;1;1;2;0 -1.HNL;Croatia;10;2.95;25.51;255.11;1;0;3;0 -Fortuna Liga;Czech Republic;16;3.08;15.60;249.63;2;1;2;0 -Super Lig;Turkey;20;2.63;46.27;925.45;2;1;2;0 -Super League 1;Greece;14;2.60;25.19;352.68;1;0;3;0 -Superligaen;Denmark;12;2.74;20.14;241.68;2;1;2;0 -Eliteserien;Norway;16;3.04;8.46;135.43;1;0;3;0 -Ligat ha'Al;Israel;14;2.38;8.88;124.38;1;0;3;0 -Allsvenskan;Sweden;16;2.63;11.33;181.29;1;0;3;0 -efbet Liga;Bulgaria;14;2.41;8.50;118.94;1;0;3;0 -Premyer Liqa;Azerbaijan;8;2.69;6.36;50.91;1;0;3;0 -Liga 1;Romania;16;2.12;12.31;196.89;1;0;3;0 -Ekstraklasa;Poland;18;2.76;14.16;254.90;1;0;3;0 -NB I.;Hungary;12;3.19;11.11;133.38;1;0;3;0 -Fortuna Liga;Slovakia;12;2.74;6.75;81.04;1;0;3;0 -Premier Liga;Kazakhstan;14;2.57;7.92;110.85;1;0;3;0 -Prva Liga;Slovenia;10;2.45;5.41;54.12;1;0;3;0 -Vysheyshaya Liga;Belarus;16;2.71;4.92;78.73;1;0;3;0 -Divizia Nationala;Moldova;8;3.26;4.96;39.67;1;0;3;0 -A Lyga;Lithuania;10;2.74;2.69;26.88;1;0;3;0 -Premijer Liga;Bosnia-Herzegovina;12;2.27;3.78;45.41;1;0;3;0 -Veikkausliiga;Finland;12;2.35;3.25;38.99;1;0;3;0 -BGL Ligue;Luxembourg;16;3.38;1.69;27.06;1;0;3;0 -Virsliga;Latvia;9;3.02;3.09;27.80;1;0;3;0 -BKT Superliga e Kosovës;Kosovo;10;2.11;2.34;22.43;1;0;2;0 -Premier Division;Republic of Ireland;10;2.54;1.35;13.46;1;0;3;0 -Premiership;Northern Ireland;12;2.85;1.96;23.50;1;0;3;0 -Kategoria Superiore;Albania;10;2.52;4.15;41.50;1;0;3;0 -Bardzragujn khumb;Armenia;10;2.45;4.08;40.79;1;0;3;0 -Betri-deildin;Faroe Islands;10;3.63;1.13;11.29;1;0;2;0 -Premium Liiga;Estonia;10;3.29;2.48;24.81;1;0;2;0 -Premier League;Malta;12;2.87;2.97;35.65;1;0;3;0 -Crystalbet Erovnuli Liga;Georgia;10;2.53;3.70;37.00;1;0;3;0 -Prva liga;North Macedonia;12;2.41;2.71;32.57;1;0;3;0 -Cymru Premier;Wales;12;2.78;1.13;13.57;1;0;3;0 -Gibraltar National League;Gibraltar;11;3.68;1.01;11.11;1;0;3;0 -Pepsi Max deild;Iceland;12;2.83;1.75;20.98;1;0;3;0 -1. CFL;Montenegro;10;2.46;2.69;26.90;1;0;3;0 -Primera Divisió;Andorra;8;2.80;1.38;11.05;1;0;2;0 -Camp. Sammarinese;San Marino;15;2.67;0.33;4.99;1;0;2;0 \ No newline at end of file +leagueName;country;clubs;goalsPerMatch;avgMarketValueInMln;teamsInChampionsLeague;teamsInEuropaLeague;teamsInConferenceLeague;famousPlayers +Premier League;England;20;2.78;453.95;4;2;1;35 +LaLiga;Spain;20;2.45;246.89;4;2;1;21 +Serie A;Italy;20;3.05;245.69;4;2;1;17 +Bundesliga;Germany;18;3.04;233.67;4;2;1;15 +Ligue 1;France;20;2.83;185.93;3;2;1;10 +Liga Bwin;Portugal;18;2.66;64.83;3;1;2;0 +Eredivisie;Netherlands;18;2.97;51.78;2;1;2;0 +Bundesliga;Austria;12;2.95;27.67;2;1;2;1 +Premiership;Scotland;12;2.52;22.98;2;1;2;0 +Premier Liga;Russia;16;2.69;60.99;2;1;2;0 +Premier Liga;Ukraine;16;2.67;28.07;2;1;2;0 +Super liga Srbije;Serbia;16;2.74;11.60;1;0;3;0 +Jupiler Pro League;Belgium;18;3.08;46.38;2;1;2;0 +Super League;Switzerland;10;3.30;28.59;1;0;3;0 +Protathlima Cyta;Cyprus;12;2.23;11.00;1;1;2;0 +1.HNL;Croatia;10;2.95;25.51;1;0;3;0 +Fortuna Liga;Czech Republic;16;3.08;15.60;2;1;2;0 +Super Lig;Turkey;20;2.63;46.27;2;1;2;0 +Super League 1;Greece;14;2.60;25.19;1;0;3;0 +Superligaen;Denmark;12;2.74;20.14;2;1;2;0 +Eliteserien;Norway;16;3.04;8.46;1;0;3;0 +Ligat ha'Al;Israel;14;2.38;8.88;1;0;3;0 +Allsvenskan;Sweden;16;2.63;11.33;1;0;3;0 +efbet Liga;Bulgaria;14;2.41;8.50;1;0;3;0 +Premyer Liqa;Azerbaijan;8;2.69;6.36;1;0;3;0 +Liga 1;Romania;16;2.12;12.31;1;0;3;0 +Ekstraklasa;Poland;18;2.76;14.16;1;0;3;0 +NB I.;Hungary;12;3.19;11.11;1;0;3;0 +Fortuna Liga;Slovakia;12;2.74;6.75;1;0;3;0 +Premier Liga;Kazakhstan;14;2.57;7.92;1;0;3;0 +Prva Liga;Slovenia;10;2.45;5.41;1;0;3;0 +Vysheyshaya Liga;Belarus;16;2.71;4.92;1;0;3;0 +Divizia Nationala;Moldova;8;3.26;4.96;1;0;3;0 +A Lyga;Lithuania;10;2.74;2.69;1;0;3;0 +Premijer Liga;Bosnia-Herzegovina;12;2.27;3.78;1;0;3;0 +Veikkausliiga;Finland;12;2.35;3.25;1;0;3;0 +BGL Ligue;Luxembourg;16;3.38;1.69;1;0;3;0 +Virsliga;Latvia;9;3.02;3.09;1;0;3;0 +BKT Superliga e Kosovës;Kosovo;10;2.11;2.34;1;0;2;0 +Premier Division;Republic of Ireland;10;2.54;1.35;1;0;3;0 +Premiership;Northern Ireland;12;2.85;1.96;1;0;3;0 +Kategoria Superiore;Albania;10;2.52;4.15;1;0;3;0 +Bardzragujn khumb;Armenia;10;2.45;4.08;1;0;3;0 +Betri-deildin;Faroe Islands;10;3.63;1.13;1;0;2;0 +Premium Liiga;Estonia;10;3.29;2.48;1;0;2;0 +Premier League;Malta;12;2.87;2.97;1;0;3;0 +Crystalbet Erovnuli Liga;Georgia;10;2.53;3.70;1;0;3;0 +Prva liga;North Macedonia;12;2.41;2.71;1;0;3;0 +Cymru Premier;Wales;12;2.78;1.13;1;0;3;0 +Gibraltar National League;Gibraltar;11;3.68;1.01;1;0;3;0 +Pepsi Max deild;Iceland;12;2.83;1.75;1;0;3;0 +1. CFL;Montenegro;10;2.46;2.69;1;0;3;0 +Primera Divisió;Andorra;8;2.80;1.38;1;0;2;0 +Camp. Sammarinese;San Marino;15;2.67;0.33;1;0;2;0 \ No newline at end of file diff --git a/main.py b/main.py index 25c9f94..0b1a566 100644 --- a/main.py +++ b/main.py @@ -6,188 +6,223 @@ from read_data import get_leagues_data # https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem.html # Variables for universes -unv_clubs = unv_goals = unv_avgValue = unv_totValue = unv_players = unv_teamsChL = unv_teamsEuL = unv_teamsCfL = unv_score = None +unv_clubs = unv_goals = unv_avgValue = unv_players = unv_teamsChL = unv_teamsEuL = unv_teamsCfL = unv_score = None # Variables for fuzzy membership functions -clubs_low = clubs_mid = clubs_hig = None -goals_low = goals_mid = goals_hig = None -avgValue_low = avgValue_mid = avgValue_hig = None -totValue_low = totValue_mid = totValue_hig = None -players_low = players_mid = players_hig = None -teamsChL_low = teamsChL_mid = teamsChL_hig = None -teamsEuL_low = teamsEuL_mid = teamsEuL_hig = None -teamsCfL_low = teamsCfL_mid = teamsCfL_hig = None -score_low = score_mid = score_hig = None +clubs_few = clubs_some = clubs_several = clubs_many = None +goals_few = goals_moderate = goals_many = None +avgValue_vpoor = avgValue_poor = avgValue_mpoor = avgValue_moderate = avgValue_mrich = avgValue_rich = avgValue_vrich = None +players_none = players_few = players_moderate = players_many = None +teamsChL_min = teamsChL_mid = teamsChL_max = None +teamsEuL_min = teamsEuL_mid = teamsEuL_max = None +teamsCfL_min = teamsCfL_mid = teamsCfL_max = None +score_tragic = score_bad = score_moderate = score_good = score_best = None # Activations of fuzzy membership functions -clubs_low_level = clubs_mid_level = clubs_hig_level = None -goals_low_level = goals_mid_level = goals_hig_level = None -avgValue_low_level = avgValue_mid_level = avgValue_hig_level = None -totValue_low_level = totValue_mid_level = totValue_hig_level = None -players_low_level = players_mid_level = players_hig_level = None -teamsChL_low_level = teamsChL_mid_level = teamsChL_hig_level = None -teamsEuL_low_level = teamsEuL_mid_level = teamsEuL_hig_level = None -teamsCfL_low_level = teamsCfL_mid_level = teamsCfL_hig_level = None +clubs_few_level = clubs_some_level = clubs_several_level = clubs_many_level = None +goals_few_level = goals_moderate_level = goals_many_level = None +avgValue_vpoor_level = avgValue_poor_level = avgValue_mpoor_level = avgValue_moderate_level = avgValue_mrich_level = avgValue_rich_level = avgValue_vrich_level = None +players_none_level = players_few_level = players_moderate_level = players_many_level = None +teamsChL_min_level = teamsChL_mid_level = teamsChL_max_level = None +teamsEuL_min_level = teamsEuL_mid_level = teamsEuL_max_level = None +teamsCfL_min_level = teamsCfL_mid_level = teamsCfL_max_level = None def initFuzzyMembershipFunctions(): - global unv_clubs, unv_goals, unv_avgValue, unv_totValue, unv_players, unv_teamsChL, unv_teamsEuL, unv_teamsCfL, unv_score - global clubs_low, clubs_mid, clubs_hig - global goals_low, goals_mid, goals_hig - global avgValue_low, avgValue_mid, avgValue_hig - global totValue_low, totValue_mid, totValue_hig - global players_low, players_mid, players_hig - global teamsChL_low, teamsChL_mid, teamsChL_hig - global teamsEuL_low, teamsEuL_mid, teamsEuL_hig - global teamsCfL_low, teamsCfL_mid, teamsCfL_hig - global score_low, score_mid, score_hig + global unv_clubs, unv_goals, unv_avgValue, unv_players, unv_teamsChL, unv_teamsEuL, unv_teamsCfL, unv_score + global clubs_few, clubs_some, clubs_several, clubs_many + global goals_few, goals_moderate, goals_many + global avgValue_vpoor, avgValue_poor, avgValue_mpoor, avgValue_moderate, avgValue_mrich, avgValue_rich, avgValue_vrich + global players_none, players_few, players_moderate, players_many + global teamsChL_min, teamsChL_mid, teamsChL_max + global teamsEuL_min, teamsEuL_mid, teamsEuL_max + global teamsCfL_min, teamsCfL_mid, teamsCfL_max + global score_tragic, score_bad, score_moderate, score_good, score_best # Universes for variables unv_clubs = np.arange(2, 31, 1) - unv_goals = np.arange(2, 4, 0.01) - unv_avgValue = np.arange(0.01, 500.0, 0.01) - unv_totValue = np.arange(0.01, 10000.0, 0.01) - unv_players = np.arange(0, 100, 1) - unv_teamsChL = np.arange(0, 10, 1) - unv_teamsEuL = np.arange(0, 10, 1) - unv_teamsCfL = np.arange(0, 10, 1) + unv_goals = np.arange(0.99, 5.01, 0.01) + unv_avgValue = np.arange(0.01, 500.01, 0.01) + unv_players = np.arange(0, 101, 1) + unv_teamsChL = np.arange(0, 6, 1) + unv_teamsEuL = np.arange(0, 6, 1) + unv_teamsCfL = np.arange(0, 6, 1) # Result score universum - unv_score = np.arange(0, 100, 1) + unv_score = np.arange(0, 101, 1) # Generate fuzzy membership functions # trimf - triangular function # trapmf - trapezoidal function - clubs_low = fuzz.trapmf(unv_clubs, [2, 2, 10, 14]) - clubs_mid = fuzz.trapmf(unv_clubs, [10, 12, 16, 18]) - clubs_hig = fuzz.trapmf(unv_clubs, [14, 16, 30, 30]) + clubs_few = fuzz.trapmf(unv_clubs, [2, 2, 5, 8]) + clubs_some = fuzz.trapmf(unv_clubs, [3, 6, 9, 12]) + clubs_several = fuzz.trapmf(unv_clubs, [8, 11, 15, 18]) + clubs_many = fuzz.trapmf(unv_clubs, [15, 18, 30, 30]) - goals_low = fuzz.trapmf(unv_goals, [2.0, 2.0, 2.5, 3.0]) - goals_mid = fuzz.trapmf(unv_goals, [2.0, 2.5, 3.0, 3.5]) - goals_hig = fuzz.trapmf(unv_goals, [3.0, 3.5, 4.0, 4.0]) + goals_few = fuzz.trapmf(unv_goals, [1.0, 1.0, 2.0, 3.0]) + goals_moderate = fuzz.trimf(unv_goals, [2.5, 3.0, 3.5]) + goals_many = fuzz.trapmf(unv_goals, [3.0, 3.5, 5.0, 5.0]) + + avgValue_vpoor = fuzz.trapmf(unv_avgValue, [0.01, 0.01, 1.0, 2.0]) + avgValue_poor = fuzz.trimf(unv_avgValue, [1.0, 5.0, 15.0]) + avgValue_mpoor = fuzz.trimf(unv_avgValue, [7.5, 20.0, 50.0]) + avgValue_moderate = fuzz.trimf(unv_avgValue, [20.0, 50.0, 100.0]) + avgValue_mrich = fuzz.trimf(unv_avgValue, [50.0, 100.0, 175.0]) + avgValue_rich = fuzz.trimf(unv_avgValue, [150.0, 200.0, 275.0]) + avgValue_vrich = fuzz.trapmf(unv_avgValue, [200.0, 300.0, 500.0, 500.0]) - avgValue_low = fuzz.trapmf(unv_avgValue, [0.01, 0.01, 100.0, 150.0]) - avgValue_mid = fuzz.trapmf(unv_avgValue, [100.0, 150.0, 350.0, 400.0]) - avgValue_hig = fuzz.trapmf(unv_avgValue, [350.0, 400.0, 500.0, 500.0]) + players_none = fuzz.trimf(unv_players, [0, 0, 1]) + players_few = fuzz.trapmf(unv_players, [1, 5, 10, 15]) + players_moderate = fuzz.trapmf(unv_players, [10, 15, 20, 25]) + players_many = fuzz.trapmf(unv_players, [20, 25, 100, 100]) - totValue_low = fuzz.trapmf(unv_totValue, [0.01, 0.01, 1000.0, 2000.0]) - totValue_mid = fuzz.trapmf(unv_totValue, [1000.0, 2000.0, 7000.0, 8000.0]) - totValue_hig = fuzz.trapmf(unv_totValue, [7000.0, 8000.0, 10000.0, 10000.0]) + teamsChL_min = fuzz.trapmf(unv_teamsChL, [0, 0, 1, 2]) + teamsChL_mid = fuzz.trapmf(unv_teamsChL, [1, 2, 3, 4]) + teamsChL_max = fuzz.trapmf(unv_teamsChL, [3, 4, 5, 5]) - players_low = fuzz.trapmf(unv_players, [0, 0, 5, 10]) - players_mid = fuzz.trapmf(unv_players, [5, 10, 15, 20]) - players_hig = fuzz.trapmf(unv_players, [15, 20, 100, 100]) + teamsEuL_min = fuzz.trimf(unv_teamsEuL, [0, 0, 1]) + teamsEuL_mid = fuzz.trimf(unv_teamsEuL, [0, 1, 2]) + teamsEuL_max = fuzz.trapmf(unv_teamsEuL, [1, 2, 5, 5]) - teamsChL_low = fuzz.trapmf(unv_teamsChL, [0, 0, 1, 2]) - teamsChL_mid = fuzz.trimf(unv_teamsChL, [1, 2, 3]) - teamsChL_hig = fuzz.trapmf(unv_teamsChL, [2, 3, 10, 10]) - - teamsEuL_low = fuzz.trapmf(unv_teamsEuL, [0, 0, 1, 2]) - teamsEuL_mid = fuzz.trimf(unv_teamsEuL, [1, 2, 3]) - teamsEuL_hig = fuzz.trapmf(unv_teamsEuL, [2, 3, 10, 10]) - - teamsCfL_low = fuzz.trapmf(unv_teamsCfL, [0, 0, 1, 2]) + teamsCfL_min = fuzz.trapmf(unv_teamsCfL, [0, 0, 1, 2]) teamsCfL_mid = fuzz.trimf(unv_teamsCfL, [1, 2, 3]) - teamsCfL_hig = fuzz.trapmf(unv_teamsCfL, [2, 3, 10, 10]) + teamsCfL_max = fuzz.trapmf(unv_teamsCfL, [2, 3, 5, 5]) - score_low = fuzz.trapmf(unv_score, [0, 0, 20, 40]) - score_mid = fuzz.trapmf(unv_score, [20, 40, 60, 80]) - score_hig = fuzz.trapmf(unv_score, [60, 80, 100, 100]) + score_tragic = fuzz.trapmf(unv_score, [0, 0, 15, 25]) + score_bad = fuzz.trapmf(unv_score, [15, 25, 35, 45]) + score_moderate = fuzz.trapmf(unv_score, [35, 45, 55, 65]) + score_good = fuzz.trapmf(unv_score, [55, 65, 75, 85]) + score_best = fuzz.trapmf(unv_score, [75, 85, 100, 100]) def activateFuzzyMembershipFunctions(values): - global unv_clubs, unv_goals, unv_avgValue, unv_totValue, unv_players, unv_teamsChL, unv_teamsEuL, unv_teamsCfL - global clubs_low, clubs_mid, clubs_hig - global goals_low, goals_mid, goals_hig - global avgValue_low, avgValue_mid, avgValue_hig - global totValue_low, totValue_mid, totValue_hig - global players_low, players_mid, players_hig - global teamsChL_low, teamsChL_mid, teamsChL_hig - global teamsEuL_low, teamsEuL_mid, teamsEuL_hig - global teamsCfL_low, teamsCfL_mid, teamsCfL_hig - global clubs_low_level, clubs_mid_level, clubs_hig_level - global goals_low_level, goals_mid_level, goals_hig_level - global avgValue_low_level, avgValue_mid_level, avgValue_hig_level - global totValue_low_level, totValue_mid_level, totValue_hig_level - global players_low_level, players_mid_level, players_hig_level - global teamsChL_low_level, teamsChL_mid_level, teamsChL_hig_level - global teamsEuL_low_level, teamsEuL_mid_level, teamsEuL_hig_level - global teamsCfL_low_level, teamsCfL_mid_level, teamsCfL_hig_level + global unv_clubs, unv_goals, unv_avgValue, unv_players, unv_teamsChL, unv_teamsEuL, unv_teamsCfL + global clubs_few, clubs_some, clubs_several, clubs_many + global goals_few, goals_moderate, goals_many + global avgValue_vpoor, avgValue_poor, avgValue_mpoor, avgValue_moderate, avgValue_mrich, avgValue_rich, avgValue_vrich + global players_none, players_few, players_moderate, players_many + global teamsChL_min, teamsChL_mid, teamsChL_max + global teamsEuL_min, teamsEuL_mid, teamsEuL_max + global teamsCfL_min, teamsCfL_mid, teamsCfL_max + global clubs_few_level, clubs_some_level, clubs_several_level, clubs_many_level + global goals_few_level, goals_moderate_level, goals_many_level + global avgValue_vpoor_level, avgValue_poor_level, avgValue_mpoor_level, avgValue_moderate_level, avgValue_mrich_level, avgValue_rich_level, avgValue_vrich_level + global players_none_level, players_few_level, players_moderate_level, players_many_level + global teamsChL_min_level, teamsChL_mid_level, teamsChL_max_level + global teamsEuL_min_level, teamsEuL_mid_level, teamsEuL_max_level + global teamsCfL_min_level, teamsCfL_mid_level, teamsCfL_max_level # Activation of fuzzy membership functions at given values. - clubs_low_level = fuzz.interp_membership(unv_clubs, clubs_low, values['clubs']) - clubs_mid_level = fuzz.interp_membership(unv_clubs, clubs_mid, values['clubs']) - clubs_hig_level = fuzz.interp_membership(unv_clubs, clubs_hig, values['clubs']) + clubs_few_level = fuzz.interp_membership(unv_clubs, clubs_few, values['clubs']) + clubs_some_level = fuzz.interp_membership(unv_clubs, clubs_some, values['clubs']) + clubs_several_level = fuzz.interp_membership(unv_clubs, clubs_several, values['clubs']) + clubs_many_level = fuzz.interp_membership(unv_clubs, clubs_many, values['clubs']) - goals_low_level = fuzz.interp_membership(unv_goals, goals_low, values['goalsPerMatch']) - goals_mid_level = fuzz.interp_membership(unv_goals, goals_mid, values['goalsPerMatch']) - goals_hig_level = fuzz.interp_membership(unv_goals, goals_hig, values['goalsPerMatch']) + goals_few_level = fuzz.interp_membership(unv_goals, goals_few, values['goalsPerMatch']) + goals_moderate_level = fuzz.interp_membership(unv_goals, goals_moderate, values['goalsPerMatch']) + goals_many_level = fuzz.interp_membership(unv_goals, goals_many, values['goalsPerMatch']) + + avgValue_vpoor_level = fuzz.interp_membership(unv_avgValue, avgValue_vpoor, values['avgMarketValueInMln']) + avgValue_poor_level = fuzz.interp_membership(unv_avgValue, avgValue_poor, values['avgMarketValueInMln']) + avgValue_mpoor_level = fuzz.interp_membership(unv_avgValue, avgValue_mpoor, values['avgMarketValueInMln']) + avgValue_moderate_level = fuzz.interp_membership(unv_avgValue, avgValue_moderate, values['avgMarketValueInMln']) + avgValue_mrich_level = fuzz.interp_membership(unv_avgValue, avgValue_mrich, values['avgMarketValueInMln']) + avgValue_rich_level = fuzz.interp_membership(unv_avgValue, avgValue_rich, values['avgMarketValueInMln']) + avgValue_vrich_level = fuzz.interp_membership(unv_avgValue, avgValue_vrich, values['avgMarketValueInMln']) - avgValue_low_level = fuzz.interp_membership(unv_avgValue, avgValue_low, values['avgMarketValueInMln']) - avgValue_mid_level = fuzz.interp_membership(unv_avgValue, avgValue_mid, values['avgMarketValueInMln']) - avgValue_hig_level = fuzz.interp_membership(unv_avgValue, avgValue_hig, values['avgMarketValueInMln']) + players_none_level = fuzz.interp_membership(unv_players, players_none, values['famousPlayers']) + players_few_level = fuzz.interp_membership(unv_players, players_few, values['famousPlayers']) + players_moderate_level = fuzz.interp_membership(unv_players, players_moderate, values['famousPlayers']) + players_many_level = fuzz.interp_membership(unv_players, players_many, values['famousPlayers']) - totValue_low_level = fuzz.interp_membership(unv_totValue, totValue_low, values['totalMarketValueInMln']) - totValue_mid_level = fuzz.interp_membership(unv_totValue, totValue_mid, values['totalMarketValueInMln']) - totValue_hig_level = fuzz.interp_membership(unv_totValue, totValue_hig, values['totalMarketValueInMln']) - - players_low_level = fuzz.interp_membership(unv_players, players_low, values['famousPlayers']) - players_mid_level = fuzz.interp_membership(unv_players, players_mid, values['famousPlayers']) - players_hig_level = fuzz.interp_membership(unv_players, players_hig, values['famousPlayers']) - - teamsChL_low_level = fuzz.interp_membership(unv_teamsChL, teamsChL_low, values['teamsInChampionsLeague']) + teamsChL_min_level = fuzz.interp_membership(unv_teamsChL, teamsChL_min, values['teamsInChampionsLeague']) teamsChL_mid_level = fuzz.interp_membership(unv_teamsChL, teamsChL_mid, values['teamsInChampionsLeague']) - teamsChL_hig_level = fuzz.interp_membership(unv_teamsChL, teamsChL_hig, values['teamsInChampionsLeague']) + teamsChL_max_level = fuzz.interp_membership(unv_teamsChL, teamsChL_max, values['teamsInChampionsLeague']) - teamsEuL_low_level = fuzz.interp_membership(unv_teamsEuL, teamsEuL_low, values['teamsInEuropaLeague']) + teamsEuL_min_level = fuzz.interp_membership(unv_teamsEuL, teamsEuL_min, values['teamsInEuropaLeague']) teamsEuL_mid_level = fuzz.interp_membership(unv_teamsEuL, teamsEuL_mid, values['teamsInEuropaLeague']) - teamsEuL_hig_level = fuzz.interp_membership(unv_teamsEuL, teamsEuL_hig, values['teamsInEuropaLeague']) + teamsEuL_max_level = fuzz.interp_membership(unv_teamsEuL, teamsEuL_max, values['teamsInEuropaLeague']) - teamsCfL_low_level = fuzz.interp_membership(unv_teamsCfL, teamsCfL_low, values['teamsInConferenceLeague']) + teamsCfL_min_level = fuzz.interp_membership(unv_teamsCfL, teamsCfL_min, values['teamsInConferenceLeague']) teamsCfL_mid_level = fuzz.interp_membership(unv_teamsCfL, teamsCfL_mid, values['teamsInConferenceLeague']) - teamsCfL_hig_level = fuzz.interp_membership(unv_teamsCfL, teamsCfL_hig, values['teamsInConferenceLeague']) + teamsCfL_max_level = fuzz.interp_membership(unv_teamsCfL, teamsCfL_max, values['teamsInConferenceLeague']) def defineRules(): - global clubs_low_level, clubs_mid_level, clubs_hig_level - global goals_low_level, goals_mid_level, goals_hig_level - global avgValue_low_level, avgValue_mid_level, avgValue_hig_level - global totValue_low_level, totValue_mid_level, totValue_hig_level - global players_low_level, players_mid_level, players_hig_level - global teamsChL_low_level, teamsChL_mid_level, teamsChL_hig_level - global teamsEuL_low_level, teamsEuL_mid_level, teamsEuL_hig_level - global teamsCfL_low_level, teamsCfL_mid_level, teamsCfL_hig_level - global score_low, score_mid, score_hig, unv_score + global clubs_few_level, clubs_some_level, clubs_several_level, clubs_many_level + global goals_few_level, goals_moderate_level, goals_many_level + global avgValue_vpoor_level, avgValue_poor_level, avgValue_mpoor_level, avgValue_moderate_level, avgValue_mrich_level, avgValue_rich_level, avgValue_vrich_level + global players_none_level, players_few_level, players_moderate_level, players_many_level + global teamsChL_min_level, teamsChL_mid_level, teamsChL_max_level + global teamsEuL_min_level, teamsEuL_mid_level, teamsEuL_max_level + global teamsCfL_min_level, teamsCfL_mid_level, teamsCfL_max_level + global score_tragic, score_bad, score_moderate, score_good, score_best, unv_score # OR - active_rule1 = np.fmax(clubs_low_level, - np.fmax(goals_low_level, - np.fmax(avgValue_low_level, - np.fmax(totValue_low_level, - np.fmax(players_low_level, - np.fmax(teamsChL_low_level, - np.fmax(teamsEuL_low_level, teamsCfL_low_level))))))) + active_rule1 = np.fmax(clubs_some_level, + np.fmax(clubs_few_level, + np.fmax(goals_few_level, + np.fmax(avgValue_mpoor_level, + np.fmax(avgValue_poor_level, + np.fmax(avgValue_vpoor_level, + np.fmax(players_none_level, + np.fmax(teamsChL_min_level, + np.fmax(teamsEuL_min_level, + np.fmax(teamsCfL_max_level, teamsCfL_mid_level)))))))))) - active_rule2 = np.fmax(clubs_mid_level, - np.fmax(goals_mid_level, - np.fmax(avgValue_mid_level, - np.fmax(totValue_mid_level, - np.fmax(players_mid_level, - np.fmax(teamsChL_mid_level, - np.fmax(teamsEuL_mid_level, teamsCfL_mid_level))))))) + active_rule2 = np.fmax(clubs_several_level, + np.fmax(clubs_some_level, + np.fmax(clubs_few_level, + np.fmax(goals_moderate_level, + np.fmax(goals_few_level, + np.fmax(avgValue_moderate_level, + np.fmax(avgValue_mpoor_level, + np.fmax(avgValue_poor_level, + np.fmax(players_few_level, + np.fmax(players_none_level, + np.fmax(teamsChL_min_level, + np.fmax(teamsEuL_min_level, + np.fmax(teamsCfL_max_level, teamsCfL_mid_level))))))))))))) - active_rule3 = np.fmax(clubs_hig_level, - np.fmax(goals_hig_level, - np.fmax(avgValue_hig_level, - np.fmax(totValue_hig_level, - np.fmax(players_hig_level, - np.fmax(teamsChL_hig_level, - np.fmax(teamsEuL_hig_level, teamsCfL_hig_level))))))) + active_rule3 = np.fmax(clubs_several_level, + np.fmax(clubs_some_level, + np.fmax(goals_moderate_level, + np.fmax(avgValue_mrich_level, + np.fmax(avgValue_moderate_level, + np.fmax(avgValue_mpoor_level, + np.fmax(players_moderate_level, + np.fmax(players_few_level, + np.fmax(teamsChL_mid_level, + np.fmax(teamsChL_min_level, + np.fmax(teamsEuL_mid_level, + np.fmax(teamsEuL_min_level, + np.fmax(teamsCfL_max_level, teamsCfL_mid_level))))))))))))) - score_activation_low = np.fmin(active_rule1, score_low) - score_activation_mid = np.fmin(active_rule2, score_mid) - score_activation_hig = np.fmin(active_rule3, score_hig) + active_rule4 = np.fmax(clubs_many_level, + np.fmax(clubs_several_level, + np.fmax(goals_many_level, + np.fmax(goals_moderate_level, + np.fmax(avgValue_vrich_level, + np.fmax(avgValue_rich_level, + np.fmax(avgValue_mrich_level, + np.fmax(players_many_level, + np.fmax(players_moderate_level, + np.fmax(teamsChL_mid_level, + np.fmax(teamsEuL_mid_level, teamsCfL_mid_level))))))))))) + + active_rule5 = np.fmax(clubs_many_level, + np.fmax(goals_many_level, + np.fmax(avgValue_vrich_level, + np.fmax(players_many_level, + np.fmax(teamsChL_max_level, + np.fmax(teamsEuL_max_level, teamsCfL_min_level)))))) - aggregated_rules = np.fmax(score_activation_low, np.fmax(score_activation_mid, score_activation_hig)) + score_activation_tragic = np.fmin(active_rule1, score_tragic) + score_activation_bad = np.fmin(active_rule2, score_bad) + score_activation_moderate = np.fmin(active_rule3, score_moderate) + score_activation_good = np.fmin(active_rule4, score_good) + score_activation_best = np.fmin(active_rule5, score_best) + + aggregated_rules = np.fmax(score_activation_tragic, np.fmax(score_activation_bad, np.fmax(score_activation_moderate, np.fmax(score_activation_good, score_activation_best)))) # active_rule1 = np.fmax(qual_level_lo, serv_level_lo) # tip_activation_lo = np.fmin(active_rule1, tip_lo) # removed entirely to 0 @@ -221,7 +256,6 @@ if __name__ == "__main__": 'clubs': input('Podaj liczbę klubów grających w lidze:\n'), 'goalsPerMatch': input('Podaj średnią liczbę goli na mecz:\n'), 'avgMarketValueInMln': input('Podaj średnią wartośc klubu w lidze (w milionach):\n'), - 'totalMarketValueInMln': input('Podaj całkowitą wartość ligi (w milionach):\n'), 'teamsInChampionsLeague': input('Podaj liczbę klubów grających w Lidze Mistrzów:\n'), 'teamsInEuropaLeague': input('Podaj liczbę klubów grających w Lidze Europy:\n'), 'teamsInConferenceLeague': input('Podaj liczbę klubów grających w Lidze Konferencji:\n'), diff --git a/res.csv b/res.csv new file mode 100644 index 0000000..7949b7d --- /dev/null +++ b/res.csv @@ -0,0 +1,54 @@ +Premier League score is, 1.0 +LaLiga score is, 1.0 +Serie A score is, 1.0 +Bundesliga score is, 1.0 +Ligue 1 score is, 0.6926977372958362 +Liga Bwin score is, 1.0 +Eredivisie score is, 1.0 +Bundesliga score is, 0.5057471264367834 +Premiership score is, 0.5057471264367834 +Premier Liga score is, 0.8734130372900716 +Premier Liga score is, 0.8734130372900716 +Super liga Srbije score is, 0.7140096618357546 +Jupiler Pro League score is, 1.0 +Super League score is, 1.0 +Protathlima Cyta score is, 0.5057471264367834 +1.HNL score is, 0.5403828197945835 +Fortuna Liga score is, 0.8734130372900716 +Super Lig score is, 1.0 +Super League 1 score is, 0.5057471264367834 +Superligaen score is, 0.5057471264367834 +Eliteserien score is, 0.8434674958254214 +Ligat ha'Al score is, 0.5057471264367834 +Allsvenskan score is, 0.7140096618357546 +efbet Liga score is, 0.5057471264367834 +Premyer Liqa score is, 0.97034078807242 +Liga 1 score is, 0.7140096618357546 +Ekstraklasa score is, 1.0 +NB I. score is, 0.9248363528865283 +Fortuna Liga score is, 0.5057471264367834 +Premier Liga score is, 0.5057471264367834 +Prva Liga score is, 0.6908378245957848 +Vysheyshaya Liga score is, 0.7140096618357546 +Divizia Nationala score is, 0.8463231347289373 +A Lyga score is, 0.6908378245957848 +Premijer Liga score is, 0.5057471264367834 +Veikkausliiga score is, 0.5057471264367834 +BGL Ligue score is, 1.0 +Virsliga score is, 0.5321408915795232 +BKT Superliga e Kosovës score is, 0.5057471264367834 +Premier Division score is, 0.6908378245957848 +Premiership score is, 0.5057471264367834 +Kategoria Superiore score is, 0.6908378245957848 +Bardzragujn khumb score is, 0.6908378245957848 +Betri-deildin score is, 1.0 +Premium Liiga score is, 1.0 +Premier League score is, 0.5057471264367834 +Crystalbet Erovnuli Liga score is, 0.6908378245957848 +Prva liga score is, 0.5057471264367834 +Cymru Premier score is, 0.5057471264367834 +Gibraltar National League score is, 1.0 +Pepsi Max deild score is, 0.5057471264367834 +1. CFL score is, 0.6908378245957848 +Primera Divisió score is, 0.5057471264367834 +Camp. Sammarinese score is, 0.5057471264367834 \ No newline at end of file diff --git a/res2.csv b/res2.csv new file mode 100644 index 0000000..a6e0935 --- /dev/null +++ b/res2.csv @@ -0,0 +1,54 @@ +Premier League score is, 0.6041054792357513 +LaLiga score is, 0.8 +Serie A score is, 0.5403828197945849 +Bundesliga score is, 0.531043470166621 +Ligue 1 score is, 0.6926977372958362 +Liga Bwin score is, 1.0 +Eredivisie score is, 1.0 +Bundesliga score is, 0.5057471264367834 +Premiership score is, 0.5057471264367834 +Premier Liga score is, 0.8734130372900716 +Premier Liga score is, 0.8734130372900716 +Super liga Srbije score is, 0.7140096618357546 +Jupiler Pro League score is, 1.0 +Super League score is, 1.0 +Protathlima Cyta score is, 0.5057471264367834 +1.HNL score is, 0.5403828197945835 +Fortuna Liga score is, 0.8734130372900716 +Super Lig score is, 1.0 +Super League 1 score is, 0.5057471264367834 +Superligaen score is, 0.5057471264367834 +Eliteserien score is, 0.8434674958254214 +Ligat ha'Al score is, 0.5057471264367834 +Allsvenskan score is, 0.7140096618357546 +efbet Liga score is, 0.5057471264367834 +Premyer Liqa score is, 0.97034078807242 +Liga 1 score is, 0.7140096618357546 +Ekstraklasa score is, 1.0 +NB I. score is, 0.9248363528865283 +Fortuna Liga score is, 0.5057471264367834 +Premier Liga score is, 0.5057471264367834 +Prva Liga score is, 0.6908378245957848 +Vysheyshaya Liga score is, 0.7140096618357546 +Divizia Nationala score is, 0.8463231347289373 +A Lyga score is, 0.6908378245957848 +Premijer Liga score is, 0.5057471264367834 +Veikkausliiga score is, 0.5057471264367834 +BGL Ligue score is, 1.0 +Virsliga score is, 0.5321408915795232 +BKT Superliga e Kosovës score is, 0.5057471264367834 +Premier Division score is, 0.6908378245957848 +Premiership score is, 0.5057471264367834 +Kategoria Superiore score is, 0.6908378245957848 +Bardzragujn khumb score is, 0.6908378245957848 +Betri-deildin score is, 1.0 +Premium Liiga score is, 1.0 +Premier League score is, 0.5057471264367834 +Crystalbet Erovnuli Liga score is, 0.6908378245957848 +Prva liga score is, 0.5057471264367834 +Cymru Premier score is, 0.5057471264367834 +Gibraltar National League score is, 1.0 +Pepsi Max deild score is, 0.5057471264367834 +1. CFL score is, 0.6908378245957848 +Primera Divisió score is, 0.5057471264367834 +Camp. Sammarinese score is, 0.5057471264367834 \ No newline at end of file