This commit is contained in:
s460941 2020-06-16 14:15:16 +02:00
parent c146e7868d
commit f8a9580699
3 changed files with 156 additions and 146 deletions

View File

@ -3,7 +3,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0fc070d1-3753-43f5-b5e7-37c2bc110b95" name="Default Changelist" comment=""> <list default="true" id="0fc070d1-3753-43f5-b5e7-37c2bc110b95" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/worker.fcl" beforeDir="false" afterPath="$PROJECT_DIR$/worker.fcl" afterDir="false" /> <change beforePath="$PROJECT_DIR$/worker.fcl" beforeDir="false" afterPath="$PROJECT_DIR$/worker.fcl" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -90,22 +89,22 @@
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
<state x="291" y="120" key="#com.intellij.execution.impl.EditConfigurationsDialog/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1591713379914" /> <state x="291" y="120" key="#com.intellij.execution.impl.EditConfigurationsDialog/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1591713379914" />
<state width="1510" height="224" key="GridCell.Tab.0.bottom" timestamp="1592220349610"> <state width="1510" height="224" key="GridCell.Tab.0.bottom" timestamp="1592220492080">
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
<state width="1510" height="224" key="GridCell.Tab.0.bottom/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220349610" /> <state width="1510" height="224" key="GridCell.Tab.0.bottom/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220492080" />
<state width="1510" height="224" key="GridCell.Tab.0.center" timestamp="1592220349610"> <state width="1510" height="224" key="GridCell.Tab.0.center" timestamp="1592220492080">
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
<state width="1510" height="224" key="GridCell.Tab.0.center/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220349610" /> <state width="1510" height="224" key="GridCell.Tab.0.center/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220492080" />
<state width="1510" height="224" key="GridCell.Tab.0.left" timestamp="1592220349610"> <state width="1510" height="224" key="GridCell.Tab.0.left" timestamp="1592220492080">
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
<state width="1510" height="224" key="GridCell.Tab.0.left/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220349610" /> <state width="1510" height="224" key="GridCell.Tab.0.left/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220492080" />
<state width="1510" height="224" key="GridCell.Tab.0.right" timestamp="1592220349610"> <state width="1510" height="224" key="GridCell.Tab.0.right" timestamp="1592220492080">
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
<state width="1510" height="224" key="GridCell.Tab.0.right/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220349610" /> <state width="1510" height="224" key="GridCell.Tab.0.right/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1592220492080" />
<state width="1510" height="207" key="GridCell.Tab.1.bottom" timestamp="1592220319922"> <state width="1510" height="207" key="GridCell.Tab.1.bottom" timestamp="1592220319922">
<screen x="67" y="27" width="1533" height="873" /> <screen x="67" y="27" width="1533" height="873" />
</state> </state>
@ -132,25 +131,6 @@
<state x="376" y="181" width="904" height="562" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1591723368763" /> <state x="376" y="181" width="904" height="562" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/67.27.1533.873/1600.0.1920.1080@67.27.1533.873" timestamp="1591723368763" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>119</line>
<option name="timeStamp" value="24" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>120</line>
<option name="timeStamp" value="26" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>121</line>
<option name="timeStamp" value="27" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager> <watches-manager>
<configuration name="PythonConfigurationType"> <configuration name="PythonConfigurationType">
<watch expression="not_in_df" /> <watch expression="not_in_df" />

260
main.py
View File

