Class LibLinearClassificationModel

java.lang.Object
org.tribuo.Model<Label>
org.tribuo.common.liblinear.LibLinearModel<Label>
org.tribuo.classification.liblinear.LibLinearClassificationModel
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<org.tribuo.provenance.ModelProvenance>, Serializable, org.tribuo.ONNXExportable, org.tribuo.protos.ProtoSerializable<org.tribuo.protos.core.ModelProto>

public class LibLinearClassificationModel extends LibLinearModel<Label> implements org.tribuo.ONNXExportable
A Model which wraps a LibLinear-java classification model.

It disables the LibLinear debug output as it's very chatty.

See:

 Fan RE, Chang KW, Hsieh CJ, Wang XR, Lin CJ.
 "LIBLINEAR: A library for Large Linear Classification"
 Journal of Machine Learning Research, 2008.
 
and for the original algorithm:
 Cortes C, Vapnik V.
 "Support-Vector Networks"
 Machine Learning, 1995.
 
See Also:
  • Field Summary

    Fields inherited from class org.tribuo.common.liblinear.LibLinearModel

    CURRENT_VERSION, models

    Fields inherited from class org.tribuo.Model

    ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput

    Fields inherited from interface org.tribuo.ONNXExportable

    PROVENANCE_METADATA_FIELD, SERIALIZER

    Fields inherited from interface org.tribuo.protos.ProtoSerializable

    DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(String newName, org.tribuo.provenance.ModelProvenance newProvenance)
     
    deserializeFromProto(int version, String className, com.google.protobuf.Any message)
    Deserialization factory.
    ai.onnx.proto.OnnxMl.ModelProto
    exportONNXModel(String domain, long modelVersion)
     
    protected double[][]
     
    Map<String, List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>>
     
    protected org.tribuo.Excuse<Label>
    innerGetExcuse(org.tribuo.Example<Label> e, double[][] allFeatureWeights)
    The call to model.getFeatureWeights in the public methods copies the weights array so this inner method exists to save the copy in getExcuses.
    org.tribuo.Prediction<Label>
    predict(org.tribuo.Example<Label> example)
     
    org.tribuo.util.onnx.ONNXNode
    writeONNXGraph(org.tribuo.util.onnx.ONNXRef<?> input)
     

    Methods inherited from class org.tribuo.common.liblinear.LibLinearModel

    copyModel, getExcuse, getExcuses, getInnerModels, serialize

    Methods inherited from class org.tribuo.Model

    castModel, copy, createDataCarrier, deserialize, deserializeFromFile, deserializeFromStream, generatesProbabilities, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, innerPredict, predict, predict, serializeToFile, serializeToStream, setName, toString, validate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.tribuo.ONNXExportable

    saveONNXModel, serializeProvenance
  • Method Details

    • deserializeFromProto

      public static LibLinearClassificationModel deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - If the protobuf could not be parsed from the message.
    • predict

      public org.tribuo.Prediction<Label> predict(org.tribuo.Example<Label> example)
      Specified by:
      predict in class org.tribuo.Model<Label>
    • getTopFeatures

      public Map<String, List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>> getTopFeatures(int n)
      Specified by:
      getTopFeatures in class org.tribuo.Model<Label>
    • copy

      protected LibLinearClassificationModel copy(String newName, org.tribuo.provenance.ModelProvenance newProvenance)
      Specified by:
      copy in class org.tribuo.Model<Label>
    • getFeatureWeights

      protected double[][] getFeatureWeights()
      Specified by:
      getFeatureWeights in class LibLinearModel<Label>
    • innerGetExcuse

      protected org.tribuo.Excuse<Label> innerGetExcuse(org.tribuo.Example<Label> e, double[][] allFeatureWeights)
      The call to model.getFeatureWeights in the public methods copies the weights array so this inner method exists to save the copy in getExcuses.

      If it becomes a problem then we could cache the feature weights in the model.

      Specified by:
      innerGetExcuse in class LibLinearModel<Label>
      Parameters:
      e - The example.
      allFeatureWeights - The feature weights.
      Returns:
      An excuse for this example.
    • exportONNXModel

      public ai.onnx.proto.OnnxMl.ModelProto exportONNXModel(String domain, long modelVersion)
      Specified by:
      exportONNXModel in interface org.tribuo.ONNXExportable
    • writeONNXGraph

      public org.tribuo.util.onnx.ONNXNode writeONNXGraph(org.tribuo.util.onnx.ONNXRef<?> input)
      Specified by:
      writeONNXGraph in interface org.tribuo.ONNXExportable