Class LibSVMModel<T extends Output<T>>
java.lang.Object
org.tribuo.Model<T>
org.tribuo.common.libsvm.LibSVMModel<T>
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<ModelProvenance>,Serializable,ProtoSerializable<org.tribuo.protos.core.ModelProto>
A model that uses an underlying libSVM model to make the
predictions.
See:
Chang CC, Lin CJ. "LIBSVM: a library for Support Vector Machines" ACM transactions on intelligent systems and technology (TIST), 2011.for the nu-svm algorithm:
Schölkopf B, Smola A, Williamson R, Bartlett P L. "New support vector algorithms" Neural Computation, 2000, 1207-1245.and for the original algorithm:
Cortes C, Vapnik V. "Support-Vector Networks" Machine Learning, 1995.
- See Also:
-
Field Summary
FieldsFields inherited from class org.tribuo.Model
ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutputFields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLibSVMModel(String name, ModelProvenance description, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<T> outputIDInfo, boolean generatesProbabilities, List<libsvm.svm_model> models) Constructs a LibSVMModel from the supplied arguments. -
Method Summary
Modifier and TypeMethodDescriptionprotected static libsvm.svm_modelcopyModel(libsvm.svm_model model) Copies an svm_model, as it does not provide a copy method.protected static libsvm.svm_modeldeserializeModel(org.tribuo.common.libsvm.protos.SVMModelProto proto) Deserializes a LibSVM svm_model from a protobuf.protected static libsvm.svm_parameterdeserializeParameters(org.tribuo.common.libsvm.protos.SVMParameterProto proto) Deserializes svm_parameter from a protobuf.List<libsvm.svm_model> Returns an unmodifiable copy of the underlying list of libsvm models.List<libsvm.svm_model> getModel()Deprecated.Deprecated to unify the names across LibLinear, LibSVM and XGBoost.getTopFeatures(int n) static booleanmodelEquals(libsvm.svm_model first, libsvm.svm_model second) Checks for equality between two svm_models.protected static org.tribuo.common.libsvm.protos.SVMModelProtoserializeModel(libsvm.svm_model model) Serializes a LibSVM svm_model to a protobuf.protected static org.tribuo.common.libsvm.protos.SVMParameterProtoserializeParameters(libsvm.svm_parameter param) Serializes a svm_parameter to a protobuf.Methods inherited from class org.tribuo.Model
castModel, copy, copy, createDataCarrier, deserialize, deserializeFromFile, deserializeFromStream, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, innerPredict, predict, predict, predict, serialize, serializeToFile, serializeToStream, setName, toString, validate
-
Field Details
-
models
The LibSVM models. Multiple models are used for multi-label or multidimensional regression outputs.Not final to support deserialization reordering of multidimensional regression models which have an incorrect id mapping. Will be final again in some future version which doesn't maintain serialization compatibility with 4.X.
-
-
Constructor Details
-
LibSVMModel
protected LibSVMModel(String name, ModelProvenance description, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<T> outputIDInfo, boolean generatesProbabilities, List<libsvm.svm_model> models) Constructs a LibSVMModel from the supplied arguments.- Parameters:
name- The model name.description- The model provenance.featureIDMap- The features the model knows about.outputIDInfo- The outputs the model can produce.generatesProbabilities- Does the model generate probabilities or not?models- The svm models themselves.
-
-
Method Details
-
getModel
Deprecated.Deprecated to unify the names across LibLinear, LibSVM and XGBoost.Returns an unmodifiable copy of the underlying list of libsvm models.- Returns:
- The underlying model list.
-
getInnerModels
Returns an unmodifiable copy of the underlying list of libsvm models.- Returns:
- The underlying model list.
-
getTopFeatures
-
getExcuse
-
copyModel
Copies an svm_model, as it does not provide a copy method.- Parameters:
model- The svm_model to copy.- Returns:
- A deep copy of the model.
-
modelEquals
Checks for equality between two svm_models.Equality is defined as bit-wise exact for SV, rho, sv_coeff, probA and probB.
- Parameters:
first- The first model.second- The second model.- Returns:
- True if the models are identical.
-
serializeParameters
protected static org.tribuo.common.libsvm.protos.SVMParameterProto serializeParameters(libsvm.svm_parameter param) Serializes a svm_parameter to a protobuf.- Parameters:
param- The parameters to serialize.- Returns:
- The protobuf.
-
serializeModel
protected static org.tribuo.common.libsvm.protos.SVMModelProto serializeModel(libsvm.svm_model model) Serializes a LibSVM svm_model to a protobuf.- Parameters:
model- The model to serialize.- Returns:
- The protobuf representation.
-
deserializeParameters
protected static libsvm.svm_parameter deserializeParameters(org.tribuo.common.libsvm.protos.SVMParameterProto proto) Deserializes svm_parameter from a protobuf.- Parameters:
proto- The protobuf to deserialize.- Returns:
- The parameters.
-
deserializeModel
protected static libsvm.svm_model deserializeModel(org.tribuo.common.libsvm.protos.SVMModelProto proto) Deserializes a LibSVM svm_model from a protobuf.- Parameters:
proto- The protobuf to deserialize.- Returns:
- The svm_model.
-