Package net.lifove.clami.util
Class Utils
java.lang.Object
net.lifove.clami.util.Utils
public class Utils
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description Utils() -
Method Summary
Modifier and Type Method Description static doublegetCutoffForACL(weka.core.Instances instances, double[] K)static double[]getDoublePrimitive(java.util.ArrayList<java.lang.Double> values)Get primitive double form ArrayListstatic double[]getHigherValueCutoffs(weka.core.Instances instances, double percentileCutoff)Get higher value cutoffs for each attributestatic double[]getHigherValueCutoffsForACL(weka.core.Instances instances)Get higher value cutoffs for each attributestatic weka.core.InstancesgetInstancesByRemovingSpecificAttributes(weka.core.Instances instances, java.lang.String attributeIndices, boolean invertSelection)Get instances by removing specific attributesstatic weka.core.InstancesgetInstancesByRemovingSpecificInstances(weka.core.Instances instances, java.lang.String instanceIndices, boolean invertSelection)Get instances by removing specific instancesstatic java.lang.StringgetInversedSelectedInstances(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel)Get the selected instance for the instance selectionstatic doublegetMedian(java.util.ArrayList<java.lang.Double> values)Get median from ArraListstatic java.util.HashMap<java.lang.Integer,java.lang.String>getMetricIndicesWithTheViolationScores(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel)Return the HashMap that the key is Metric Violation Score and the value is string of metric indexesstatic java.lang.StringgetNegLabel(weka.core.Instances instances, java.lang.String positiveLabel)Get the negative label string value from the positive label valuestatic doublegetPDrForACL(weka.core.Instances instances, double[] K)static doublegetPercentile(java.util.ArrayList<java.lang.Double> values, double percentile)Get a value in a specific percentile from ArraListstatic java.util.ArrayList<java.lang.Double>getPerformanceResult()Return performance result ArrayListstatic java.lang.StringgetSelectedInstances(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel, int inversedMetricIndex)Get the selected instance for the instance selectionstatic java.lang.StringgetStringValueOfInstanceLabel(weka.core.Instances instances, int instanceIndex)Get label value of an instancestatic weka.core.InstancesloadArff(java.lang.String path, java.lang.String classAttributeName)Load Instances from arff file.static voidmakeFile(java.lang.String versionName)To create a result filestatic voidprintEvaluationResult(weka.core.Instances instances, weka.core.Instances testInstances, weka.core.Instances trainingInstances, weka.classifiers.Classifier classifier, java.lang.String positiveLabel, boolean experimental, java.lang.String fileName)Print prediction performance in terms of TP, TN, FP, FN, precision, recall, f1, AUC, and MCC.static voidprintEvaluationResultCLA(int TP, int TN, int FP, int FN, boolean experimental, java.lang.String fileName)Print prediction performance in terms of TP, TN, FP, FN, precision, recall, and f1.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
makeFile
public static void makeFile(java.lang.String versionName) throws java.io.FileNotFoundException, java.io.IOExceptionTo create a result file- Parameters:
versionName-- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
printEvaluationResultCLA
public static void printEvaluationResultCLA(int TP, int TN, int FP, int FN, boolean experimental, java.lang.String fileName)Print prediction performance in terms of TP, TN, FP, FN, precision, recall, and f1.- Parameters:
TP-TN-FP-FN-- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
getPerformanceResult
public static java.util.ArrayList<java.lang.Double> getPerformanceResult()Return performance result ArrayList- Returns:
-
printEvaluationResult
public static void printEvaluationResult(weka.core.Instances instances, weka.core.Instances testInstances, weka.core.Instances trainingInstances, weka.classifiers.Classifier classifier, java.lang.String positiveLabel, boolean experimental, java.lang.String fileName)Print prediction performance in terms of TP, TN, FP, FN, precision, recall, f1, AUC, and MCC.- Parameters:
instances-testInstances-trainingInstances-classifier-positiveLabel-experimental-fileName-
-
getHigherValueCutoffs
public static double[] getHigherValueCutoffs(weka.core.Instances instances, double percentileCutoff)Get higher value cutoffs for each attribute- Parameters:
instances-percentileCutoff-- Returns:
- double[]
-
getHigherValueCutoffsForACL
public static double[] getHigherValueCutoffsForACL(weka.core.Instances instances)Get higher value cutoffs for each attribute- Parameters:
instances-- Returns:
- double[]
-
getPDrForACL
public static double getPDrForACL(weka.core.Instances instances, double[] K) -
getCutoffForACL
public static double getCutoffForACL(weka.core.Instances instances, double[] K) -
getMetricIndicesWithTheViolationScores
public static java.util.HashMap<java.lang.Integer,java.lang.String> getMetricIndicesWithTheViolationScores(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel)Return the HashMap that the key is Metric Violation Score and the value is string of metric indexes- Parameters:
instances-cutoffsForHigherValuesOfAttribute-positiveLabel-- Returns:
- HashMap
-
getSelectedInstances
public static java.lang.String getSelectedInstances(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel, int inversedMetricIndex)Get the selected instance for the instance selection- Parameters:
instances-cutoffsForHigherValuesOfAttribute-positiveLabel-- Returns:
- String
-
getInversedSelectedInstances
public static java.lang.String getInversedSelectedInstances(weka.core.Instances instances, double[] cutoffsForHigherValuesOfAttribute, java.lang.String positiveLabel)Get the selected instance for the instance selection- Parameters:
instances-cutoffsForHigherValuesOfAttribute-positiveLabel-- Returns:
- String
-
getNegLabel
public static java.lang.String getNegLabel(weka.core.Instances instances, java.lang.String positiveLabel)Get the negative label string value from the positive label value- Parameters:
instances-positiveLabel-- Returns:
- String
-
loadArff
public static weka.core.Instances loadArff(java.lang.String path, java.lang.String classAttributeName)Load Instances from arff file. Last attribute will be set as class attribute- Parameters:
path- arff file path- Returns:
- Instances
-
getStringValueOfInstanceLabel
public static java.lang.String getStringValueOfInstanceLabel(weka.core.Instances instances, int instanceIndex)Get label value of an instance- Parameters:
instances-instanceIndex-- Returns:
- string label of an instance
-
getMedian
public static double getMedian(java.util.ArrayList<java.lang.Double> values)Get median from ArraList- Parameters:
values-- Returns:
- double
-
getPercentile
public static double getPercentile(java.util.ArrayList<java.lang.Double> values, double percentile)Get a value in a specific percentile from ArraList- Parameters:
values-- Returns:
- double
-
getDoublePrimitive
public static double[] getDoublePrimitive(java.util.ArrayList<java.lang.Double> values)Get primitive double form ArrayList- Parameters:
values-- Returns:
- double[]
-
getInstancesByRemovingSpecificAttributes
public static weka.core.Instances getInstancesByRemovingSpecificAttributes(weka.core.Instances instances, java.lang.String attributeIndices, boolean invertSelection)Get instances by removing specific attributes- Parameters:
instances-attributeIndices- attribute indices (e.g., 1,3,4) first index is 1invertSelection- for invert selection, if true, select attributes with attributeIndices bug if false, remote attributes with attributeIndices- Returns:
- new instances with specific attributes
-
getInstancesByRemovingSpecificInstances
public static weka.core.Instances getInstancesByRemovingSpecificInstances(weka.core.Instances instances, java.lang.String instanceIndices, boolean invertSelection)Get instances by removing specific instances- Parameters:
instances-instanceIndices- (e.g., 1,3,4) first index is 1- Returns:
- selected instances
-