Class Dice

  • All Implemented Interfaces:
    Serializable, weka.classifiers.evaluation.InformationRetrievalEvaluationMetric, weka.classifiers.evaluation.StandardEvaluationMetric

    public class Dice
    extends weka.classifiers.evaluation.AbstractEvaluationMetric
    implements weka.classifiers.evaluation.StandardEvaluationMetric, weka.classifiers.evaluation.InformationRetrievalEvaluationMetric
    Sørensen–Dice coefficient: https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class weka.classifiers.evaluation.AbstractEvaluationMetric

        weka.classifiers.evaluation.AbstractEvaluationMetric.UnknownStatisticException
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String NAME  
      • Fields inherited from class weka.classifiers.evaluation.AbstractEvaluationMetric

        m_baseEvaluation
    • Constructor Summary

      Constructors 
      Constructor Description
      Dice()  
    • Constructor Detail

      • Dice

        public Dice()
    • Method Detail

      • getMetricName

        public String getMetricName()
        Get the name of this metric
        Specified by:
        getMetricName in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Returns:
        the name of this metric
      • getMetricDescription

        public String getMetricDescription()
        Get a short description of this metric (algorithm, forumulas etc.).
        Specified by:
        getMetricDescription in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Returns:
        a short description of this metric
      • appliesToNominalClass

        public boolean appliesToNominalClass()
        Return true if this evaluation metric can be computed when the class is nominal
        Specified by:
        appliesToNominalClass in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Returns:
        true if this evaluation metric can be computed when the class is nominal
      • appliesToNumericClass

        public boolean appliesToNumericClass()
        Return true if this evaluation metric can be computed when the class is numeric
        Specified by:
        appliesToNumericClass in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Returns:
        true if this evaluation metric can be computed when the class is numeric
      • getStatisticNames

        public List<String> getStatisticNames()
        Get a list of the names of the statistics that this metrics computes. E.g. an information theoretic evaluation measure might compute total number of bits as well as average bits/instance
        Specified by:
        getStatisticNames in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Returns:
        the names of the statistics that this metric computes
      • getStatistic

        public double getStatistic​(String statName)
        Get the value of the named statistic - for the first class label.
        Specified by:
        getStatistic in class weka.classifiers.evaluation.AbstractEvaluationMetric
        Parameters:
        statName - the name of the statistic to compute the value for
        Returns:
        the computed statistic or Utils.missingValue() if the statistic can't be computed for some reason
        See Also:
        getStatistic(String, int)
      • getStatistic

        public double getStatistic​(String statName,
                                   int classIndex)
        Get the value of the named statistic for the given class index.

        If the implementing class is extending AbstractEvaluationMetric then the implementation of getStatistic(String statName) should just call this method with a classIndex of 0.

        Specified by:
        getStatistic in interface weka.classifiers.evaluation.InformationRetrievalEvaluationMetric
        Parameters:
        statName - the name of the statistic to compute the value for
        classIndex - the class index for which to compute the statistic
        Returns:
        the value of the named statistic for the given class index or Utils.missingValue() if the statistic can't be computed for some reason
      • getClassWeightedAverageStatistic

        public double getClassWeightedAverageStatistic​(String statName)
        Get the weighted (by class) average for this statistic.
        Specified by:
        getClassWeightedAverageStatistic in interface weka.classifiers.evaluation.InformationRetrievalEvaluationMetric
        Parameters:
        statName - the name of the statistic to compute
        Returns:
        the weighted (by class) average value of the statistic or Utils.missingValue() if this can't be computed (or isn't appropriate).
      • toSummaryString

        public String toSummaryString()
        Return a formatted string (suitable for displaying in console or GUI output) containing all the statistics that this metric computes.
        Specified by:
        toSummaryString in interface weka.classifiers.evaluation.StandardEvaluationMetric
        Returns:
        a formatted string containing all the computed statistics
      • updateStatsForClassifier

        public void updateStatsForClassifier​(double[] predictedDistribution,
                                             weka.core.Instance instance)
                                      throws Exception
        Updates the statistics about a classifiers performance for the current test instance. Gets called when the class is nominal. Implementers need only implement this method if it is not possible to compute their statistics from what is stored in the base Evaluation object.
        Specified by:
        updateStatsForClassifier in interface weka.classifiers.evaluation.InformationRetrievalEvaluationMetric
        Specified by:
        updateStatsForClassifier in interface weka.classifiers.evaluation.StandardEvaluationMetric
        Parameters:
        predictedDistribution - the probabilities assigned to each class
        instance - the instance to be classified
        Throws:
        Exception - if the class of the instance is not set
      • updateStatsForPredictor

        public void updateStatsForPredictor​(double predictedValue,
                                            weka.core.Instance instance)
                                     throws Exception
        Updates the statistics about a predictors performance for the current test instance. Gets called when the class is numeric. Implementers need only implement this method if it is not possible to compute their statistics from what is stored in the base Evaluation object.
        Specified by:
        updateStatsForPredictor in interface weka.classifiers.evaluation.StandardEvaluationMetric
        Parameters:
        predictedValue - the numeric value the classifier predicts
        instance - the instance to be classified
        Throws:
        Exception - if the class of the instance is not set