2020-06-04 19:21:01 +02:00
|
|
|
from fcl_parser import FCLParser
|
|
|
|
import skfuzzy.control as ctrl
|
|
|
|
import pandas as pd
|
|
|
|
|
2020-06-09 17:11:27 +02:00
|
|
|
|
|
|
|
def myround(x):
|
|
|
|
r = 0
|
|
|
|
if (x < 0): r = x // 1
|
|
|
|
if (x > 0): r = int(round(x))
|
|
|
|
return r
|
|
|
|
|
2020-06-04 19:21:01 +02:00
|
|
|
teams = pd.read_csv('teams_list.csv')
|
|
|
|
matches = pd.read_csv('matches_list.csv')
|
|
|
|
|
|
|
|
not_in_df = ['Miedź Legnica','Zagłębie Sosnowiec']
|
|
|
|
|
|
|
|
matches_input = []
|
2020-06-04 21:29:51 +02:00
|
|
|
for i in range(0,293):
|
2020-06-04 19:21:01 +02:00
|
|
|
team1 = matches['Team1'][i][:-1]
|
|
|
|
team2 = matches['Team2'][i][1:-1]
|
|
|
|
gameweek = matches['Gameweek'][i]
|
|
|
|
if((team1 not in not_in_df) and (team2 not in not_in_df)):
|
|
|
|
form_1 = teams.loc[ (teams['Team'] == team1) & (teams['Gameweek'] == gameweek)].Form.values[0]
|
|
|
|
temp_1 = teams.loc[ (teams['Team'] == team1) & (teams['Gameweek'] == gameweek)].Points.values[0]
|
|
|
|
form_2 = teams.loc[ (teams['Team'] == team2) & (teams['Gameweek'] == gameweek)].Form.values[0]
|
|
|
|
temp_2 = teams.loc[ (teams['Team'] == team2) & (teams['Gameweek'] == gameweek)].Points.values[0]
|
|
|
|
|
|
|
|
points = temp_1 - temp_2
|
|
|
|
|
|
|
|
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
|
|
|
|
matches_input.append([form_1, form_2, points, ground_truth])
|
|
|
|
|
|
|
|
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 = []
|
|
|
|
for i in range(0,224):
|
2020-06-04 19:21:01 +02:00
|
|
|
module.input['form1'] = matches_input[i][0]
|
|
|
|
module.input['form2'] = matches_input[i][1]
|
2020-06-04 21:29:51 +02:00
|
|
|
#module.input['points'] = matches_input[i][2]
|
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))
|
|
|
|
|
|
|
|
#y = int(x + (x % (1 if x >= 0 else -1)))
|
|
|
|
#y = myround(x)
|
|
|
|
y = int(round(x))
|
2020-06-04 21:29:51 +02:00
|
|
|
predictions.append(y)
|
2020-06-09 17:11:27 +02:00
|
|
|
#print(str(y) +": " + str(matches_input[i][3]))
|
|
|
|
print("FCL: " +str(x) + " ROUND: " + str(y) + " GROUND: " + str(matches_input[i][3]))
|
2020-06-04 21:29:51 +02:00
|
|
|
|
|
|
|
num = 0
|
|
|
|
cor = 0
|
|
|
|
for i in range(0,224):
|
|
|
|
if(predictions[i]==matches_input[i][3]):
|
|
|
|
cor+=1
|
|
|
|
num+=1
|
|
|
|
else:
|
|
|
|
num+=1
|
|
|
|
print(float(cor/num))
|