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
- Direct Known Subclasses:
LibSVMAnomalyModel
,LibSVMClassificationModel
,LibSVMRegressionModel
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, provenanceOutput
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LibSVMModel
(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_model
copyModel
(libsvm.svm_model model) Copies an svm_model, as it does not provide a copy method.Generates an excuse for an example.List
<libsvm.svm_model> Returns an unmodifiable copy of the underlying list of libsvm models.List
<libsvm.svm_model> getModel()
Deprecated.getTopFeatures
(int n) Gets the topn
features associated with this model.Methods inherited from class org.tribuo.Model
copy, copy, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, innerPredict, predict, predict, predict, setName, toString, validate
-
Field Details
-
models
-
-
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.Returns an unmodifiable copy of the underlying list of libsvm models.Deprecated to unify the names across LibLinear, LibSVM and XGBoost.
- Returns:
- The underlying model list.
-
getInnerModels
Returns an unmodifiable copy of the underlying list of libsvm models.- Returns:
- The underlying model list.
-
getTopFeatures
Description copied from class:Model
Gets the topn
features associated with this model.If the model does not produce per output feature lists, it returns a map with a single element with key Model.ALL_OUTPUTS.
If the model cannot describe it's top features then it returns
Collections.emptyMap()
.- Specified by:
getTopFeatures
in classModel<T extends Output<T>>
- Parameters:
n
- the number of features to return. If this value is less than 0, all features should be returned for each class, unless the model cannot score it's features.- Returns:
- a map from string outputs to an ordered list of pairs of feature names and weights associated with that feature in the model
-
getExcuse
Description copied from class:Model
Generates an excuse for an example.This attempts to explain a classification result. Generating an excuse may be quite an expensive operation.
This excuse either contains per class information or an entry with key Model.ALL_OUTPUTS.
The optional is empty if the model does not provide excuses.
-
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.
-