Class DataFrameClassifier.VectorDataFrameClassifier

java.lang.Object
smile.classification.DataFrameClassifier.VectorDataFrameClassifier
All Implemented Interfaces:
Serializable, ToDoubleFunction<Tuple>, ToIntFunction<Tuple>, Classifier<Tuple>, DataFrameClassifier, SHAP<Tuple>
Enclosing interface:
DataFrameClassifier

public static final class DataFrameClassifier.VectorDataFrameClassifier extends Object implements DataFrameClassifier, SHAP<Tuple>, Serializable
Adapter wrapping a vector Classifier<double[]> as a DataFrameClassifier with SHAP<Tuple> support.
See Also:
  • Method Details

    • formula

      public Formula formula()
      Description copied from interface: DataFrameClassifier
      Returns the formula associated with the model.
      Specified by:
      formula in interface DataFrameClassifier
      Returns:
      the formula associated with the model.
    • schema

      public StructType schema()
      Description copied from interface: DataFrameClassifier
      Returns the predictor schema.
      Specified by:
      schema in interface DataFrameClassifier
      Returns:
      the predictor schema.
    • isSoft

      public boolean isSoft()
      Description copied from interface: Classifier
      Returns true if this is a soft classifier that can estimate the posteriori probabilities of classification.
      Specified by:
      isSoft in interface Classifier<Tuple>
      Returns:
      true if soft classifier.
    • isOnline

      public boolean isOnline()
      Description copied from interface: Classifier
      Returns true if this is an online learner.
      Specified by:
      isOnline in interface Classifier<Tuple>
      Returns:
      true if online learner.
    • numClasses

      public int numClasses()
      Description copied from interface: Classifier
      Returns the number of classes.
      Specified by:
      numClasses in interface Classifier<Tuple>
      Returns:
      the number of classes.
    • classes

      public int[] classes()
      Description copied from interface: Classifier
      Returns the class labels.
      Specified by:
      classes in interface Classifier<Tuple>
      Returns:
      the class labels.
    • predict

      public int predict(Tuple x)
      Description copied from interface: Classifier
      Predicts the class label of an instance.
      Specified by:
      predict in interface Classifier<Tuple>
      Parameters:
      x - the instance to be classified.
      Returns:
      the predicted class label.
    • predict

      public int predict(Tuple x, double[] posteriori)
      Description copied from interface: Classifier
      Predicts the class label of an instance and also calculate a posteriori probabilities. Classifiers may NOT support this method since not all classification algorithms are able to calculate such a posteriori probabilities.
      Specified by:
      predict in interface Classifier<Tuple>
      Parameters:
      x - an instance to be classified.
      posteriori - a posteriori probabilities on output.
      Returns:
      the predicted class label
    • update

      public void update(Tuple x, int y)
      Description copied from interface: Classifier
      Online update the classifier with a new training instance. In general, this method may be NOT multi-thread safe.
      Specified by:
      update in interface Classifier<Tuple>
      Parameters:
      x - the training instance.
      y - the training label.
    • shap

      public double[] shap(Tuple x)
      Description copied from interface: SHAP
      Returns the SHAP values. For regression, the length of SHAP values is same as the number of features. For classification, SHAP values are of p x k, where p is the number of features and k is the classes. The first k elements are the SHAP values of first feature over k classes, respectively. The rest features follow accordingly.
      Specified by:
      shap in interface SHAP<Tuple>
      Parameters:
      x - an instance.
      Returns:
      the SHAP values.
    • shap

      public double[] shap(Tuple x, KernelSHAP.Options options)
      Description copied from interface: SHAP
      Returns the SHAP values with custom KernelSHAP.Options (ignored by exact explainers such as TreeSHAP and linear SHAP).
      Specified by:
      shap in interface SHAP<Tuple>
      Parameters:
      x - an instance.
      options - the KernelSHAP options, or null to use default options.
      Returns:
      the SHAP values.