![]() |
KSquare Utilities
|
Namespce used to wrap implementation of libSVM version 2.89. More...
Classes | |
| class | Cache |
| struct | decision_function |
| class | Kernel |
| class | ONE_CLASS_Q |
| class | QMatrix |
| class | Solver |
| class | Solver_NU |
| class | SVC_Q |
| struct | Svm_Model |
| struct | svm_parameter |
| struct | svm_problem |
| class | SVR_Q |
Typedefs | |
| typedef float | Qfloat |
| typedef signed char | schar |
| typedef XmlElementTemplate< Svm_Model > | XmlElementSvm_Model |
| typedef XmlElementSvm_Model * | XmlElementSvm_ModelPtr |
Functions | |
| template<class S , class T > | |
| void | clone (T *&dst, S *src, kkint32 n) |
| template<class T > | |
| T * | GrowAllocation (T *src, kkint32 origSize, kkint32 newSize) |
| Kernel_Type | Kernel_Type_FromStr (KKStr s) |
| KKStr | Kernel_Type_ToStr (Kernel_Type kernelType) |
| void | multiclass_probability (kkint32 numClasses, double **pairwiseProbs, double *classProb) |
| double | powi (double base, kkint32 times) |
| double | sigmoid_predict (double decision_value, double A, double B) |
| void | sigmoid_train (kkint32 numExamples, const double *dec_values, const double *labels, double &A, double &B) |
| void | solve_c_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, double Cp, double Cn, RunLog &_log) |
| void | solve_epsilon_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log) |
| void | solve_nu_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log) |
| void | solve_one_class (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, RunLog &_log) |
| const char * | svm_check_parameter (const struct svm_problem *prob, const struct svm_parameter *param) |
| kkint32 | svm_check_probability_model (const struct Svm_Model *model) |
| void | svm_cross_validation (const svm_problem &prob, const svm_parameter ¶m, kkint32 nr_fold, double *target, RunLog &log) |
| void | svm_destroy_model (struct Svm_Model *&model) |
| void | svm_destroy_param (struct svm_parameter *¶m) |
| void | svm_get_labels (const struct Svm_Model *model, kkint32 *label) |
| kkint32 | svm_get_nr_class (const struct Svm_Model *model) |
| kkint32 | svm_get_svm_type (const struct Svm_Model *model) |
| double | svm_get_svr_probability (const struct Svm_Model *model) |
| double | svm_predict (const struct Svm_Model *model, const FeatureVector &x) |
| double | svm_predict_probability (Svm_Model *model, const FeatureVector &x, double *prob_estimates, kkint32 *votes) |
| void | svm_predict_values (const Svm_Model *model, const FeatureVector &x, double *dec_values) |
| Svm_Model * | svm_train (const svm_problem &prob, const svm_parameter ¶m, RunLog &log) |
| decision_function | svm_train_one (const svm_problem &prob, const svm_parameter ¶m, double Cp, double Cn, RunLog &_log) |
| SVM_Type | SVM_Type_FromStr (KKStr s) |
| KKStr | SVM_Type_ToStr (SVM_Type svmType) |
| template<class T > | |
| void | swap (T &x, T &y) |
Variables | |
| kkint32 | libsvm_version |
| void(* | svm_print_string )(const char *) = &print_string_stdout |
Namespce used to wrap implementation of libSVM version 2.89.
There is more than one version of libSVM implemented in the library. To prevent name conflicts between them each one was wrapped in their own namespace.
libSVM is a Support Vector Machine implementation done by "Chih-Chung Chang" and "Chih-Jen Lin". It was downloaded from http://www.csie.ntu.edu.tw/~cjlin/libsvm/. The source code was modified by Kurt Kramer. The primary changes to this implementation involves the replacement of the sparse data-structure in the original implementation with fixed length array implemented through the "FeatureVector" class and the ability to specify a sub-set of features to be utilized via the "FeatureNumList" class. This allows us to load in a single set of training data with all its features that can then be used for multiple Support Vector Machine instances where each instance utilizes a different set of features. The use of this version of libSVM(SVM289_MFS) is via the "ModelSvmBase" class.
| typedef float SVM289_MFS::Qfloat |
| typedef signed char SVM289_MFS::schar |
|
strong |
| Enumerator | |
|---|---|
| Kernel_NULL | |
| LINEAR | |
| POLY | |
| RBF | |
| SIGMOID | |
| PRECOMPUTED | |
|
strong |
|
inline |
|
inline |
| Kernel_Type SVM289_MFS::Kernel_Type_FromStr | ( | KKStr | s | ) |
Definition at line 564 of file svm2.cpp.
References KKB::KKStr::EqualIgnoreCase(), Kernel_NULL, LINEAR, KKB::KKStr::operator==(), POLY, PRECOMPUTED, RBF, SIGMOID, and KKB::KKStr::Upper().
Referenced by SVM289_MFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ProcessSvmParameter(), and SVM289_MFS::Svm_Model::ReadXML().
| KKStr SVM289_MFS::Kernel_Type_ToStr | ( | Kernel_Type | kernelType | ) |
Definition at line 580 of file svm2.cpp.
References LINEAR, POLY, PRECOMPUTED, RBF, and SIGMOID.
Referenced by SVM289_MFS::svm_parameter::ToTabDelStr(), and SVM289_MFS::Svm_Model::WriteXML().
| void SVM289_MFS::multiclass_probability | ( | kkint32 | numClasses, |
| double ** | pairwiseProbs, | ||
| double * | classProb | ||
| ) |
Implements method 2 from the multiclass_prob paper by Wu, Lin, and Weng
| [in] | numClasses | |
| [in] | pairwiseProbs | |
| [out] | classProb |
| numClasses | Number of Classes. |
| pairwiseProbs | Pair-wise Probabilities. |
| classProb | Class Probability |
Definition at line 3009 of file svm2.cpp.
References info().
|
inline |
| double SVM289_MFS::sigmoid_predict | ( | double | decision_value, |
| double | A, | ||
| double | B | ||
| ) |
| void SVM289_MFS::sigmoid_train | ( | kkint32 | numExamples, |
| const double * | dec_values, | ||
| const double * | labels, | ||
| double & | A, | ||
| double & | B | ||
| ) |
Definition at line 2850 of file svm2.cpp.
References info().
Referenced by svm_binary_svc_probability().
| void SVM289_MFS::solve_c_svc | ( | const svm_problem * | prob, |
| const svm_parameter * | param, | ||
| double * | alpha, | ||
| Solver::SolutionInfo * | si, | ||
| double | Cp, | ||
| double | Cn, | ||
| RunLog & | _log | ||
| ) |
Definition at line 2414 of file svm2.cpp.
References SVM289_MFS::svm_parameter::eps, SVM289_MFS::svm_problem::numTrainExamples, SVM289_MFS::svm_parameter::shrinking, SVM289_MFS::Solver::Solve(), SVM289_MFS::SVC_Q::SVC_Q(), and SVM289_MFS::svm_problem::y.
Referenced by svm_train_one().
| void SVM289_MFS::solve_epsilon_svr | ( | const svm_problem * | prob, |
| const svm_parameter * | param, | ||
| double * | alpha, | ||
| Solver::SolutionInfo * | si, | ||
| RunLog & | _log | ||
| ) |
Definition at line 2613 of file svm2.cpp.
References SVM289_MFS::svm_parameter::C, SVM289_MFS::svm_parameter::eps, info(), SVM289_MFS::svm_problem::numTrainExamples, SVM289_MFS::svm_parameter::p, SVM289_MFS::svm_parameter::shrinking, SVM289_MFS::Solver::Solve(), SVM289_MFS::SVR_Q::SVR_Q(), and SVM289_MFS::svm_problem::y.
Referenced by svm_train_one().
| void SVM289_MFS::solve_nu_svc | ( | const svm_problem * | prob, |
| const svm_parameter * | param, | ||
| double * | alpha, | ||
| Solver::SolutionInfo * | si, | ||
| RunLog & | _log | ||
| ) |
Definition at line 2476 of file svm2.cpp.
References SVM289_MFS::svm_parameter::eps, info(), SVM289_MFS::svm_parameter::nu, SVM289_MFS::svm_problem::numTrainExamples, SVM289_MFS::Solver::SolutionInfo::obj, SVM289_MFS::Solver::SolutionInfo::r, SVM289_MFS::Solver::SolutionInfo::rho, SVM289_MFS::svm_parameter::shrinking, SVM289_MFS::Solver_NU::Solve(), SVM289_MFS::SVC_Q::SVC_Q(), SVM289_MFS::Solver::SolutionInfo::upper_bound_n, SVM289_MFS::Solver::SolutionInfo::upper_bound_p, and SVM289_MFS::svm_problem::y.
Referenced by svm_train_one().
| void SVM289_MFS::solve_one_class | ( | const svm_problem * | prob, |
| const svm_parameter * | param, | ||
| double * | alpha, | ||
| Solver::SolutionInfo * | si, | ||
| RunLog & | _log | ||
| ) |
Definition at line 2558 of file svm2.cpp.
References SVM289_MFS::svm_parameter::eps, SVM289_MFS::svm_parameter::nu, SVM289_MFS::svm_problem::numTrainExamples, SVM289_MFS::ONE_CLASS_Q::ONE_CLASS_Q(), SVM289_MFS::svm_parameter::shrinking, and SVM289_MFS::Solver::Solve().
Referenced by svm_train_one().
| const char* SVM289_MFS::svm_check_parameter | ( | const struct svm_problem * | prob, |
| const struct svm_parameter * | param | ||
| ) |
| void SVM289_MFS::svm_cross_validation | ( | const svm_problem & | prob, |
| const svm_parameter & | param, | ||
| kkint32 | nr_fold, | ||
| double * | target, | ||
| RunLog & | log | ||
| ) |
Definition at line 3661 of file svm2.cpp.
References C_SVC, SVM289_MFS::svm_problem::FileDesc(), NU_SVC, SVM289_MFS::svm_problem::numTrainExamples, SVM289_MFS::svm_parameter::probability, SVM289_MFS::svm_problem::SelFeatures(), svm_destroy_model(), svm_get_nr_class(), svm_group_classes(), SVM289_MFS::svm_problem::svm_problem(), svm_train(), SVM289_MFS::svm_parameter::svm_type, and SVM289_MFS::svm_problem::y.
Referenced by svm_svr_probability().
| void SVM289_MFS::svm_destroy_model | ( | struct Svm_Model *& | model | ) |
Definition at line 4611 of file svm2.cpp.
Referenced by svm_cross_validation(), KKMLL::ModelSvmBase::TrainModel(), and KKMLL::ModelSvmBase::~ModelSvmBase().
| void SVM289_MFS::svm_destroy_param | ( | struct svm_parameter *& | param | ) |
Referenced by svm_cross_validation().
| double SVM289_MFS::svm_get_svr_probability | ( | const struct Svm_Model * | model | ) |
| double SVM289_MFS::svm_predict | ( | const struct Svm_Model * | model, |
| const FeatureVector & | x | ||
| ) |
Referenced by KKMLL::ModelSvmBase::Predict(), and svm_predict_probability().
| double SVM289_MFS::svm_predict_probability | ( | Svm_Model * | model, |
| const FeatureVector & | x, | ||
| double * | prob_estimates, | ||
| kkint32 * | votes | ||
| ) |
Definition at line 3988 of file svm2.cpp.
References C_SVC, SVM289_MFS::Svm_Model::DecValues(), SVM289_MFS::Svm_Model::label, SVM289_MFS::Svm_Model::NormalizeProbability(), SVM289_MFS::Svm_Model::nr_class, NU_SVC, SVM289_MFS::Svm_Model::PairwiseProb(), SVM289_MFS::Svm_Model::param, SVM289_MFS::Svm_Model::probA, SVM289_MFS::Svm_Model::probB, SVM289_MFS::Svm_Model::ProbEstimates(), SVM289_MFS::svm_parameter::probParam, svm_predict(), svm_predict_values(), and SVM289_MFS::svm_parameter::svm_type.
Referenced by KKMLL::ModelSvmBase::Predict(), and KKMLL::ModelSvmBase::ProbabilitiesByClass().
| void SVM289_MFS::svm_predict_values | ( | const Svm_Model * | model, |
| const FeatureVector & | x, | ||
| double * | dec_values | ||
| ) |
Definition at line 3856 of file svm2.cpp.
References EPSILON_SVR, SVM289_MFS::Svm_Model::nr_class, SVM289_MFS::Svm_Model::nSV, NU_SVR, SVM289_MFS::Svm_Model::numSVs, ONE_CLASS, SVM289_MFS::Svm_Model::param, SVM289_MFS::Svm_Model::rho, SVM289_MFS::Svm_Model::sv_coef, and SVM289_MFS::svm_parameter::svm_type.
Referenced by svm_predict_probability().
| Svm_Model * SVM289_MFS::svm_train | ( | const svm_problem & | prob, |
| const svm_parameter & | param, | ||
| RunLog & | log | ||
| ) |
Definition at line 3345 of file svm2.cpp.
References SVM289_MFS::decision_function::alpha, SVM289_MFS::svm_parameter::C, EPSILON_SVR, KKMLL::FeatureVectorList::FeatureVectorList(), SVM289_MFS::svm_problem::FileDesc(), info(), SVM289_MFS::Svm_Model::label, SVM289_MFS::Svm_Model::nr_class, SVM289_MFS::svm_parameter::nr_weight, SVM289_MFS::Svm_Model::nSV, NU_SVR, SVM289_MFS::Svm_Model::numSVs, SVM289_MFS::svm_problem::numTrainExamples, ONE_CLASS, SVM289_MFS::Svm_Model::probA, SVM289_MFS::svm_parameter::probability, SVM289_MFS::Svm_Model::probB, SVM289_MFS::Svm_Model::rho, SVM289_MFS::decision_function::rho, SVM289_MFS::svm_problem::SelFeatures(), SVM289_MFS::Svm_Model::sv_coef, svm_binary_svc_probability(), svm_group_classes(), SVM289_MFS::Svm_Model::Svm_Model(), SVM289_MFS::svm_problem::svm_problem(), svm_svr_probability(), svm_train_one(), SVM289_MFS::svm_parameter::svm_type, SVM289_MFS::svm_parameter::weight, SVM289_MFS::svm_parameter::weight_label, SVM289_MFS::Svm_Model::weOwnSupportVectors, and SVM289_MFS::svm_problem::y.
Referenced by svm_binary_svc_probability(), svm_cross_validation(), and KKMLL::ModelSvmBase::TrainModel().
| decision_function SVM289_MFS::svm_train_one | ( | const svm_problem & | prob, |
| const svm_parameter & | param, | ||
| double | Cp, | ||
| double | Cn, | ||
| RunLog & | _log | ||
| ) |
Definition at line 2744 of file svm2.cpp.
References SVM289_MFS::decision_function::alpha, C_SVC, KKB::KKStr::Concat(), EPSILON_SVR, KKB::KKException::KKException(), NU_SVC, NU_SVR, SVM289_MFS::svm_problem::numTrainExamples, ONE_CLASS, SVM289_MFS::Solver::SolutionInfo::rho, SVM289_MFS::decision_function::rho, solve_c_svc(), solve_epsilon_svr(), solve_nu_svc(), solve_nu_svr(), solve_one_class(), SVM289_MFS::svm_parameter::svm_type, and SVM289_MFS::svm_problem::y.
Referenced by svm_train().
Definition at line 534 of file svm2.cpp.
References C_SVC, EPSILON_SVR, KKB::KKStr::EqualIgnoreCase(), NU_SVC, NU_SVR, ONE_CLASS, KKB::KKStr::operator==(), SVM_NULL, and KKB::KKStr::Upper().
Referenced by SVM289_MFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ProcessSvmParameter(), and SVM289_MFS::Svm_Model::ReadXML().
Definition at line 549 of file svm2.cpp.
References C_SVC, EPSILON_SVR, NU_SVC, NU_SVR, and ONE_CLASS.
Referenced by SVM289_MFS::svm_parameter::ToTabDelStr(), and SVM289_MFS::Svm_Model::WriteXML().
|
inline |
| kkint32 SVM289_MFS::libsvm_version |
| void(* SVM289_MFS::svm_print_string)(const char *) = &print_string_stdout |