From cd40e018aeb50e3d2e24ba2b0c9344c0e82e4636 Mon Sep 17 00:00:00 2001 From: s460941 Date: Thu, 4 Jun 2020 21:29:51 +0200 Subject: [PATCH] baseline --- .idea/vcs.xml | 6 ++++++ .idea/workspace.xml | 38 +++++++++++++++++++++++++++++++++++++- main.py | 22 ++++++++++++++++++---- worker.fcl | 29 ++++++++++++++++------------- 4 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 21a1a14..027a059 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ - + + + + + + + + + @@ -72,4 +81,31 @@ + + + + + + + + file://$PROJECT_DIR$/main.py + 39 + + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py index b3ec488..bc1682f 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ matches = pd.read_csv('matches_list.csv') not_in_df = ['Miedź Legnica','Zagłębie Sosnowiec'] matches_input = [] -for i in range(25,150): +for i in range(0,293): team1 = matches['Team1'][i][:-1] team2 = matches['Team2'][i][1:-1] gameweek = matches['Gameweek'][i] @@ -36,9 +36,23 @@ p.read_fcl_file('worker.fcl') cs1 = ctrl.ControlSystem(p.rules) module = ctrl.ControlSystemSimulation(cs1) -for i in range(50,75): +predictions = [] +for i in range(0,224): module.input['form1'] = matches_input[i][0] module.input['form2'] = matches_input[i][1] - module.input['points'] = matches_input[i][2] + #module.input['points'] = matches_input[i][2] module.compute() - print(str(module.output['result']) +": " + str(matches_input[i][3])) \ No newline at end of file + x = module.output['result'] + y = int(x + (x % (1 if x >= 0 else -1))) + predictions.append(y) + print(str(y) +": " + str(matches_input[i][3])) + +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)) diff --git a/worker.fcl b/worker.fcl index c030d50..e4998db 100644 --- a/worker.fcl +++ b/worker.fcl @@ -11,17 +11,17 @@ VAR_OUTPUT END_VAR FUZZIFY form1 - RANGE := (0.000 .. 5.000); - TERM bad := (1,1)(3,0); + RANGE := (-1.000 .. 5.000); + TERM bad := (1,1)(2,0); TERM avg := (1,0)(2,1)(3,1)(4,0); - TERM great := (3,0)(5,1); + TERM great := (4,0)(5,1); END_FUZZIFY FUZZIFY form2 - RANGE := (0.000 .. 5.000); - TERM bad := (1,1)(3,0); + RANGE := (-1.000 .. 5.000); + TERM bad := (1,1)(2,0); TERM avg := (1,0)(2,1)(3,1)(4,0); - TERM great := (3,0)(5,1); + TERM great := (4,0)(5,1); END_FUZZIFY FUZZIFY points @@ -46,13 +46,16 @@ RULEBLOCK ACCU : MAX; ACT : MIN; RULE 1 : if form1 is great and form2 is bad then result is home - RULE 2 : if form1 is bad and form2 is great then result is away - RULE 3 : if form1 is avg and form2 is avg then result is draw - RULE 4 : if form1 is great and form2 is great and points is low then result is draw - RULE 5 : if form1 is great and form2 is avg and points is avg then result is away - RULE 6 : if form1 is avg and form2 is avg and points is high then result is home - RULE 7 : if form1 is avg and form2 is avg and points is low then result is away - RULE 8 : if points is avg then result is away + RULE 2 : if form1 is great and form2 is avg then result is home + RULE 3 : if form1 is great and form2 is great then result is draw + + RULE 4 : if form1 is avg and form2 is bad then result is home + RULE 5 : if form1 is avg and form2 is avg then result is draw + RULE 6 : if form1 is avg and form2 is great then result is away + + RULE 7 : if form1 is bad and form2 is bad then result is draw + RULE 8 : if form1 is bad and form2 is avg then result is away + RULE 9 : if form1 is bad and form2 is great then result is away END_RULEBLOCK END_FUNCTION_BLOCK