Class WekaClassificationModel

  • All Implemented Interfaces:
    adams.core.logging.LoggingSupporter, adams.core.SizeOfHandler, adams.ml.model.classification.ClassificationModel, adams.ml.model.Model, Serializable

    public class WekaClassificationModel
    extends adams.core.logging.LoggingObject
    implements adams.ml.model.classification.ClassificationModel
    Classification model for Weka classifiers.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected adams.ml.data.DatasetInfo m_DatasetInfo
      the dataset info.
      protected weka.core.Instances m_InstancesHeader
      the instances used.
      protected weka.classifiers.Classifier m_Model
      the underlying model.
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Constructor Summary

      Constructors 
      Constructor Description
      WekaClassificationModel​(weka.classifiers.Classifier model, adams.ml.data.Dataset data, weka.core.Instances inst)
      Initializes the model.
    • Field Detail

      • m_Model

        protected weka.classifiers.Classifier m_Model
        the underlying model.
      • m_DatasetInfo

        protected adams.ml.data.DatasetInfo m_DatasetInfo
        the dataset info.
      • m_InstancesHeader

        protected weka.core.Instances m_InstancesHeader
        the instances used.
    • Constructor Detail

      • WekaClassificationModel

        public WekaClassificationModel​(weka.classifiers.Classifier model,
                                       adams.ml.data.Dataset data,
                                       weka.core.Instances inst)
        Initializes the model.
        Parameters:
        model - the built Weka classifier
        data - the training data
        inst - the Weka training data
    • Method Detail

      • classify

        public String classify​(adams.data.spreadsheet.Row row)
                        throws Exception
        Returns the class label for the given row.
        Specified by:
        classify in interface adams.ml.model.classification.ClassificationModel
        Parameters:
        row - the row to make predictions for
        Returns:
        the prediction
        Throws:
        Exception - if prediction fails
      • distribution

        public double[] distribution​(adams.data.spreadsheet.Row row)
                              throws Exception
        Returns the class distribution for the given row.
        Specified by:
        distribution in interface adams.ml.model.classification.ClassificationModel
        Parameters:
        row - the row to generate the class distribution for
        Returns:
        the class distribution
        Throws:
        Exception - if prediction fails
      • getDatasetInfo

        public adams.ml.data.DatasetInfo getDatasetInfo()
        Returns information about the dataset used for building the model.
        Specified by:
        getDatasetInfo in interface adams.ml.model.Model
        Returns:
        the information
      • getInstancesHeader

        public weka.core.Instances getInstancesHeader()
        Returns the Instances header used for building the model.
        Returns:
        the header
      • getModelDescription

        public String getModelDescription()
        Gets a short string description of the model.
        Specified by:
        getModelDescription in interface adams.ml.model.Model
        Returns:
        the description, null if none available
      • isCompatible

        public String isCompatible​(adams.ml.data.Dataset data)
        Checks whether the dataset is compatible with the model.
        Specified by:
        isCompatible in interface adams.ml.model.Model
        Parameters:
        data - the dataset to check
        Returns:
        null if compatible, otherwise error message why not