goals prediction
This commit is contained in:
parent
25ad949b3a
commit
278b6fe6b0
@ -1,5 +1,6 @@
|
||||
package com.resultprediction.polishekstraklasa.Predictions;
|
||||
|
||||
import com.resultprediction.polishekstraklasa.Predictions.model.match.Match;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.sourceforge.jFuzzyLogic.FIS;
|
||||
@ -27,12 +28,11 @@ public class Prediction {
|
||||
variables.add(variable);
|
||||
}
|
||||
|
||||
|
||||
public static int make() {
|
||||
public static int makeGoals() {
|
||||
|
||||
// Load from 'FCL' file
|
||||
File file = new File("Prediction.fcl");
|
||||
String fileName = file.getAbsolutePath().replace("Prediction.fcl", "src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\Prediction.fcl");
|
||||
File file = new File("PredictionGoals.fcl");
|
||||
String fileName = file.getAbsolutePath().replace("PredictionGoals.fcl", "src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\PredictionGoals.fcl");
|
||||
FIS fis = FIS.load(fileName, true);
|
||||
|
||||
if (fis == null) {
|
||||
@ -61,20 +61,90 @@ public class Prediction {
|
||||
// Drukuje reguly
|
||||
//System.out.println(fis);
|
||||
variables.clear();
|
||||
double malo = Double.valueOf(fis.getVariable("goals").getMembership("malo"));
|
||||
double srednio = Double.valueOf(fis.getVariable("goals").getMembership("srednio"));
|
||||
double duzo = Double.valueOf(fis.getVariable("goals").getMembership("duzo"));
|
||||
if (malo >= srednio && malo >= duzo) {
|
||||
System.out.println("PREDICTION : " + malo + "goals\n\n");
|
||||
if (malo >= 0.8)
|
||||
return 0;
|
||||
if (malo <= 0.2)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
if (srednio > malo && srednio > duzo) {
|
||||
System.out.println("PREDICTION : " + srednio + "goals\n\n");
|
||||
if (srednio >= 0.7)
|
||||
return 3;
|
||||
if (srednio < 0.7 && malo > 0)
|
||||
return 2;
|
||||
if (srednio < 0.4 && duzo > 0)
|
||||
return 4;
|
||||
return 3;
|
||||
}
|
||||
else {
|
||||
System.out.println("PREDICTION : " + duzo + "goals\n\n");
|
||||
if (duzo >= 0.7)
|
||||
return 5;
|
||||
if (duzo >= 0.4)
|
||||
return 4;
|
||||
return 3;
|
||||
}
|
||||
/*
|
||||
*
|
||||
DEFUZZIFY goals
|
||||
TERM malo := (0,1) (0.5, 1) (2,0);
|
||||
TERM srednio := (1,0) (2.5 ,1) (4,0);
|
||||
TERM duzo := (3,0) (5, 1) (5,1);
|
||||
DEFAULT := 1;
|
||||
END_DEFUZZIFY*/
|
||||
}
|
||||
|
||||
|
||||
public static Match make(Match match) {
|
||||
|
||||
// Load from 'FCL' file
|
||||
File file = new File("Prediction.fcl");
|
||||
String fileName = file.getAbsolutePath().replace("Prediction.fcl", "src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\Prediction.fcl");
|
||||
FIS fis = FIS.load(fileName, true);
|
||||
|
||||
if (fis == null) {
|
||||
System.err.println("Can't load file: '" + fileName + "'");
|
||||
System.exit(1);
|
||||
}
|
||||
FunctionBlock functionBlock = fis.getFunctionBlock(null);
|
||||
|
||||
for (com.resultprediction.polishekstraklasa.Predictions.Variable variable : variables){
|
||||
fis.setVariable(variable.getName(), variable.getValue());
|
||||
}
|
||||
|
||||
fis.evaluate();
|
||||
Variable prediction = functionBlock.getVariable("prediction");
|
||||
|
||||
|
||||
double draw = Double.valueOf(fis.getVariable("prediction").getMembership("remis"));
|
||||
double team1 = Double.valueOf(fis.getVariable("prediction").getMembership("team1"));
|
||||
double team2 = Double.valueOf(fis.getVariable("prediction").getMembership("team2"));
|
||||
|
||||
int goals = makeGoals();
|
||||
if (goals > 0)
|
||||
match.setPredicted_goals((Double.valueOf(goals) - 1.5D) + "");
|
||||
else
|
||||
match.setPredicted_goals(goals + "");
|
||||
|
||||
variables.clear();
|
||||
if (draw >= team1 && draw >= team2) {
|
||||
System.out.println("PREDICTION : DRAW\n\n");
|
||||
return 0;
|
||||
match.setPredicted_result(0);
|
||||
}
|
||||
if (team1 > draw && team1 > team2) {
|
||||
System.out.println("PREDICTION : team1\n\n");
|
||||
return 1;
|
||||
match.setPredicted_result(1);
|
||||
}
|
||||
else {
|
||||
System.out.println("PREDICTION : team2\n\n");
|
||||
return 2;
|
||||
match.setPredicted_result(2);
|
||||
}
|
||||
return match;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ public class MatchDTO {
|
||||
|
||||
private Long id;
|
||||
private String result;
|
||||
private Integer goals;
|
||||
private String predictedResult;
|
||||
private String predictedGoals;
|
||||
private String season;
|
||||
|
@ -134,7 +134,8 @@ public class PredictService {
|
||||
Prediction.addToList(new Variable("team2Form", calculatedTeam2Form));
|
||||
System.out.println(match.getTeamsMatchStatistics1().getGoals() + ":" + match.getTeamsMatchStatistics1().getGoals_lost());
|
||||
|
||||
match.setPredicted_result(Prediction.make());
|
||||
match = Prediction.make(match);
|
||||
//match.setPredicted_result(Prediction.make());
|
||||
matchRepository.save(match);
|
||||
|
||||
//int winner = whoWillWin(calculatedTeam1Form, calculatedTeam2Form);
|
||||
@ -377,7 +378,7 @@ public class PredictService {
|
||||
predictedResult = match.getTeamsMatchStatistics2().getTeam().getName();
|
||||
else
|
||||
predictedResult = "X";
|
||||
matchDTOS.add(new MatchDTO(match.getId(), result, predictedResult, match.getPredicted_goals(), match.getSeason().toString(), match.getDate().toString(), match.getTeamsMatchStatistics1().getTeam().getName(), match.getTeamsMatchStatistics2().getTeam().getName()));
|
||||
matchDTOS.add(new MatchDTO(match.getId(), result,match.getTeamsMatchStatistics1().getGoals() + match.getTeamsMatchStatistics1().getGoals_lost() ,predictedResult, match.getPredicted_goals(), match.getSeason().toString(), match.getDate().toString(), match.getTeamsMatchStatistics1().getTeam().getName(), match.getTeamsMatchStatistics2().getTeam().getName()));
|
||||
}
|
||||
return matchDTOS;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"EkstraklasaPrzewidywanieWynikow": {
|
||||
@ -129,6 +129,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}},
|
||||
"defaultProject": "EkstraklasaPrzewidywanieWynikow"
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "EkstraklasaPrzewidywanieWynikow",
|
||||
"cli": {
|
||||
"analytics": "b8d721fd-92c8-4703-b9fe-f499ce606326"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user