public class SVM extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
SVM.EX
Expectile regression learning scenario.
|
static class |
SVM.LS
Least squares regression learning scenario.
|
static class |
SVM.MC
Binary and multi-class learning scenario.
|
static class |
SVM.NPL
Neyman-Pearson lemma learning scenario.
|
static class |
SVM.QT
Quantile regression learning scenario.
|
static class |
SVM.ROC
Receiver Operating Characteristic curve learning scenario.
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
ENABLE_LOAD_WITHOUT_LIBRARY |
static int |
MAX_CPU |
| Constructor and Description |
|---|
SVM()
For quick demonstration initialize a least squares SVM using the trees dataset.
|
SVM(String scenario,
double[][] data,
double[] labels,
Config config)
Initializes an SVM with training data and optionally configuration options and a scenario.
|
SVM(String scenario,
LiquidData.Data data,
Config config)
Initializes an SVM with training data and optionally configuration options and a scenario.
|
SVM(String scenario,
LiquidData data,
Config config)
Initializes an SVM with training data and optionally configuration options and a scenario
and performs testing.
|
| Modifier and Type | Method and Description |
|---|---|
static double[][] |
calculateDataCover(int NNs,
double[][] data)
Helper function to calculate Voronoi centers that cover the
data set
s.t. |
void |
clean() |
protected void |
finalize() |
String |
getConfig(String name)
Gets configuration of this SVM
|
int[] |
getCover(int task) |
ResultAndErrors |
getLastResult()
Keeps the last result and errors around after
test(double[][], double[], java.lang.String...)ing. |
double[][] |
getSelectErrs()
Returns many information upon
select(java.lang.String...)ing. |
double[] |
getSolutionCoeffs(int task,
int cell,
int fold) |
int[] |
getSolutionSVs(int task,
int cell,
int fold) |
double[][] |
getTrainErrs()
Returns many information upon
train(java.lang.String...)ing. |
boolean |
isSelected()
Has the SVM already been selected.
|
boolean |
isTrained()
Has the SVM already been trained.
|
double[] |
predict(double[][] test,
String... argv)
Predicts labels for the given
test data. |
int |
readSVM(String filename) |
double[][] |
select(String... argv)
Selects the best hyperparameter pair according to validation error.
|
SVM |
setConfig(String name,
double value)
Sets configuration directly in the SVM.
|
SVM |
setConfig(String name,
double[] value)
Sets configuration directly in the SVM.
|
SVM |
setConfig(String name,
int value)
Sets configuration directly in the SVM.
|
SVM |
setConfig(String name,
String value)
Sets configuration directly in the SVM.
|
SVM |
setConfigAll(Config config)
Sets all the values in the
config in this SVM. |
ResultAndErrors |
test(double[][] test,
double[] labs,
String... argv)
Predicts labels for the given
test data and compares
these to the given labs. |
ResultAndErrors |
test(LiquidData.Data test,
String... argv)
Predicts labels for the given
test.x data and compares
these to the given test.y. |
double[][] |
train(String... argv)
Performs training on the hyperparameter grid.
|
public static boolean ENABLE_LOAD_WITHOUT_LIBRARY
public static final int MAX_CPU
public SVM()
LiquidData.treespublic SVM(String scenario, double[][] data, double[] labels, Config config)
SVM.LS, SVM.MC, SVM.QT, SVM.EX, SVM.NPL, or SVM.ROC.
After the training data and the configuration are set,
Config.train(boolean) and Config.select(boolean)
determine whether train(String...) and select(String...) should be started.
If config==NULL they are performed.public SVM(String scenario, LiquidData.Data data, Config config)
SVM.LS, SVM.MC, SVM.QT, SVM.EX, SVM.NPL, or SVM.ROC.
After the training data and the configuration are set,
Config.train(boolean) and Config.select(boolean)
determine whether train(String...) and select(String...) should be started.
If config==NULL they are performed.public SVM(String scenario, LiquidData data, Config config)
SVM.LS, SVM.MC, SVM.QT, SVM.EX, SVM.NPL, or SVM.ROC.
After the training data and the configuration are set,
Config.train(boolean) and Config.select(boolean)
determine whether train(String...) and select(String...) should be started.
If config==NULL they are performed.public double[][] getTrainErrs()
train(java.lang.String...)ing.
For every point in the hyperparametergrid, every fold,
every cell, and every task there is one line.public double[][] getSelectErrs()
select(java.lang.String...)ing.
For every cell, and every task there is one line.public ResultAndErrors getLastResult()
test(double[][], double[], java.lang.String...)ing.public double[][] train(String... argv)
argv can be used by experts in the same way
as in the svm-train command line program of liquidSVM interface.
Most users should rather use Config.argv - further command line arguments (for experts)getTrainErrs()public double[][] select(String... argv)
argv can be used by experts in the same way
as in the svm-select command line program of liquidSVM interface.
Most users should rather use Config.argv - further command line arguments (for experts)getSelectErrs()IllegalStateException - if the model has not been trainedpublic double[] predict(double[][] test,
String... argv)
test data.
argv can be used by experts in the same way
as in the svm-test command line program of liquidSVM interface.
Most users should rather use Config.test - array of test samples features (X)argv - further command line arguments (for experts)IllegalStateException - if the model has neither been trained nor selectedpublic ResultAndErrors test(double[][] test, double[] labs, String... argv)
test data and compares
these to the given labs.
argv can be used by experts in the same way
as in the svm-test command line program of liquidSVM interface.
Most users should rather use Config.test - array of test samples features (X)labs - array of test labelsargv - further command line arguments (for experts)IllegalStateException - if the model has neither been trained nor selectedpublic ResultAndErrors test(LiquidData.Data test, String... argv)
test.x data and compares
these to the given test.y.
argv can be used by experts in the same way
as in the svm-test command line program of liquidSVM interface.
Most users should rather use Config.test - array of test samplesargv - further command line arguments (for experts)IllegalStateException - if the model has neither been trained nor selectedpublic void clean()
protected void finalize()
throws Throwable
public static double[][] calculateDataCover(int NNs,
double[][] data)
data set
s.t. each cell should not have more than NNs samples.NNs - biggest size of cellsdata - data set to coverpublic SVM setConfig(String name, String value)
Config.name - value - public SVM setConfig(String name, int value)
Config.name - value - public SVM setConfig(String name, double value)
Config.name - value - public SVM setConfig(String name, double[] value)
Config.
The values get joined by spaces to form a string.name - value - public SVM setConfigAll(Config config)
config in this SVM.config - public String getConfig(String name)
name - key in tihs SVM.public boolean isTrained()
train(String...)public boolean isSelected()
select(String...)public int[] getCover(int task)
public int[] getSolutionSVs(int task,
int cell,
int fold)
public double[] getSolutionCoeffs(int task,
int cell,
int fold)
public int readSVM(String filename)
Copyright © 2018. All rights reserved.