net.sf.myra.datamining
Class Evaluator

java.lang.Object
  extended by net.sf.myra.datamining.Evaluator

public final class Evaluator
extends java.lang.Object

Utility class to evaluate rules discovered by ants.

Version:
$Revision$ $Date:: $
Author:
Fernando Esteban Barril Otero

Method Summary
static java.util.List<Instance> filter(java.util.List<Instance> instances, Term term)
          Filters the specified list of instances according to the test represented by the term.
static java.util.List<Instance> findCorrectCases(Rule rule, Dataset dataset)
          Returns the correct covered (the instance class value equals to the specified rule consequent) instances by the specified rule.
static java.util.List<Instance> findCoveredCases(Rule rule, Dataset dataset)
          Returns the covered instances by the specified rule.
static java.util.List<Instance> findCoveredCases(Rule rule, java.util.List<Instance> instances)
          Returns the covered instances by the specified rule.
static java.util.Set<java.lang.Integer> findIndexedCoveredCases(Rule rule, Dataset dataset)
          Returns a set of indexes of the covered instances by the specified rule.
static java.util.Set<java.lang.Integer> findIndexedCoveredCases(Rule rule, java.util.List<Instance> instances)
          Returns a set of indexes of the covered instances by the specified rule.
static Label findMajorityClass(Dataset dataset)
          Returns the majority class value among the specified dataset.
static Label findMajorityClass(java.util.List<Instance> instances, Metadata metadata)
          Returns the majority class value among the specified instances.
static Label findMajorityClass(java.util.List<Instance> instances, Metadata metadata, Label label)
          Returns the majority class value among the specified instances.
static Label findMajorityClassValue(java.util.List<Instance> instances, int index)
          Returns the majority class value among the specified instances.
static Label findMajorityClassValue(java.util.List<Instance> instances, int index, Label label)
          Returns the majority class value among the specified instances.
static java.util.List<Instance> findNotCoveredCases(Rule rule, Dataset dataset)
          Returns the not covered instances by the specified rule.
static java.util.List<Instance> findNotCoveredCases(Rule rule, java.util.List<Instance> instances)
          Returns the not covered instances by the specified rule.
static java.util.List<Instance> findPositiveCases(Rule rule, Dataset dataset)
          Returns the positive covered (the instance class value contains the specified rule consequent) instances by the specified rule.
static DefaultConfidenceFactor getConfidenceFactor(Rule rule, Dataset dataset)
          Returns the confidence factor of the specified rule when used to classify the dataset instances.
static ConfusionMatrix getConfusionMatrix(Model model, Dataset dataset)
          Returns the confusion matrix of the specified rule set when used to classify the dataset instances.
static ConfusionMatrix getConfusionMatrix(Model model, Dataset dataset, java.lang.String label)
          Returns the confusion matrix of the model for the specified class label.
static ConfusionMatrix getConfusionMatrix(Rule rule, Dataset dataset)
          Returns the confusion matrix of the specified rule when used to classify the dataset instances.
static ConfusionMatrix getConfusionMatrix(Rule rule, Dataset dataset, java.lang.String label)
          Returns the confusion matrix of the rule when used to classify the dataset instances, predicting the specified class label.
static ConfusionMatrix getConfusionMatrix(Rule rule, java.util.List<Instance> instances)
          Returns the confusion matrix of the specified rule when used to classify the specified instances.
static ConfusionMatrix getConfusionMatrix(Rule rule, java.util.List<Instance> instances, java.lang.String label)
          Returns the confusion matrix of the rule when used to classify the specified instances, predicting a class label.
static ConfusionMatrix getConfusionMatrix(Rule rule, java.util.List<Instance> instances, UsefulnessHelper helper)
          Returns the confusion matrix of the specified rule when used to classify the specified instances.
static Label getPresentLabel(java.util.List<Instance> instances)
          Returns a label instance with all present class labels from from the specified instances active.
