jsat.classifiers.svm
Class DCSVM
- java.lang.Object
-
- jsat.classifiers.svm.SupportVectorLearner
-
- jsat.classifiers.svm.DCSVM
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, BinaryScoreClassifier, Classifier, Parameterized
public class DCSVM extends SupportVectorLearner implements Classifier, Parameterized, BinaryScoreClassifier
This is an implementation of the Divide-and-Conquer Support Vector Machine (DC-SVM). It uses a a combination of clustering and warm-starting to train faster, as well as an early stopping strategy to provide a fast approximate SVM solution. The final accuracy should often be at or near that of a normal SVM, while being faster to train.
The current implementation is based onSVMnoBias, meaning this code does not have a bias term and it only works with normalized kernels. Any non-normalized kernel will be normalized automatically. This is not a problem for the common RBF kernel.
See:- Hsieh, C.-J., Si, S., & Dhillon, I. S. (2014). A Divide-and-Conquer Solver for Kernel Support Vector Machines. In Proceedings of the 31st International Conference on Machine Learning. Beijing, China.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsat.classifiers.svm.SupportVectorLearner
SupportVectorLearner.CacheMode
-
-
Constructor Summary
Constructors Constructor and Description DCSVM()Creates a new DC-SVM for the RBF kernelDCSVM(DCSVM toCopy)Copy ConstructorDCSVM(KernelTrick k)Creates a new DC-SVM for the given kernel
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.DCSVMclone()doublegetC()Returns the soft margin complexity parameter of the SVMintgetClusterSampleSize()intgetEndLevel()doublegetScore(DataPoint dp)Returns the numeric score for predicting a class of a given data point, where the sign of the value indicates which class the data point is predicted to belong to.intgetStartLevel()voidsetC(double C)Sets the complexity parameter of SVM.voidsetClusterSampleSize(int m)At each level of the DC-SVM training, a clustering algorithm is used to divide the dataset into sub-groups for independent training.voidsetEndLevel(int l_early)The DC-SVM algorithm works by creating a hierarchy of levels, and iteratively refining the solution from one level to the next.voidsetStartLevel(int l_max)The DC-SVM algorithm works by creating a hierarchy of levels, and iteratively refining the solution from one level to the next.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidtrain(ClassificationDataSet dataSet, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.-
Methods inherited from class jsat.classifiers.svm.SupportVectorLearner
getCacheMode, getCacheValue, getKernel, setCacheMode, setCacheSize, setCacheValue, setKernel
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
Methods inherited from interface jsat.classifiers.Classifier
train
-
-
-
-
Constructor Detail
-
DCSVM
public DCSVM(KernelTrick k)
Creates a new DC-SVM for the given kernel- Parameters:
k- the kernel to use
-
DCSVM
public DCSVM()
Creates a new DC-SVM for the RBF kernel
-
DCSVM
public DCSVM(DCSVM toCopy)
Copy Constructor- Parameters:
toCopy- object to copy
-
-
Method Detail
-
setStartLevel
public void setStartLevel(int l_max)
The DC-SVM algorithm works by creating a hierarchy of levels, and iteratively refining the solution from one level to the next. Level 0 corresponds to the exact SVM solution, and higher levels are courser approximations. This method controls which level the training starts at.- Parameters:
l_max- which level to start the training at.
-
getStartLevel
public int getStartLevel()
- Returns:
- which level to start the training at.
-
setEndLevel
public void setEndLevel(int l_early)
The DC-SVM algorithm works by creating a hierarchy of levels, and iteratively refining the solution from one level to the next. Level 0 corresponds to the exact SVM solution, and higher levels are courser approximations. This method controls which level the training stops at, with 0 being the latest it can stop. The default stopping level is 3.- Parameters:
l_early- which level to stop the training at, and use for classification.
-
getEndLevel
public int getEndLevel()
- Returns:
- which level to stop the training at, and use for classification.
-
setClusterSampleSize
public void setClusterSampleSize(int m)
At each level of the DC-SVM training, a clustering algorithm is used to divide the dataset into sub-groups for independent training. Increasing the number of points used for clustering improves model accuracy, but also increases training time. The default value is 2000. This value may need to be increased if using a higher staring level.- Parameters:
m- the number of data points to sample for each cluster size
-
getClusterSampleSize
public int getClusterSampleSize()
-
classify
public CategoricalResults classify(DataPoint data)
Description copied from interface:ClassifierPerforms classification on the given data point.- Specified by:
classifyin interfaceClassifier- Parameters:
data- the data point to classify- Returns:
- the results of the classification.
-
getScore
public double getScore(DataPoint dp)
Description copied from interface:BinaryScoreClassifierReturns the numeric score for predicting a class of a given data point, where the sign of the value indicates which class the data point is predicted to belong to.- Specified by:
getScorein interfaceBinaryScoreClassifier- Parameters:
dp- the data point to predict the class label of- Returns:
- the score for the given data point
-
train
public void train(ClassificationDataSet dataSet, boolean parallel)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train onparallel-trueif multiple threads should be used to train the model.falseif it should be done in a single threaded manner.
-
supportsWeightedData
public boolean supportsWeightedData()
Description copied from interface:ClassifierIndicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.- Specified by:
supportsWeightedDatain interfaceClassifier- Returns:
- true if the model supports weighted data, false otherwise
-
clone
public DCSVM clone()
- Specified by:
clonein interfaceBinaryScoreClassifier- Specified by:
clonein interfaceClassifier- Overrides:
clonein classjava.lang.Object
-
setC
public void setC(double C)
Sets the complexity parameter of SVM. The larger the C value the harder the margin SVM will attempt to find. Lower values of C allow for more misclassification errors.- Parameters:
C- the soft margin parameter
-
getC
public double getC()
Returns the soft margin complexity parameter of the SVM- Returns:
- the complexity parameter of the SVM
-
-
DataMelt 3.0 © DataMelt by jWork.ORG