org.encog.ml.svm
Class SVM
- java.lang.Object
-
- org.encog.ml.BasicML
-
- org.encog.ml.svm.SVM
-
- All Implemented Interfaces:
- java.io.Serializable, MLClassification, MLError, MLInput, MLInputOutput, MLMethod, MLOutput, MLProperties, MLRegression
public class SVM extends BasicML implements MLRegression, MLClassification, MLError
This is a network that is backed by one or more Support Vector Machines (SVM). It is designed to function very similarly to an Encog neural network, and is largely interchangeable with an Encog neural network. The support vector machine supports several types. Regression is used when you want the network to predict a value, given the input. Function approximation is a good example of regression. Classification is used when you want the SVM to group the input data into one or more classes. Support Vector Machines typically have a single output. Neural networks can have multiple output neurons. To get around this issue, this class will create multiple SVM's if there is more than one output specified. Because a SVM is trained quite differently from a neural network, none of the neural network training classes will work. This class must be trained using SVMTrain.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intDEFAULT_CThe default C.static intDEFAULT_CACHE_SIZEThe default cache size.static intDEFAULT_COEF0The default COEF0.static intDEFAULT_DEGREEThe default degree.static doubleDEFAULT_EPSThe default EPS.static doubleDEFAULT_NUThe default NU.static doubleDEFAULT_PThe default P.
-
Constructor Summary
Constructors Constructor and Description SVM()Construct the SVM.SVM(int theInputCount, boolean regression)Construct an SVM network.SVM(int theInputCount, SVMType svmType, KernelType kernelType)Construct a SVM network.SVM(svm_model theModel)Construct a SVM from a model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecalculateError(MLDataSet data)Calculate the error for this SVM.intclassify(MLData input)Classify the input into a group.MLDatacompute(MLData input)Compute the output for the given input.intgetInputCount()KernelTypegetKernelType()svm_modelgetModel()intgetOutputCount()svm_parametergetParams()SVMTypegetSVMType()svm_node[]makeSparse(MLData data)Convert regular Encog MLData into the "sparse" data needed by an SVM.voidsetInputCount(int i)Set the input count.voidsetModel(svm_model theModel)Set the model.voidupdateProperties()Not needed, no properties to update.-
Methods inherited from class org.encog.ml.BasicML
getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty
-
-
-
-
Field Detail
-
DEFAULT_DEGREE
public static final int DEFAULT_DEGREE
The default degree.- See Also:
- Constant Field Values
-
DEFAULT_COEF0
public static final int DEFAULT_COEF0
The default COEF0.- See Also:
- Constant Field Values
-
DEFAULT_NU
public static final double DEFAULT_NU
The default NU.- See Also:
- Constant Field Values
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZE
The default cache size.- See Also:
- Constant Field Values
-
DEFAULT_C
public static final int DEFAULT_C
The default C.- See Also:
- Constant Field Values
-
DEFAULT_EPS
public static final double DEFAULT_EPS
The default EPS.- See Also:
- Constant Field Values
-
DEFAULT_P
public static final double DEFAULT_P
The default P.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SVM
public SVM()
Construct the SVM.
-
SVM
public SVM(int theInputCount, boolean regression)Construct an SVM network. For regression it will use an epsilon support vector. Both types will use an RBF kernel.- Parameters:
theInputCount- The input count.regression- True if this network is used for regression.
-
SVM
public SVM(int theInputCount, SVMType svmType, KernelType kernelType)Construct a SVM network.- Parameters:
theInputCount- The input count.svmType- The type of SVM.kernelType- The SVM kernal type.
-
SVM
public SVM(svm_model theModel)
Construct a SVM from a model.- Parameters:
theModel- The model.
-
-
Method Detail
-
calculateError
public double calculateError(MLDataSet data)
Calculate the error for this SVM.- Specified by:
calculateErrorin interfaceMLError- Parameters:
data- The training set.- Returns:
- The error percentage.
-
classify
public int classify(MLData input)
Classify the input into a group.- Specified by:
classifyin interfaceMLClassification- Parameters:
input- The input data to classify.- Returns:
- The group that the data was classified into.
-
compute
public MLData compute(MLData input)
Compute the output for the given input.- Specified by:
computein interfaceMLRegression- Parameters:
input- The input to the SVM.- Returns:
- The results from the SVM.
-
getInputCount
public int getInputCount()
- Specified by:
getInputCountin interfaceMLInput- Returns:
- The input count.
-
getKernelType
public KernelType getKernelType()
- Returns:
- The kernel type.
-
getModel
public svm_model getModel()
- Returns:
- The SVM models for each output.
-
getOutputCount
public int getOutputCount()
- Specified by:
getOutputCountin interfaceMLOutput- Returns:
- For a SVM, the output count is always one.
-
getParams
public final svm_parameter getParams()
- Returns:
- The SVM params for each of the outputs.
-
getSVMType
public SVMType getSVMType()
- Returns:
- The SVM type.
-
makeSparse
public svm_node[] makeSparse(MLData data)
Convert regular Encog MLData into the "sparse" data needed by an SVM.- Parameters:
data- The data to convert.- Returns:
- The SVM sparse data.
-
setInputCount
public void setInputCount(int i)
Set the input count.- Parameters:
i- The new input count.
-
setModel
public void setModel(svm_model theModel)
Set the model.- Parameters:
theModel- The model.
-
updateProperties
public void updateProperties()
Not needed, no properties to update.- Specified by:
updatePropertiesin interfaceMLProperties- Specified by:
updatePropertiesin classBasicML
-
-
DMelt 3.0 © DataMelt by jWork.ORG