MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / SVC

Class SVC

include/thundersvm/model/svc.h:17–71  ·  view source on GitHub ↗

* @brief Support Vector Machine for classification */

Source from the content-addressed store, hash-verified

15 * @brief Support Vector Machine for classification
16 */
17class SVC : public SvmModel {
18public:
19
20 void train(const DataSet &dataset, SvmParam param) override;
21
22 vector<float_type> predict(const DataSet::node2d &instances, int batch_size) override;
23
24protected:
25 /**
26 * train a binary SVC model \f$SVM_{i,j}\f$ for class i and class j.
27 * @param [in] dataset original dataset
28 * @param [in] i
29 * @param [in] j
30 * @param [out] alpha optimization variables \f$\boldsymbol{\alpha}\f$ in dual problem, should be initialized with
31 * the same size of the number
32 * of instances in this binary problem
33 * @param [out] rho bias term \f$b\f$ in dual problem
34 */
35 virtual void train_binary(const DataSet &dataset, int i, int j, SyncArray<float_type> &alpha, float_type &rho);
36
37 void model_setup(const DataSet &dataset, SvmParam &param) override;
38
39private:
40
41 /**
42 * predict final labels using voting. \f$SVM_{i,j}\f$ will vote for class i if its decision value greater than 0,
43 * otherwise it will vote for class j. The final label will be the one with the most votes.
44 * @param dec_values decision values for each instance and each binary model
45 * @param n_instances the number of instances to be predicted
46 * @return final labels of each instances
47 */
48 vector<float_type> predict_label(const SyncArray<float_type> &dec_values, int n_instances) ;
49
50 /**
51 * perform probability training.
52 * If param.probability equals to 1, probability_train() will be called to train probA and probB and the model will
53 * be able to produce probability outputs.
54 * @param dataset training dataset, should be already grouped using group_classes().
55 */
56 void probability_train(const DataSet &dataset);
57
58 /**
59 * transform n_binary_models binary probabilities in to probabilities of each class
60 * @param [in] r n_binary_models binary probabilities
61 * @param [out] p probabilities for each class
62 */
63 void multiclass_probability(const vector<vector<float_type>> &r, vector<float_type> &p) const;
64
65 /**
66 * class weight for each class, the final \f$C_{i}\f$ of class i will be \f$C*\text{c_weight}[i]\f$
67 */
68 vector<float_type> c_weight;
69
70
71};
72
73#endif //THUNDERSVM_SVC_H

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected