Click or drag to resize
Accord.NET (logo)

LibSvmModel Class

Reads support vector machines created from LibSVM or Liblinear. Not all solver types are supported.
Inheritance Hierarchy
SystemObject
  Accord.IOLibSvmModel

Namespace:  Accord.IO
Assembly:  Accord.MachineLearning (in Accord.MachineLearning.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class LibSvmModel
Request Example View Source

The LibSvmModel type exposes the following members.

Constructors
  NameDescription
Public methodLibSvmModel
Creates a new LibSvmModel object.
Top
Properties
  NameDescription
Public propertyBias
Gets or sets whether an initial double value should be appended in the beginning of every feature vector. If set to a negative number, this functionality is disabled. Default is 0.
Public propertyClasses Obsolete.
Obsolete. Please use NumberOfClasses instead.
Public propertyDimension Obsolete.
Obsolete. Please use NumberOfInputs instead.
Public propertyLabels
Gets or sets the class label for each class this classification model expects to handle.
Public propertyNumberOfClasses
Gets or sets the number of classes that this classification model can handle.
Public propertyNumberOfInputs
Gets or sets the number of dimensions (features) the classification or regression model can handle.
Public propertySolver
Gets or sets the solver type used to create the model.
Public propertyVectors
Gets or sets the set of support vectors used by this model. If the model is compact, this will be set to null.
Public propertyWeights
Gets or sets the vector of linear weights used by this model, if it is a compact model. If this is not a compact model, this will be set to null.
Top
Methods
  NameDescription
Public methodCreateAlgorithm
Creates a support vector machine learning algorithm that attends the requisites specified in this model.
Public methodCreateMachine
Creates a SupportVectorMachine that attends the requisites specified in this model.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodStatic memberFromMachine
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberLoad(Stream)
Loads a model specified using LibSVM's model format from a stream.
Public methodStatic memberLoad(String)
Loads a model specified using LibSVM's model format from disk.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSave(Stream)
Saves this model to disk using LibSVM's model format.
Public methodSave(String)
Saves this model to disk using LibSVM's model format.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

This class can be used to import LibSVM or LibLINEAR models into .NET and use them to make predictions in .NET/C# applications.

If you are looking for ways to load and save SVM models in the Accord.NET Framework without necessarily being compatible with LibSVM or LIBLINEAR, please use the Serializer class instead.

Examples
// Let's say we have used LIBLINEAR to learn a linear SVM model that has
// been stored in a text file named "svm.txt". We would like to load this
// same model in .NET and use it to make predictions using C#.
// 
// First, we use LibSvmModel.Load to load the LIBLINEAR model from disk:
LibSvmModel model = LibSvmModel.Load(Path.Combine(basePath, "svm.txt"));

// Now, we can use the model class to create the equivalent Accord.NET SVM:
SupportVectorMachine svm = model.CreateMachine();

// Now, we can use this machine normally, like as shown in the 
// examples in the Support Vector Machine documentation page.
See Also