This commit is contained in:
marcin-szczepanski 2020-05-24 17:05:03 +02:00
commit 510dd68881
3 changed files with 48 additions and 6 deletions

View File

@ -89,9 +89,9 @@ FUZZIFY lastMatchesResultBetweenAverage
END_FUZZIFY
DEFUZZIFY prediction
TERM przegrana := (-1,1) (0,0);
TERM remis := (-0.5,0) (0,1) (0.5,0);
TERM wygrana := (0,0) (1,1);
TERM przegrana := (0,1) (10,0);
TERM remis := (10,0) (15,1) (20,0);
TERM wygrana := (20,0) (30,1);
DEFAULT := 0;
END_DEFUZZIFY
@ -124,6 +124,26 @@ RULEBLOCK No1
RULE 21: IF shootsOnTargetAverage IS przecietnie AND goalsLostAverage IS duzo OR shootsOnTargetAverage IS przecietnie AND goalkeeperForm IS zla THEN prediction IS przegrana;
RULE 22: IF redCardsAverage IS przecietnie AND possessionAverage IS malo AND goalkeeperForm IS zla THEN prediction IS przegrana;
RULE 21: IF goalkeeperForm IS znakomita AND penaltiesAverage IS duzo OR goalkeeperForm IS dobra AND penaltiesAverage IS duzo THEN prediction IS wygrana;
RULE 22: IF shootsOnTargetAverage IS duzo AND possessionAverage IS duzo OR shootsOnTargetAverage IS przecietnie AND possessionAverage IS duzo THEN prediction IS wygrana;
RULE 23: IF lastMatchesResultAverage IS bardzo_dobrze THEN prediction IS wygrana;
RULE 24: IF penaltyAreaEntriesAverage IS czesto AND lastMatchesResultAverage IS dobrze OR penaltyAreaEntriesAverage IS czesto AND lastMatchesResultAverage IS przecietnie THEN prediction IS wygrana;
RULE 25: IF goalsAverage IS duzo AND goalsLostAverage is malo OR goalsAverage IS przecietnie AND goalsLostAverage is malo THEN prediction IS wygrana;
RULE 26: IF formationAgainstForm is dobra AND possessionAverage IS przecietnie OR formationAgainstForm is dobra AND possessionAverage IS duzo THEN prediction IS wygrana;
RULE 27: IF lastMatchesResultBetweenAverage IS bardzo_dobrze THEN prediction IS wygrana;
RULE 28: IF lastMatchesResultBetweenAverage IS dobrze AND lastMatchesResultAverage IS dobrze OR lastMatchesResultBetweenAverage IS przecietnie AND lastMatchesResultAverage IS dobrze THEN prediction IS wygrana;
RULE 29: IF penaltiesAverage IS duzo THEN prediction IS wygrana;
RULE 30: IF redCardsAverage IS malo THEN prediction IS wygrana;
RULE 31: IF possessionAverage IS duzo AND goalsLostAverage IS malo THEN prediction IS wygrana;
RULE 32: IF penaltyAreaEntriesAverage is czesto THEN prediction IS wygrana;
RULE 33: IF goalsLostAverage IS malo THEN prediction IS wygrana;
RULE 34: IF goalkeeperForm IS znakomita THEN prediction IS wygrana;
RULE 35: IF formationAgainstForm IS przecietna AND goalsAverage IS duzo THEN prediction IS wygrana;
RULE 36: IF formationAgainstForm IS przecietna AND goalkeeperForm IS zla AND shootsOnTargetAverage IS malo THEN prediction IS przegrana;
RULE 37: IF penaltiesAverage IS przecietnie AND goalsLostAverage IS duzo AND goalsAverage IS malo THEN prediction IS przegrana;
RULE 38: IF shootsOnTargetAverage IS przecietnie AND goalsLostAverage IS duzo OR shootsOnTargetAverage IS przecietnie AND goalkeeperForm IS zla THEN prediction IS przegrana;
RULE 39: IF redCardsAverage IS przecietnie AND possessionAverage IS malo AND goalkeeperForm IS zla THEN prediction IS przegrana;
END_RULEBLOCK
END_FUNCTION_BLOCK

View File

@ -10,6 +10,7 @@ import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart;
import net.sourceforge.jFuzzyLogic.rule.Variable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -30,7 +31,15 @@ public class Prediction {
public static void make() {
// Load from 'FCL' file
FIS fis = Fuzzy.jFuzzyLogic.getFis();
//FIS fis = Fuzzy.jFuzzyLogic.getFis();
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);
}
// Pokazuje reguly
FunctionBlock functionBlock = fis.getFunctionBlock(null);
JFuzzyChart.get().chart(functionBlock);
@ -39,6 +48,18 @@ public class Prediction {
for (com.resultprediction.polishekstraklasa.Predictions.Variable variable : variables){
fis.setVariable(variable.getName(), variable.getValue());
}
/*
fis.setVariable("goalkeeperForm", 85);
fis.setVariable("formationAgainstForm", 60);
fis.setVariable("shootsOnTargetAverage", 8);
fis.setVariable("possessionAverage", 80);
fis.setVariable("goalsAverage", 2);
fis.setVariable("goalsLostAverage", 0);
fis.setVariable("redCardsAverage", 0.1);
fis.setVariable("penaltyAreaEntriesAverage", 1);
fis.setVariable("penaltiesAverage", 0.1);
fis.setVariable("lastMatchesResultAverage", 8);
fis.setVariable("lastMatchesResultBetweenAverage", 8);*/
// Wylicza zbiory rozmyte
fis.evaluate();
@ -52,7 +73,8 @@ public class Prediction {
// Drukuje reguly
//System.out.println(fis);
System.out.println("Prediction:" + fis.getVariable("prediction"));
System.out.println(fis);
System.out.println("Napiwek:" + fis.getVariable("prediction"));
variables.clear();
}
}

View File

@ -31,7 +31,7 @@ public class PredictionsApplication {
ConfigurableApplicationContext context = builder.run(args);
Fuzzy fuzzy = new Fuzzy();
//Fuzzy fuzzy = new Fuzzy();
}
}