Package org.processmining.prediction
Class EvaluationNDC
- java.lang.Object
-
- org.processmining.prediction.EvaluationNDC
-
public class EvaluationNDC extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EvaluationNDC(J48WithNDCs fairTree, J48WithNDCs normalTree, Instances dataset, int sensitiveAttributeIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateTestAndTrainSatasets(int percent)doublediscriminationInData(Instances dataset)voiddoEvaluate()double[][]evaluate(J48WithNDCs fairTree, J48WithNDCs normalTree, Instances dataset)double[]getAccuracy()double[][]getDiscrimination()public void ev(Instances instances) throws Exception { double[][] result = new double[2][2]; double nsiData = 0; // numSensitiveInstancesIn dataset double nfiData = 0; double nasiFairTree = 0; // numAcceptedSensitiveInstancesFairTree double nafiFairTree = 0; // numAcceptedFavorabelInstancesInFairTree double nasiNormalTree = 0; // numAcceptedSensitiveInstancesNormalTree double nafiNormalTree = 0; // numAcceptedFavorabelInstancesInNormalTree double numCorrectPredictionFairTree = 0; double numCorrectPredictionNormalTree = 0; double correctnessFairTree = 0; double correctnessNormalTree = 0; for (int i = 0; i < dataset.numInstances() ; i++) { Instance inst = dataset.instance(i); int resultFair = (int) Math.round(fairTree.classifyInstance(inst)); int resultNormal = (int) Math.round(normalTree.classifyInstance(inst)); if (dataset.instance(i).stringValue(sensitiveAttributeIndex).equals("protected_value")) { nsiData++; if (resultFair == 0 ) { nasiFairTree++; } if (resultNormal == 0 ) { nasiNormalTree++; } } else { nfiData++; if (resultFair == 0 ) { nafiFairTree++; } if (resultNormal == 0 ) { nafiNormalTree++; } } } // System.out.println("ev disc fair :"+ ((nafiFairTree/nfiData)-(nasiFairTree/nsiData))); // System.out.println("ev disc normal :"+ ((nafiNormalTree/nfiData)-(nasiNormalTree/nsiData))); }java.lang.StringtoStringAccuracy()java.lang.StringtoStringDiscrimination()
-
-
-
Constructor Detail
-
EvaluationNDC
public EvaluationNDC(J48WithNDCs fairTree, J48WithNDCs normalTree, Instances dataset, int sensitiveAttributeIndex) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
createTestAndTrainSatasets
public void createTestAndTrainSatasets(int percent)
-
doEvaluate
public void doEvaluate() throws java.lang.Exception- Throws:
java.lang.Exception
-
discriminationInData
public double discriminationInData(Instances dataset)
-
evaluate
public double[][] evaluate(J48WithNDCs fairTree, J48WithNDCs normalTree, Instances dataset) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getDiscrimination
public double[][] getDiscrimination()
public void ev(Instances instances) throws Exception { double[][] result = new double[2][2]; double nsiData = 0; // numSensitiveInstancesIn dataset double nfiData = 0; double nasiFairTree = 0; // numAcceptedSensitiveInstancesFairTree double nafiFairTree = 0; // numAcceptedFavorabelInstancesInFairTree double nasiNormalTree = 0; // numAcceptedSensitiveInstancesNormalTree double nafiNormalTree = 0; // numAcceptedFavorabelInstancesInNormalTree double numCorrectPredictionFairTree = 0; double numCorrectPredictionNormalTree = 0; double correctnessFairTree = 0; double correctnessNormalTree = 0; for (int i = 0; i < dataset.numInstances() ; i++) { Instance inst = dataset.instance(i); int resultFair = (int) Math.round(fairTree.classifyInstance(inst)); int resultNormal = (int) Math.round(normalTree.classifyInstance(inst)); if (dataset.instance(i).stringValue(sensitiveAttributeIndex).equals("protected_value")) { nsiData++; if (resultFair == 0 ) { nasiFairTree++; } if (resultNormal == 0 ) { nasiNormalTree++; } } else { nfiData++; if (resultFair == 0 ) { nafiFairTree++; } if (resultNormal == 0 ) { nafiNormalTree++; } } } // System.out.println("ev disc fair :"+ ((nafiFairTree/nfiData)-(nasiFairTree/nsiData))); // System.out.println("ev disc normal :"+ ((nafiNormalTree/nfiData)-(nasiNormalTree/nsiData))); }
-
toStringDiscrimination
public java.lang.String toStringDiscrimination()
-
getAccuracy
public double[] getAccuracy()
-
toStringAccuracy
public java.lang.String toStringAccuracy()
-
-