static boolean sameLabel(java.util.List<Instance> instances)
          Verifies if the the list of instances have the same class label.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findCoveredCases

public static java.util.List<Instance> findCoveredCases(Rule rule,
                                                        Dataset dataset)
Returns the covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
dataset - the dataset to get the instances.
Returns:
the covered instances by the specified rule.

findCoveredCases

public static java.util.List<Instance> findCoveredCases(Rule rule,
                                                        java.util.List<Instance> instances)
Returns the covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
instances - the instances list to check.
Returns:
the covered instances by the specified rule.

findNotCoveredCases

public static java.util.List<Instance> findNotCoveredCases(Rule rule,
                                                           Dataset dataset)
Returns the not covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
dataset - the dataset to get the instances.
Returns:
the not covered instances by the specified rule.

findNotCoveredCases

public static java.util.List<Instance> findNotCoveredCases(Rule rule,
                                                           java.util.List<Instance> instances)
Returns the not covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
instances - the instances list to check.
Returns:
the not covered instances by the specified rule.

findIndexedCoveredCases

public static java.util.Set<java.lang.Integer> findIndexedCoveredCases(Rule rule,
                                                                       Dataset dataset)
Returns a set of indexes of the covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
dataset - the dataset to get the instances.
Returns:
a set of indexes of the covered instances by the specified rule.

findIndexedCoveredCases

public static java.util.Set<java.lang.Integer> findIndexedCoveredCases(Rule rule,
                                                                       java.util.List<Instance> instances)
Returns a set of indexes of the covered instances by the specified rule.

Parameters:
rule - the trail to be used as a filter.
instances - the instances list to check.
Returns:
a set of indexes of the covered instances by the specified rule.

findPositiveCases

public static java.util.List<Instance> findPositiveCases(Rule rule,
                                                         Dataset dataset)
Returns the positive covered (the instance class value contains the specified rule consequent) instances by the specified rule. For flat and single-label classification problems, this method returns the same set

See Also:
findCorrectCases(Rule, Dataset)

findCorrectCases

public static java.util.List<Instance> findCorrectCases(Rule rule,
                                                        Dataset dataset)
Returns the correct covered (the instance class value equals to the specified rule consequent) instances by the specified rule. For flat and single-label classification problems, this method returns the same set of instances as the findPositiveCases(Rule, Dataset) method.

Parameters:
rule - the rule to be used as a filter.
dataset - the dataset to get the instances.
Returns:
the correct covered instances by the specified rule.
See Also:
findPositiveCases(Rule, Dataset)

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Rule rule,
                                                 Dataset dataset)
Returns the confusion matrix of the specified rule when used to classify the dataset instances. For hierarchical problems, the confusion matrix is computed across all class labels, so each field of the matrix epresents the accumulated value.

Parameters:
rule - the rule to be used in the classification.
dataset - the dataset to get the instances.
Returns:
the confusion matrix of the specified rule.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Rule rule,
                                                 java.util.List<Instance> instances)
Returns the confusion matrix of the specified rule when used to classify the specified instances. For hierarchical problems, the confusion matrix is computed across all class labels, so each field of the matrix epresents the accumulated value.

Parameters:
rule - the rule to be used in the classification.
instances - the instances to classify.
Returns:
the confusion matrix of the specified rule.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Rule rule,
                                                 java.util.List<Instance> instances,
                                                 UsefulnessHelper helper)
Returns the confusion matrix of the specified rule when used to classify the specified instances. For hierarchical problems, the confusion matrix is computed across all class labels, so each field of the matrix epresents the accumulated value.

Parameters:
rule - the rule to be used in the classification.
instances - the instances to classify.
Returns:
the confusion matrix of the specified rule.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Rule rule,
                                                 Dataset dataset,
                                                 java.lang.String label)
Returns the confusion matrix of the rule when used to classify the dataset instances, predicting the specified class label. This method is useful for calculating the confusion matrix for an individual class label in hierarchical problems.

