Class ClassificationExplainedImpl

  • All Implemented Interfaces:
    IClassification, IClassificationExplained

    public class ClassificationExplainedImpl
    extends Object
    implements IClassificationExplained
    The detailed explanation of a classification : - likelyhood values - likelyhood formulae (in a readable format) - likelyhood expressions (in a readable format) The toString() function generates a JavaScript that can interpreted
    Author:
    elian
    • Constructor Detail

      • ClassificationExplainedImpl

        public ClassificationExplainedImpl​(IClassification classification,
                                           double[] likelyhoods,
                                           String[] likelyhoodFormulae,
                                           String[] likelyhoodExpressions)
        Create an immutable detailed explanation of a classification :
        Parameters:
        classification - The classification output and explainData
        likelyhoods - The likelyhood values
        likelyhoodFormulae - The likelyhood formulae
        likelyhoodExpressions - The likelyhood expressions
    • Method Detail

      • getClassification

        public IClassification getClassification()
        Returns:
        the classification
      • getLikelyhoodFormulae

        public String[] getLikelyhoodFormulae()
        Description copied from interface: IClassificationExplained
        For each likelyhood, get the formula ex. gL_cA_Yes / gL * ((gL_cA_Yes_fE_temp_is_Cool + alpha)/(gL_cA_Yes_fE_temp + ( gL_fE_temp_count * alpha )) * (gL_cA_Yes_fE_humidity_is_High + alpha)/(gL_cA_Yes_fE_humidity + ( gL_fE_humidity_count * alpha )) * (gL_cA_Yes_fE_outlook_is_Overcast + alpha)/(gL_cA_Yes_fE_outlook + ( gL_fE_outlook_count * alpha )) * (gL_cA_Yes_fE_wind_is_Strong + alpha)/(gL_cA_Yes_fE_wind + ( gL_fE_wind_count * alpha )) * 1 )
        Specified by:
        getLikelyhoodFormulae in interface IClassificationExplained
        Returns:
        the likelyhoodFormulae
      • getLikelyhoodExpressions

        public String[] getLikelyhoodExpressions()
        Description copied from interface: IClassificationExplained
        For each likelyhood, get the expression ex. 9 / 14 * ((3 + 1.0 )/(9 + ( 3 * 1.0 )) * (3 + 1.0 )/(9 + ( 2 * 1.0 )) * (4 + 1.0 )/(9 + ( 3 * 1.0 )) * (3 + 1.0 )/(9 + ( 2 * 1.0 )) * 1 )
        Specified by:
        getLikelyhoodExpressions in interface IClassificationExplained
        Returns:
        the likelyhoodExpressions
      • isLaplaceSmoothedVariant

        public boolean isLaplaceSmoothedVariant()
        Description copied from interface: IClassification
        If Laplace Smoothed With variant, then: likelyhood[i] = 1d * ((categoryCount + alpha) / (globalCount + globalCountCategories * alpha)) * product; otherwise: likelyhood[i] = 1d * categoryCount / globalCount * product;
        Specified by:
        isLaplaceSmoothedVariant in interface IClassification
        Returns:
        If Laplace smothing variant used
      • getLaplaceSmoothingAlpha

        public double getLaplaceSmoothingAlpha()
        Description copied from interface: IClassification
        The alpha value used for Laplace smoothing
        Specified by:
        getLaplaceSmoothingAlpha in interface IClassification
        Returns:
        The alpha value, usually 1.0
      • toString

        public String toString()
        Print to String that can be interpreted as JavaScript and return the highest probability value
        Overrides:
        toString in class Object
        Returns:
        The Javascript text