@ -2,131 +2,163 @@ from fcl_parser import FCLParser
import skfuzzy.control as ctrl import skfuzzy.control as ctrl
import pandas as pd import pandas as pd
s1 = '2018/2019'
s2 = '2019/2020'
teams = pd.read_csv('teams_list.csv')
matches = pd.read_csv('matches_list.csv')
not_in_df = ['Podbeskidzie'] def test():
matches_input = [] s1 = '2018/2019'
for i in range(0,matches.shape[0]): s2 = '2019/2020'
team1 = matches['Team1'][i][:-1] teams = pd.read_csv('teams_list.csv')
team2 = matches['Team2'][i][1:-1] matches = pd.read_csv('matches_list.csv')
gameweek = matches['Gameweek'][i]
season = matches['Season'][i]
points2017 = { not_in_df = ['Podbeskidzie']
"Legia Warszawa": 70, matches_input = []
"Jagiellonia Białystok": 67, for i in range(0,matches.shape[0]):
"Lech Poznań": 60, team1 = matches['Team1'][i][:-1]
"Górnik Zabrze": 60, team2 = matches['Team2'][i][1:-1]
"Wisła Płock": 57, gameweek = matches['Gameweek'][i]
"Wisła Kraków": 55, season = matches['Season'][i]
"Zagłębie Lubin": 52,
"Korona Kielce": 49, points2017 = {
"Cracovia Kraków": 50, "Legia Warszawa": 70,
"Śląsk Wrocław": 50, "Jagiellonia Białystok": 67,
"Pogoń Szczecin": 45, "Lech Poznań": 60,
"Arka Gdynia": 43, "Górnik Zabrze": 60,
"Lechia Gdańsk": 39, "Wisła Płock": 57,
"Piast Gliwice": 37, "Wisła Kraków": 55,
"Miedź Legnica": 35, "Zagłębie Lubin": 52,
"Zagłębie Sosnowiec": 35, "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,
}
if((team1 not in not_in_df) and (team2 not in not_in_df)): if((team1 not in not_in_df) and (team2 not in not_in_df)):
try:
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]
except:
print(team1 + team2 + str(gameweek))
if ((gameweek < 7) & (season==s1)):
try: try:
t1 = points2017[team1]
except:
t1 = 35
try:
t2 = points2017[team2]
except:
t2 = 35
points = t1 - t2
elif ((gameweek < 7) & (season==s2)): form_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Form.values[0]
try: temp_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Points.values[0]
t1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == 37) & (teams['Season'] == s1)].Points.values[0] xGform_1 = teams.loc[(teams['Team'] == team1) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].xGform.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
temp = teams.loc[ (teams['Team'] == team1) & (teams['Gameweek'] == gameweek)].Result.values[0] form_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Form.values[0]
ground_truth = 0 temp_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].Points.values[0]
if(temp == 'W'): xGform_2 = teams.loc[(teams['Team'] == team2) & (teams['Gameweek'] == gameweek) & (teams['Season'] == season)].xGform.values[0]
ground_truth = -1
elif(temp == 'D'): except:
print(team1 + team2 + str(gameweek))
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
temp = teams.loc[ (teams['Team'] == team1) & (teams['Gameweek'] == gameweek)].Result.values[0]
ground_truth = 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, xGform_1, xGform_2, ground_truth])
p = FCLParser() # Create the parser
p.read_fcl_file('C:\Studia\LSR-master\lsr\worker.fcl')
cs1 = ctrl.ControlSystem(p.rules)
module = ctrl.ControlSystemSimulation(cs1)
predictions = []
for i in range(0,matches.shape[0]):
module.input['form1'] = matches_input[i][0]
module.input['form2'] = matches_input[i][1]
module.input['points'] = matches_input[i][2]
module.input['xGform1'] = matches_input[i][3]
module.input['xGform2'] = matches_input[i][4]
module.compute()
x = module.output['result']
x = float("{:.4f}".format(x))
#y = int(round(x))
if x > 0.1:
y = 1
elif x < -0.1:
y = -1
else: else:
ground_truth = 1 y = 0
matches_input.append([form_1, form_2, points, xGform_1, xGform_2, ground_truth]) predictions.append(y)
print("|FCL: " +str(x) + "|ROUND: " + str(y) + "|GROUND: " + str(matches_input[i][5]) + "|PKT DIFFERENCE: " + str(matches_input[i][2])+'|')
p = FCLParser() # Create the parser num = 0
p.read_fcl_file('worker.fcl') cor = 0
home_count = 0
draw_count = 0
away_count = 0
cs1 = ctrl.ControlSystem(p.rules) for i in range(0,matches.shape[0]):
module = ctrl.ControlSystemSimulation(cs1) if (matches_input[i][5] == -1): home_count+=1
predictions = [] if (matches_input[i][5] == 0): draw_count += 1
for i in range(0,matches.shape[0]): if (matches_input[i][5] == 1): away_count += 1
module.input['form1'] = matches_input[i][0] if(predictions[i]==matches_input[i][5]):
module.input['form2'] = matches_input[i][1] cor+=1
module.input['points'] = matches_input[i][2] num+=1
module.input['xGform1'] = matches_input[i][3] else:
module.input['xGform2'] = matches_input[i][4] num+=1
module.compute() from collections import Counter
x = module.output['result'] print("Predictions: " + str(Counter(predictions).keys()))
x = float("{:.4f}".format(x)) print("Predictions: " + str(Counter(predictions).values()))
print("GT: " + str(home_count) + " " + str(draw_count) + " " + str(away_count))
print(float(cor/num))
#y = int(round(x)) if __name__ == "__main__":
if x > 0.1: while True:
y = 1 p = FCLParser() # Create the parser
elif x < -0.1: p.read_fcl_file('C:\Studia\LSR-master\lsr\worker.fcl')
y = -1
else:
y = 0
predictions.append(y)
print("|FCL: " +str(x) + "|ROUND: " + str(y) + "|GROUND: " + str(matches_input[i][5]) + "|PKT DIFFERENCE: " + str(matches_input[i][2])+'|')
num = 0 cs1 = ctrl.ControlSystem(p.rules)
cor = 0 module = ctrl.ControlSystemSimulation(cs1)
home_count = 0 print("Wpisz 'test' albo dodaj wartości (po przecinku): forma1, forma2, punkty, xGforma1, xGforma2")
draw_count = 0 command = input()
away_count = 0 if command == "test":
test()
else:
values = command.split(sep=',')
module.input['form1'] = float(values[0])
module.input['form2'] = float(values[1])
module.input['points'] = float(values[2])
module.input['xGform1'] = float(values[3])
module.input['xGform2'] = float(values[4])
module.compute()
x = module.output['result']
x = float("{:.4f}".format(x))
print(x)
if x > 0.1:
print("Wygra drużyna 2")
elif x < -0.1:
print("Wygra drużyna 1")
else:
print("Będzie remis")
for i in range(0,matches.shape[0]):
if (matches_input[i][5] == -1): home_count+=1
if (matches_input[i][5] == 0): draw_count += 1
if (matches_input[i][5] == 1): away_count += 1
if(predictions[i]==matches_input[i][5]):
cor+=1
num+=1
else:
num+=1
from collections import Counter
print("Predictions: " + str(Counter(predictions).keys()))
print("Predictions: " + str(Counter(predictions).values()))
print("GT: " + str(home_count) + " " + str(draw_count) + " " + str(away_count))
print(float(cor/num))