Parameters:
rule - the rule to be used in the classification.
dataset - the dataset to get the instances from.
label - the class label to be used as the prediction. The label should be present in the consequent of the rule.
Returns:
the confusion matrix of the specified rule.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Rule rule,
                                                 java.util.List<Instance> instances,
                                                 java.lang.String label)
Returns the confusion matrix of the rule when used to classify the specified instances, predicting a class label. This method is useful for calculating the confusion matrix for an individual class label in hierarchical problems.

Parameters:
rule - the rule to be used in the classification.
instances - the instances to classify.
label - the class label to be used as the prediction. The label should be present in the consequent of the rule.
Returns:
the confusion matrix of the specified rule.

getConfidenceFactor

public static DefaultConfidenceFactor getConfidenceFactor(Rule rule,
                                                          Dataset dataset)
Returns the confidence factor of the specified rule when used to classify the dataset instances.

Parameters:
rule - the rule to be used in the classification.
dataset - the dataset to get the instances.
Returns:
the confusion matrix of the specified rule.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Model model,
                                                 Dataset dataset,
                                                 java.lang.String label)
Returns the confusion matrix of the model for the specified class label.

Parameters:
model - the model to be used in the classification.
dataset - the dataset to get the instances.
label - the desired class label.
Returns:
the confusion matrix for the specified class label.

getConfusionMatrix

public static ConfusionMatrix getConfusionMatrix(Model model,
                                                 Dataset dataset)
Returns the confusion matrix of the specified rule set when used to classify the dataset instances. This method assumes that the majority class represents the negative examples and that there are only two different class labels.

Parameters:
model - the model to be used in the classification.
dataset - the dataset to get the instances.
Returns:
the confusion matrix of the classification.

findMajorityClassValue

public static Label findMajorityClassValue(java.util.List<Instance> instances,
                                           int index)
Returns the majority class value among the specified instances.

Parameters:
instances - the list of instances.
index - the class attribute index.
Returns:
the majority class value among the specified instances.

findMajorityClassValue

public static Label findMajorityClassValue(java.util.List<Instance> instances,
                                           int index,
                                           Label label)
Returns the majority class value among the specified instances.

Parameters:
instances - the list of instances.
index - the class attribute index.
label - the label returned in case of a tie. Usually this label will represent the overall majority of the data set.
Returns:
the majority class value among the specified instances.

findMajorityClass

public static Label findMajorityClass(java.util.List<Instance> instances,
                                      Metadata metadata)
Returns the majority class value among the specified instances.

Parameters:
instances - the list of instances.
metadata - the dataset metadata.
Returns:
the majority class value among the specified instances.

findMajorityClass

public static Label findMajorityClass(java.util.List<Instance> instances,
                                      Metadata metadata,
                                      Label label)
Returns the majority class value among the specified instances.

Parameters:
instances - the list of instances.
metadata - the dataset metadata.
label - the label returned in case of a tie. Usually this label will represent the overall majority of the data set.
Returns:
the majority class value among the specified instances.

findMajorityClass

public static Label findMajorityClass(Dataset dataset)
Returns the majority class value among the specified dataset.

Parameters:
dataset - the dataset reference.
Returns:
the majority class value among the specified dataset.

filter

public static java.util.List<Instance> filter(java.util.List<Instance> instances,
                                              Term term)
Filters the specified list of instances according to the test represented by the term.

Parameters:
instances - the list of instances to be filtered.
term - the filter criterion.
Returns:
a list of instances that satisfies the term test.

sameLabel

public static boolean sameLabel(java.util.List<Instance> instances)
Verifies if the the list of instances have the same class label.

Parameters:
instances - the list of instances to check.
Returns:
true of all instances have the same label; false otherwise.

getPresentLabel

public static Label getPresentLabel(java.util.List<Instance> instances)
Returns a label instance with all present class labels from from the specified instances active.

Parameters:
instances - the list of instances to check.
Returns:
a label instance with all present class labels from from the specified instances active.


Copyright © 2013. All Rights Reserved.