Support Vector Machine Classifier (SVM)
Operation | Computational methods | Programming Interface |
Mathematical formulation
Programming Interface
- template<typenameFloat= float, typenameMethod= method::by_default, typenameTask= task::by_default, typenameKernel= linear_kernel::descriptor<Float>>classdescriptor
- Template Parameters
- Float– The floating-point type that the algorithm uses for intermediate computations. Can befloatordouble.
- Task– Tag-type that specifies the type of the problem to solve. Can betask::classification,task::nu_classification,task::regression, ortask::nu_regression.
Constructors- descriptor(constKernel &kernel= kernel_t{})
- Creates a new instance of the class with the given descriptor of the kernel function.
Properties- doubletau
- The threshold parameter
for computing the quadratic coefficient.
Default value: 1e-6.- Getter & Setter
double get_tau() const
auto & set_tau(double value)
- Invariants
tau > 0.0
- doublenu
- Getter & Setter
template> double get_nu() const
template> auto & set_nu(double value)
- Invariants
0 < nu <= 1
- doubleepsilon
- The epsilon. Used withtask::regressiononly.Default value: 0.1.
- Getter & Setter
template> double get_epsilon() const
template> auto & set_epsilon(double value)
- Invariants
epsilon >= 0
- doublec
- The upper bound
in constraints of the quadratic optimization problem. Used with
task::classification,task::regression, andtask::nu_regression.Default value: 1.0.- Getter & Setter
template> double get_c() const
template> auto & set_c(double value)
- Invariants
c > 0
- boolshrinking
- A flag that enables the use of a shrinking optimization technique. Used withmethod::smosplit-finding method only.Default value: true.
- Getter & Setter
bool get_shrinking() const
auto & set_shrinking(bool value)
- constKernel &kernel
- The descriptor of kernel function
. Can be
linear_kernel::descriptororpolynomial_kernel::descriptororrbf_kernel::descriptororsigmoid_kernel::descriptor.- Getter & Setter
const Kernel & get_kernel() const
auto & set_kernel(const Kernel &kernel)
- doublecache_size
- The size of cache (in megabytes) for storing the values of the kernel matrix.Default value: 200.0.
- Getter & Setter
double get_cache_size() const
auto & set_cache_size(double value)
- Invariants
cache_size >= 0.0
- std::int64_tclass_count
- The number of classes. Used withtask::classificationandtask::nu_classification.Default value: 2.
- Getter & Setter
template> std::int64_t get_class_count() const
template> auto & set_class_count(std::int64_t value)
- Invariants
class_count >= 2
- std::int64_tmax_iteration_count
- The maximum number of iterations
.
Default value: 100000.- Getter & Setter
std::int64_t get_max_iteration_count() const
auto & set_max_iteration_count(std::int64_t value)
- Invariants
max_iteration_count >= 0
- doubleaccuracy_threshold
- The threshold
for the stop condition.
Default value: 0.0.- Getter & Setter
double get_accuracy_threshold() const
auto & set_accuracy_threshold(double value)
- Invariants
accuracy_threshold >= 0.0
- structsmo
- Tag-type that denotes SMO computational method.
- structthunder
- Tag-type that denotes Thunder computational method.
- structclassification
- Tag-type that parameterizes entities that are used for solving classification problem.
- structnu_classification
- Tag-type that parameterizes entities that are used for solving nu-classification problem.
- structnu_regression
- Tag-type that parameterizes entities used for solving nu-regression problem.
- structregression
- Tag-type that parameterizes entities used for solving regression problem.
- Alias tag-type for classification task.
- Template Parameters
- Task– Tag-type that specifies the type of the problem to solve. Can betask::classification,task::nu_classification,task::regression, ortask::nu_regression.
Constructors- model()
- Creates a new instance of the class with the default property values.
Public Methods- std::int64_tget_support_vector_count()const
- The number of support vectors.
Properties- A
table for
task::classificationandtask::nu_classificationand atable for
task::regressionandtask::nu_regressioncontaining coefficients of Lagrange multiplier.Default value: table{}.- Getter & Setter
const table & get_coeffs() const
auto & set_coeffs(const table &value)
- doublebias
- The bias.Default value: 0.0.
- Getter & Setter
double get_bias() const
auto & set_bias(double value)
- A
table for
task::classificationandtask::nu_classificationand atable for
task::regressionandtask::nu_regressioncontaining constants in decision function.- Getter & Setter
const table & get_biases() const
auto & set_biases(const table &value)
- std::int64_tsecond_class_label
- The second unique value in class labels. Used withtask::classificationandtask::nu_classification.
- Getter & Setter
std::int64_t get_second_class_label() const
template> auto & set_second_class_label(std::int64_t value)
- A
table containing support vectors. Where
- number of support vectors.
Default value: table{}.- Getter & Setter
const table & get_support_vectors() const
auto & set_support_vectors(const table &value)
- std::int64_tfirst_class_label
- The first unique value in class labels. Used withtask::classificationandtask::nu_classification.
- Getter & Setter
std::int64_t get_first_class_label() const
template> auto & set_first_class_label(std::int64_t value)
- std::int64_tfirst_class_response
- The first unique value in class responses. Used withtask::classificationandtask::nu_classification.
- Getter & Setter
std::int64_t get_first_class_response() const
template> auto & set_first_class_response(std::int64_t value)
- std::int64_tsecond_class_response
- The second unique value in class responses. Used withtask::classificationandtask::nu_classification.
- Getter & Setter
std::int64_t get_second_class_response() const
template> auto & set_second_class_response(std::int64_t value)
- Template Parameters
- Task– Tag-type that specifies the type of the problem to solve. Can beoneapi::dal::svm::task::classification,oneapi::dal::svm::task::nu_classification,oneapi::dal::svm::task::regression, oroneapi::dal::svm::task::nu_regression.
ConstructorsProperties- The vector of labels
for the training set
.
Default value: table{}.- Getter & Setter
const table & get_labels() const
auto & set_labels(const table &value)
- The vector of weights
for the training set
.
Default value: table{}.- Getter & Setter
const table & get_weights() const
auto & set_weights(const table &value)
- The vector of responses
for the training set
.
Default value: table{}.- Getter & Setter
const table & get_responses() const
auto & set_responses(const table &value)
- The training set
.
Default value: table{}.- Getter & Setter
const table & get_data() const
auto & set_data(const table &value)
- Template Parameters
- Task– Tag-type that specifies the type of the problem to solve. Can beoneapi::dal::svm::task::classification,oneapi::dal::svm::task::nu_classification,oneapi::dal::svm::task::regression, oroneapi::dal::svm::task::nu_regression.
Constructors- train_result()
- Creates a new instance of the class with the default property values.
Public Methods- std::int64_tget_support_vector_count()const
- The number of support vectors.
Properties- A
table for
task::classificationandtask::classificationandtable for
task::regressionandtask::nu_regressioncontaining coefficients of Lagrange multiplier.Default value: table{}.- Getter & Setter
const table & get_coeffs() const
auto & set_coeffs(const table &value)
- doublebias
- The bias.Default value: 0.0.
- Getter & Setter
double get_bias() const
auto & set_bias(double value)
- A
table for
task::classificationandtask::classificationandtable for
task::regressionandtask::nu_regressioncontaining constants in decision function.- Getter & Setter
const table & get_biases() const
auto & set_biases(const table &value)
- The trained SVM model.Default value: model<Task>{}.
- Getter & Setter
const model< Task > & get_model() const
auto & set_model(const model< Task > &value)
- A
table containing support vectors, where
is the number of support vectors.
Default value: table{}.- Getter & Setter
const table & get_support_vectors() const
auto & set_support_vectors(const table &value)
- A
table containing support indices.
Default value: table{}.- Getter & Setter
const table & get_support_indices() const
auto & set_support_indices(const table &value)
- template<typenameDescriptor> svm::train_resulttrain(constDescriptor &desc,constsvm::train_input &input)
- Parameters
- desc– SVM algorithm descriptorsvm::descriptor.
- input– Input data for the training operation
- Preconditions
input.data.is_empty == false
input.labels.is_empty == false
input.labels.column_count == 1
input.data.row_count == input.labels.row_count
- Template Parameters
- Task– Tag-type that specifies the type of the problem to solve. Can beoneapi::dal::svm::task::classification,oneapi::dal::svm::task::nu_classification,oneapi::dal::svm::task::regression, oroneapi::dal::svm::task::nu_regression.
ConstructorsProperties- The dataset for inference
.
Default value: table{}.- Getter & Setter
const table & get_data() const
auto & set_data(const table &value)
- The trained SVM model.Default value: model<Task>{}.
- Getter & Setter
const model< Task > & get_model() const
auto & set_model(const model< Task > &value)
- Template Parameters
- Task– Tag-type that specifies the type of the problem to solve. Can beoneapi::dal::svm::task::classification,oneapi::dal::svm::task::nu_classification,oneapi::dal::svm::task::regression, oroneapi::dal::svm::task::nu_regression.
Constructors- infer_result()
- Creates a new instance of the class with the default property values.
Properties- The
table with the predicted labels.
Default value: table{}.- Getter & Setter
const table & get_labels() const
auto & set_labels(const table &value)
- The
table with the predicted class. Used with
oneapi::dal::svm::task::classificationandoneapi::dal::svm::task::nu_classification. decision function for each observation.Default value: table{}.- Getter & Setter
const table & get_decision_function() const
template> auto & set_decision_function(const table &value)
- The
table with the predicted responses.
Default value: table{}.- Getter & Setter
const table & get_responses() const
auto & set_responses(const table &value)
- template<typenameDescriptor> svm::infer_resultinfer(constDescriptor &desc,constsvm::infer_input &input)
- Parameters
- desc– SVM algorithm descriptorsvm::descriptor.
- input– Input data for the inference operation
- Preconditions
input.data.is_empty == false