2020-06-04 19:21:01 +02:00
|
|
|
from fcl_parser import FCLParser
|
|
|
|
import skfuzzy.control as ctrl
|
|
|
|
import pandas as pd
|
|
|
|
|
2020-06-15 12:16:49 +02:00
|
|
|
s1 = '2018/2019'
|
|
|
|
s2 = '2019/2020'
|
2020-06-04 19:21:01 +02:00
|
|
|
teams = pd.read_csv('teams_list.csv')
|
|
|
|
matches = pd.read_csv('matches_list.csv')
|
|
|
|
|
2020-06-09 19:57:26 +02:00
|
|
|
not_in_df = ['Podbeskidzie']
|
2020-06-04 19:21:01 +02:00
|
|
|
matches_input = []
|
2020-06-09 19:57:26 +02:00
|
|
|
for i in range(0,matches.shape[0]):
|
2020-06-04 19:21:01 +02:00
|
|
|
team1 = matches['Team1'][i][:-1]
|
|
|
|
team2 = matches['Team2'][i][1:-1]
|
|
|
|
gameweek = matches['Gameweek'][i]
|
2020-06-15 12:16:49 +02:00
|
|
|
season = matches['Season'][i]
|
|
|
|
|
|
|
|
points2017 = {
|
|
|
|
"Legia Warszawa": 70,
|
|
|
|
"Jagiellonia Białystok": 67,
|
|
|
|
"Lech Poznań": 60,
|
|
|
|
"Górnik Zabrze": 60,
|
|
|
|
"Wisła Płock": 57,
|
|
|
|
"Wisła Kraków": 55,
|
|
|
|
"Zagłębie Lubin": 52,
|
|
|
|
"Korona Kielce": 49,
|
|
|
|
"Cracovia Kraków": 50,
|
|
|
|
"Śląsk Wrocław": 50,
|
|
|
|
"Pogoń Szczecin": 45,
|
|
|
|
"Arka Gdynia": 43,
|
|
|
|
"Lechia Gdańsk": 39,
|
|
|
|
"Piast Gliwice": 37,
|
|
|
|
"Miedź Legnica": 35,
|
|
|
|
"Zagłębie Sosnowiec": 35,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-04 19:21:01 +02:00
|
|
|
if((team1 not in not_in_df) and (team2 not in not_in_df)):
|
2020-06-09 19:57:26 +02:00
|
|
|
try:
|
2020-06-15 12:16:49 +02:00
|
|
|
|
|
|
|
form_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Form.values[0]
|
|
|
|
temp_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Points.values[0]
|
|
|
|
xGform_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].xGform.values[0]
|
|
|
|
|
|
|
|
form_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Form.values[0]
|
|
|
|
temp_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Points.values[0]
|
|
|
|
xGform_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].xGform.values[0]
|
|
|
|
|
2020-06-09 19:57:26 +02:00
|
|
|
except:
|
|
|
|
print(team1 + team2 + str(gameweek))
|
2020-06-04 19:21:01 +02:00
|
|
|
|
2020-06-15 12:16:49 +02:00
|
|
|
if ((gameweek < 7) & (season==s1)):
|
|
|
|
try:
|
|
|
|
t1 = points2017[team1]
|
|
|
|
except:
|
|
|
|
t1 = 35
|
|
|
|
try:
|
|
|
|
t2 = points2017[team2]
|
|
|
|
except:
|
|
|
|
t2 = 35
|
|
|
|
points = t1 - t2
|
|
|
|
|
|
|
|
elif ((gameweek < 7) & (season==s2)):
|
|
|
|
try:
|
|
|
|
t1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == 37) & (teams['Season'] == s1)].Points.values[0]
|
|
|
|
except:
|
|
|
|
t1 = 35
|
|
|
|
try:
|
|
|
|
t2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == 37) & (teams['Season'] == s1)].Points.values[0]
|
|
|
|
except:
|
|
|
|
t2 = 35
|
|
|
|
points = t1 - t2
|
|
|
|
else:
|
|
|
|
points = temp_1 - temp_2
|
|
|
|
#0.365234375
|
2020-06-04 19:21:01 +02:00
|
|
|
|
|
|
|
temp = teams.loc[ (teams['Team'] == team1) & (teams['Gameweek'] == gameweek)].Result.values[0]
|
|
|
|
ground_truth = 0
|
|
|
|
if(temp == 'W'):
|
|
|
|
ground_truth = -1
|
|
|
|
elif(temp == 'D'):
|
|
|
|
ground_truth = 0
|
|
|
|
else:
|
|
|
|
ground_truth = 1
|
2020-06-15 12:16:49 +02:00
|
|
|
matches_input.append([form_1, form_2, points, xGform_1, xGform_2, ground_truth])
|
2020-06-04 19:21:01 +02:00
|
|
|
|
|
|
|
p = FCLParser() # Create the parser
|
|
|
|
p.read_fcl_file('worker.fcl')
|
|
|
|
|
|
|
|
cs1 = ctrl.ControlSystem(p.rules)
|
|
|
|
module = ctrl.ControlSystemSimulation(cs1)
|
2020-06-04 21:29:51 +02:00
|
|
|
predictions = []
|
2020-06-10 10:28:41 +02:00
|
|
|
for i in range(0,matches.shape[0]):
|
2020-06-04 19:21:01 +02:00
|
|
|
module.input['form1'] = matches_input[i][0]
|
|
|
|
module.input['form2'] = matches_input[i][1]
|
2020-06-10 11:29:47 +02:00
|
|
|
module.input['points'] = matches_input[i][2]
|
2020-06-15 12:16:49 +02:00
|
|
|
module.input['xGform1'] = matches_input[i][3]
|
|
|
|
module.input['xGform2'] = matches_input[i][4]
|
2020-06-04 19:21:01 +02:00
|
|
|
module.compute()
|
2020-06-04 21:29:51 +02:00
|
|
|
x = module.output['result']
|
2020-06-09 17:11:27 +02:00
|
|
|
x = float("{:.4f}".format(x))
|
|
|
|
|
2020-06-10 11:29:47 +02:00
|
|
|
#y = int(round(x))
|
|
|
|
if x > 0.2:
|
|
|
|
y = 1
|
|
|
|
elif x < -0.2:
|
|
|
|
y = -1
|
|
|
|
else:
|
|
|
|
y = 0
|
2020-06-04 21:29:51 +02:00
|
|
|
predictions.append(y)
|
2020-06-15 12:16:49 +02:00
|
|
|
print("|FCL: " +str(x) + "|ROUND: " + str(y) + "|GROUND: " + str(matches_input[i][5]) + "|PKT DIFFERENCE: " + str(matches_input[i][2])+'|')
|
2020-06-04 21:29:51 +02:00
|
|
|
|
|
|
|
num = 0
|
|
|
|
cor = 0
|
2020-06-10 10:28:41 +02:00
|
|
|
for i in range(0,matches.shape[0]):
|
2020-06-15 12:16:49 +02:00
|
|
|
if(predictions[i]==matches_input[i][5]):
|
2020-06-04 21:29:51 +02:00
|
|
|
cor+=1
|
|
|
|
num+=1
|
|
|
|
else:
|
|
|
|
num+=1
|
|
|
|
print(float(cor/num))
|