View File

@ -60,8 +60,7 @@ RULEBLOCK
ACCU : MAX; ACCU : MAX;
ACT : MIN; ACT : MIN;
// 0.365234375
//tego nic nie daje
RULE 0 : if form1 is great and form2 is bad then result is home RULE 0 : if form1 is great and form2 is bad then result is home
// rozbicie home // rozbicie home
RULE 3 : if form1 is great and form2 is avg and points is low then result is draw RULE 3 : if form1 is great and form2 is avg and points is low then result is draw
@ -73,7 +72,7 @@ RULEBLOCK
RULE 7 : if form1 is great and form2 is great and points is avg then result is home RULE 7 : if form1 is great and form2 is great and points is avg then result is home
RULE 8 : if form1 is great and form2 is great and points is high then result is home RULE 8 : if form1 is great and form2 is great and points is high then result is home
//rozbicie tego jednego home coś dało //rozbicie home
RULE 31 : if form1 is avg and form2 is bad and points is low then result is draw RULE 31 : if form1 is avg and form2 is bad and points is low then result is draw
RULE 32 : if form1 is avg and form2 is bad and points is avg then result is home RULE 32 : if form1 is avg and form2 is bad and points is avg then result is home
RULE 33 : if form1 is avg and form2 is bad and points is high then result is home RULE 33 : if form1 is avg and form2 is bad and points is high then result is home
@ -92,7 +91,6 @@ RULEBLOCK
RULE 62 : if form1 is bad and form2 is bad and points is avg then result is draw RULE 62 : if form1 is bad and form2 is bad and points is avg then result is draw
RULE 63 : if form1 is bad and form2 is bad and points is high then result is home RULE 63 : if form1 is bad and form2 is bad and points is high then result is home
// to rozbicie nic nie daje
RULE 66 : if form1 is bad and form2 is avg then result is away RULE 66 : if form1 is bad and form2 is avg then result is away
// rozbicie away // rozbicie away
RULE 67 : if form1 is bad and form2 is great and points is low then result is away RULE 67 : if form1 is bad and form2 is great and points is low then result is away