zmiany
This commit is contained in:
parent
3ba3aafd43
commit
88b838b968
@ -19,21 +19,21 @@ VAR_OUTPUT
|
||||
END_VAR
|
||||
|
||||
FUZZIFY goalkeeperForm
|
||||
TERM zla := (50, 1) (70, 0);
|
||||
TERM zla := (0, 1)(50, 1) (70, 0);
|
||||
TERM dobra := (70, 0) (80,1) (90,0);
|
||||
TERM znakomita := (90, 0) (100, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY formationAgainstForm
|
||||
TERM zla := (30, 1) (40, 0);
|
||||
TERM zla := (0, 0)(30, 1) (40, 0);
|
||||
TERM przecietna := (35, 0) (50,1) (70,0);
|
||||
TERM dobra := (70, 0) (100, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY shootsOnTargetAverage
|
||||
TERM malo := (2, 1) (4, 0);
|
||||
TERM malo := (0, 1)(2, 1) (4, 0);
|
||||
TERM przecietnie := (3, 0) (5,1) (7,0);
|
||||
TERM duzo := (7, 0) (10, 1);
|
||||
TERM duzo := (7, 0) (10, 1)(30, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY possessionAverage
|
||||
@ -57,7 +57,7 @@ END_FUZZIFY
|
||||
FUZZIFY redCardsAverage
|
||||
TERM malo := (0, 1) (0.1, 0);
|
||||
TERM przecietnie := (0.1, 0) (0.2,1) (0.3,0);
|
||||
TERM duzo := (0.3, 0) (0.4, 1);
|
||||
TERM duzo := (0.3, 0) (0.4, 1)(1, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY penaltyAreaEntriesAverage
|
||||
@ -69,7 +69,7 @@ END_FUZZIFY
|
||||
FUZZIFY penaltiesAverage
|
||||
TERM malo := (0, 1) (0.1, 0);
|
||||
TERM przecietnie := (0.1, 0) (0.2,1) (0.3,0);
|
||||
TERM duzo := (0.3, 0) (0.4, 1);
|
||||
TERM duzo := (0.3, 0) (0.4, 1) (1 , 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY lastMatchesResultAverage
|
||||
@ -102,7 +102,7 @@ RULEBLOCK No1
|
||||
|
||||
RULE 1: IF goalkeeperForm IS zla AND possessionAverage IS malo THEN prediction IS przegrana;
|
||||
RULE 2: IF possessionAverage IS duzo AND shootsOnTargetAverage IS duzo THEN prediction IS wygrana;
|
||||
RULE 3: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis;
|
||||
RULE 3: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie OR lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis;
|
||||
END_RULEBLOCK
|
||||
|
||||
END_FUNCTION_BLOCK
|
||||
|
@ -58,7 +58,7 @@ public class Prediction {
|
||||
JFuzzyChart.get().chart(prediction, prediction.getDefuzzifier(), true);
|
||||
|
||||
// Drukuje reguly
|
||||
System.out.println(fis);
|
||||
//System.out.println(fis);
|
||||
System.out.println("Prediction:" + fis.getVariable("prediction").getValue());
|
||||
Process proc = null;
|
||||
try {
|
||||
|
@ -17,5 +17,5 @@ public class Variable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Integer value;
|
||||
private Double value;
|
||||
}
|
||||
|
@ -69,70 +69,70 @@ public class PredictService {
|
||||
Team team1 = match.getTeamsMatchStatistics1().getTeam();
|
||||
List<Match> previousMatchesTeam1 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeOrderByDateDesc(team1, match.getSeason(), match.getDate(), team1, match.getSeason(), match.getDate());
|
||||
|
||||
int goalkeeperForm1;
|
||||
double goalkeeperForm1;
|
||||
if (howManyPastForGoalkeeperForm > previousMatchesTeam1.size()){
|
||||
goalkeeperForm1 = calculateGoalkeeperForm(previousMatchesTeam1, team1);
|
||||
} else {
|
||||
goalkeeperForm1 = calculateGoalkeeperForm(previousMatchesTeam1.subList(0, howManyPastForGoalkeeperForm - 1), team1);
|
||||
}
|
||||
Prediction.addToList(new Variable("goalkeeperForm1", goalkeeperForm1));
|
||||
Prediction.addToList(new Variable("goalkeeperForm", goalkeeperForm1));
|
||||
System.out.println("Team1 Goalkeeper form = " + goalkeeperForm1);
|
||||
|
||||
List<Match> formationMatchesTeam1 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeAndTeamsMatchStatistics2FormationOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeAndTeamsMatchStatistics1FormationOrderByDateDesc(team1, match.getSeason(), match.getDate(), match.getTeamsMatchStatistics2().getFormation(), team1, match.getSeason(), match.getDate(), match.getTeamsMatchStatistics2().getFormation());
|
||||
int formationAgainstForm1;
|
||||
double formationAgainstForm1;
|
||||
if (howManyPastForFormationAgainstForm > formationMatchesTeam1.size()){
|
||||
formationAgainstForm1 = calculateFormationForm(formationMatchesTeam1, team1);
|
||||
} else {
|
||||
formationAgainstForm1 = calculateFormationForm(formationMatchesTeam1.subList(0, howManyPastForFormationAgainstForm - 1), team1);
|
||||
}
|
||||
Prediction.addToList(new Variable("formationAgainstForm1", formationAgainstForm1));
|
||||
Prediction.addToList(new Variable("formationAgainstForm", formationAgainstForm1));
|
||||
System.out.println("Team1 Formation against form = " + formationAgainstForm1);
|
||||
|
||||
List<Match> teamFormMatches1 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeOrderByDateDesc(team1, match.getSeason(), match.getDate(), team1, match.getSeason(), match.getDate());
|
||||
int teamForm1;
|
||||
double teamForm1;
|
||||
if (howManyLastMatchesResult > teamFormMatches1.size()){
|
||||
teamForm1 = calculateTeamForm(teamFormMatches1, team1, match.getTeamsMatchStatistics2().getTeam(), match.getDate(),"1");
|
||||
teamForm1 = calculateTeamForm(teamFormMatches1, team1, match.getTeamsMatchStatistics2().getTeam(), match.getDate());
|
||||
} else {
|
||||
teamForm1 = calculateTeamForm(teamFormMatches1.subList(0, howManyLastMatchesResult - 1), team1, match.getTeamsMatchStatistics2().getTeam(), match.getDate(),"1");
|
||||
teamForm1 = calculateTeamForm(teamFormMatches1.subList(0, howManyLastMatchesResult - 1), team1, match.getTeamsMatchStatistics2().getTeam(), match.getDate());
|
||||
}
|
||||
System.out.println("Team1 Form = " + teamForm1);
|
||||
|
||||
int calculatedTeam1Form = ((goalkeeperForm1 * gooalkeeperFormValue) + (formationAgainstForm1 * formationFormValue) + (teamForm1 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
||||
double calculatedTeam1Form = ((goalkeeperForm1 * gooalkeeperFormValue) + (formationAgainstForm1 * formationFormValue) + (teamForm1 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
||||
System.out.println("Team1 Calculated Form = " + calculatedTeam1Form);
|
||||
|
||||
Prediction.make();
|
||||
|
||||
Team team2 = match.getTeamsMatchStatistics2().getTeam();
|
||||
List<Match> previousMatchesTeam2 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeOrderByDateDesc(team2, match.getSeason(), match.getDate(), team2, match.getSeason(), match.getDate());
|
||||
|
||||
int goalkeeperForm2;
|
||||
double goalkeeperForm2;
|
||||
if (howManyPastForGoalkeeperForm > previousMatchesTeam2.size()){
|
||||
goalkeeperForm2 = calculateGoalkeeperForm(previousMatchesTeam2, team1);
|
||||
} else {
|
||||
goalkeeperForm2 = calculateGoalkeeperForm(previousMatchesTeam2.subList(0, howManyPastForGoalkeeperForm - 1), team1);
|
||||
}
|
||||
Prediction.addToList(new Variable("goalkeeperForm2", goalkeeperForm2));
|
||||
Prediction.addToList(new Variable("goalkeeperForm", goalkeeperForm2));
|
||||
System.out.println("Team2 Goalkeeper form = " + goalkeeperForm2);
|
||||
|
||||
List<Match> formationMatchesTeam2 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeAndTeamsMatchStatistics2FormationOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeAndTeamsMatchStatistics1FormationOrderByDateDesc(team2, match.getSeason(), match.getDate(), match.getTeamsMatchStatistics1().getFormation(), team2, match.getSeason(), match.getDate(), match.getTeamsMatchStatistics1().getFormation());
|
||||
int formationAgainstForm2;
|
||||
double formationAgainstForm2;
|
||||
if (howManyPastForFormationAgainstForm > formationMatchesTeam2.size()){
|
||||
formationAgainstForm2 = calculateFormationForm(formationMatchesTeam2, team2);
|
||||
} else {
|
||||
formationAgainstForm2 = calculateFormationForm(formationMatchesTeam2.subList(0, howManyPastForFormationAgainstForm - 1), team2);
|
||||
}
|
||||
Prediction.addToList(new Variable("formationAgainstForm2", formationAgainstForm2));
|
||||
Prediction.addToList(new Variable("formationAgainstForm", formationAgainstForm2));
|
||||
System.out.println("Team2 Formation against form = " + formationAgainstForm2);
|
||||
|
||||
|
||||
List<Match> teamFormMatches2 = matchRepository.findTop10ByTeamsMatchStatistics1TeamAndSeasonAndDateBeforeOrTeamsMatchStatistics2TeamAndSeasonAndDateBeforeOrderByDateDesc(team2, match.getSeason(), match.getDate(), team2, match.getSeason(), match.getDate());
|
||||
int teamForm2;
|
||||
double teamForm2;
|
||||
if (howManyLastMatchesResult > teamFormMatches2.size()){
|
||||
teamForm2 = calculateTeamForm(teamFormMatches2, team2, team1, match.getDate(),"2");
|
||||
teamForm2 = calculateTeamForm(teamFormMatches2, team2, team1, match.getDate());
|
||||
} else {
|
||||
teamForm2 = calculateTeamForm(teamFormMatches2.subList(0, howManyLastMatchesResult - 1), team2, team1, match.getDate(),"2");
|
||||
teamForm2 = calculateTeamForm(teamFormMatches2.subList(0, howManyLastMatchesResult - 1), team2, team1, match.getDate());
|
||||
}
|
||||
System.out.println("Team2 Form = " + teamForm2);
|
||||
int calculatedTeam2Form = ((goalkeeperForm2 * gooalkeeperFormValue) + (formationAgainstForm2 * formationFormValue) + (teamForm2 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
||||
double calculatedTeam2Form = ((goalkeeperForm2 * gooalkeeperFormValue) + (formationAgainstForm2 * formationFormValue) + (teamForm2 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
||||
System.out.println("Team2 Calculated Form = " + calculatedTeam2Form);
|
||||
System.out.println(match.getTeamsMatchStatistics1().getGoals() + ":" + match.getTeamsMatchStatistics1().getGoals_lost());
|
||||
|
||||
@ -161,19 +161,19 @@ public class PredictService {
|
||||
|
||||
}*/
|
||||
|
||||
private int calculateTeamForm(List<Match> matches, Team team, Team enemy, Date actualMatchDate, String nameForFuzzy) {
|
||||
private int calculateTeamForm(List<Match> matches, Team team, Team enemy, Date actualMatchDate) {
|
||||
if (matches.size() == 0)
|
||||
return 100;
|
||||
|
||||
int shootsOnTargetAverage = 0;
|
||||
int possessionAverage = 0;
|
||||
int goalsAverage = 0;
|
||||
int goalsLostAverage = 0;
|
||||
int redCardsAverage = 0;
|
||||
int penaltyAreaEntriesAverage = 0;
|
||||
int penaltiesAverage = 0;
|
||||
int lastMatchesResultAverage = 0;
|
||||
int lastMatchesResultBetweenAverage = 0;
|
||||
double shootsOnTargetAverage = 0;
|
||||
double possessionAverage = 0;
|
||||
double goalsAverage = 0;
|
||||
double goalsLostAverage = 0;
|
||||
double redCardsAverage = 0;
|
||||
double penaltyAreaEntriesAverage = 0;
|
||||
double penaltiesAverage = 0;
|
||||
double lastMatchesResultAverage = 0;
|
||||
double lastMatchesResultBetweenAverage = 0;
|
||||
|
||||
for (Match match : matches){
|
||||
if (match.getTeamsMatchStatistics1().getTeam().equals(team)){
|
||||
@ -250,20 +250,20 @@ public class PredictService {
|
||||
lastMatchesResultBetweenAverage = lastMatchesResultBetweenAverage / matchesBetween.size();
|
||||
else lastMatchesResultBetweenAverage = 0;
|
||||
|
||||
Prediction.addToList(new Variable("shootsOnTargetAverage" + nameForFuzzy, shootsOnTargetAverage));
|
||||
Prediction.addToList(new Variable("possessionAverage" + nameForFuzzy, possessionAverage));
|
||||
Prediction.addToList(new Variable("goalsAverage" + nameForFuzzy, goalsAverage));
|
||||
Prediction.addToList(new Variable("goalsLostAverage" + nameForFuzzy, goalsLostAverage));
|
||||
Prediction.addToList(new Variable("redCardsAverage" + nameForFuzzy, redCardsAverage));
|
||||
Prediction.addToList(new Variable("penaltyAreaEntriesAverage" + nameForFuzzy, penaltyAreaEntriesAverage));
|
||||
Prediction.addToList(new Variable("penaltiesAverage" + nameForFuzzy, penaltiesAverage));
|
||||
Prediction.addToList(new Variable("lastMatchesResultAverage" + nameForFuzzy, lastMatchesResultAverage));
|
||||
Prediction.addToList(new Variable("lastMatchesResultBetweenAverage" + nameForFuzzy, lastMatchesResultBetweenAverage));
|
||||
Prediction.addToList(new Variable("shootsOnTargetAverage", shootsOnTargetAverage));
|
||||
Prediction.addToList(new Variable("possessionAverage", possessionAverage));
|
||||
Prediction.addToList(new Variable("goalsAverage", goalsAverage));
|
||||
Prediction.addToList(new Variable("goalsLostAverage", goalsLostAverage));
|
||||
Prediction.addToList(new Variable("redCardsAverage", redCardsAverage));
|
||||
Prediction.addToList(new Variable("penaltyAreaEntriesAverage", penaltyAreaEntriesAverage));
|
||||
Prediction.addToList(new Variable("penaltiesAverage", penaltiesAverage));
|
||||
Prediction.addToList(new Variable("lastMatchesResultAverage", lastMatchesResultAverage));
|
||||
Prediction.addToList(new Variable("lastMatchesResultBetweenAverage", lastMatchesResultBetweenAverage));
|
||||
return calculateTeamStatsByAverages(shootsOnTargetAverage, possessionAverage, goalsAverage, goalsLostAverage, redCardsAverage, penaltyAreaEntriesAverage, penaltiesAverage, lastMatchesResultAverage, lastMatchesResultBetweenAverage, matches.size(), lastMatchesBetweenSize);
|
||||
}
|
||||
|
||||
|
||||
private int calculateTeamStatsByAverages(int shootsOnTargetAverage, int possessionAverage, int goalsAverage, int goalsLostAverage, int redCardsAverage, int penaltyAreaEntriesAverage, int penaltiesAverage, int lastMatchesResultAverage, int lastMatchesResultBetweenAverage, int howManyLastMatchesSize, int lastMatchesBetweenSize) {
|
||||
private int calculateTeamStatsByAverages(double shootsOnTargetAverage, double possessionAverage, double goalsAverage, double goalsLostAverage, double redCardsAverage, double penaltyAreaEntriesAverage, double penaltiesAverage, double lastMatchesResultAverage, double lastMatchesResultBetweenAverage, double howManyLastMatchesSize, double lastMatchesBetweenSize) {
|
||||
double fuzzyValueOfShootsOnTarget = fuzzyChecker(2,10, 10, shootsOnTargetAverage);
|
||||
double fuzzyValueOfPossession = fuzzyChecker(30,70, 70, possessionAverage);
|
||||
double fuzzyValueOfGoals = fuzzyChecker(1,3, 3, goalsAverage);
|
||||
@ -271,8 +271,8 @@ public class PredictService {
|
||||
double fuzzyValueOfRedCards = fuzzyChecker(0,0, 1, redCardsAverage);
|
||||
double fuzzyValueOfPenaltyAreaEntries = fuzzyChecker(10,25, 25, penaltyAreaEntriesAverage);
|
||||
double fuzzyValueOfPenalties = fuzzyChecker(0,1, 1, penaltiesAverage);
|
||||
double fuzzyValueOfLastMatchesResult = fuzzyChecker(0,howManyLastMatchesSize * 3, howManyLastMatchesSize * 3, lastMatchesResultAverage);
|
||||
double fuzzyValueOfLastMatchesResultBetween = fuzzyChecker(0,lastMatchesBetweenSize * 3, lastMatchesBetweenSize * 3, lastMatchesResultBetweenAverage);
|
||||
double fuzzyValueOfLastMatchesResult = fuzzyChecker(0,(int)howManyLastMatchesSize * 3, (int)howManyLastMatchesSize * 3, lastMatchesResultAverage);
|
||||
double fuzzyValueOfLastMatchesResultBetween = fuzzyChecker(0,(int)lastMatchesBetweenSize * 3, (int)lastMatchesBetweenSize * 3, lastMatchesResultBetweenAverage);
|
||||
|
||||
double teamForm = (fuzzyValueOfShootsOnTarget * shootsOnTargetValue) + (fuzzyValueOfPossession * possessionValue) + (fuzzyValueOfGoals * goalsValue) + (fuzzyValueOfGoalsLost * goalsLostValue) + (fuzzyValueOfRedCards * redCardsValue) + (fuzzyValueOfPenaltyAreaEntries * penaltyAreaEntriesValue) + (fuzzyValueOfPenalties * penaltiesValue) + (fuzzyValueOfLastMatchesResult * lastMatchesResultValue) + (fuzzyValueOfLastMatchesResultBetween * lastMatchesResultBetweenValue);
|
||||
teamForm = teamForm / (shootsOnTargetValue + possessionValue + goalsValue + goalsLostValue + redCardsValue + penaltyAreaEntriesValue + penaltiesValue + lastMatchesResultValue + lastMatchesResultBetweenValue);
|
||||
@ -315,7 +315,7 @@ public class PredictService {
|
||||
}
|
||||
|
||||
|
||||
private double fuzzyChecker(int a, int b, int c, int valueToCheck){
|
||||
private double fuzzyChecker(int a, int b, int c, double valueToCheck){
|
||||
if (a == b){
|
||||
if (valueToCheck <= a){
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user