![]() |
Rosetta Utilities
2015.09
|
#include <math.h>
#include <cstdio>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <locale.h>
#include <iostream>
#include <cassert>
#include "Svm.hh"
Classes | |
class | Cache |
struct | Cache::head_t |
class | QMatrix |
class | Kernel |
class | Solver |
struct | Solver::SolutionInfo |
class | Solver_NU |
class | SVC_Q |
class | ONE_CLASS_Q |
class | SVR_Q |
struct | decision_function |
Macros | |
#define | INF HUGE_VAL |
#define | TAU 1e-12 |
#define | Malloc(type, n) (type *)malloc((n)*sizeof(type)) |
Typedefs | |
typedef float | Qfloat |
typedef signed char | schar |
Functions | |
template<class T > | |
static T | min (T x, T y) |
template<class T > | |
static T | max (T x, T y) |
template<class T > | |
static void | swap (T &x, T &y) |
template<class S , class T > | |
static void | clone (T *&dst, S *src, int n) |
static double | powi (double base, int times) |
static void | print_string_stdout (const char *s) |
static void | info (const char *fmt,...) |
static void | solve_c_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, double Cp, double Cn) |
static void | solve_nu_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si) |
static void | solve_one_class (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si) |
static void | solve_epsilon_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si) |
static void | solve_nu_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si) |
static decision_function | svm_train_one (const svm_problem *prob, const svm_parameter *param, double Cp, double Cn) |
static void | sigmoid_train (int l, const double *dec_values, const double *labels, double &A, double &B) |
static double | sigmoid_predict (double decision_value, double A, double B) |
static void | multiclass_probability (int k, double **r, double *p) |
static void | svm_binary_svc_probability (const svm_problem *prob, const svm_parameter *param, double Cp, double Cn, double &probA, double &probB) |
static double | svm_svr_probability (const svm_problem *prob, const svm_parameter *param) |
static void | svm_group_classes (const svm_problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm) |
svm_model * | svm_train (const svm_problem *prob, const svm_parameter *param) |
void | svm_cross_validation (const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target) |
int | svm_get_svm_type (const svm_model *model) |
int | svm_get_nr_class (const svm_model *model) |
void | svm_get_labels (const svm_model *model, int *label) |
void | svm_get_sv_indices (const svm_model *model, int *indices) |
int | svm_get_nr_sv (const svm_model *model) |
double | svm_get_svr_probability (const svm_model *model) |
double | svm_predict_values (const svm_model *model, const svm_node *x, double *dec_values) |
double | svm_predict (const svm_model *model, const svm_node *x) |
double | svm_predict_probability (const svm_model *model, const svm_node *x, double *prob_estimates) |
int | svm_save_model (const char *model_file_name, const svm_model *model) |
static char * | readline (FILE *input) |
svm_model * | svm_load_model (const char *model_file_name) |
void | svm_free_model_content (svm_model *model_ptr) |
void | svm_free_and_destroy_model (svm_model **model_ptr_ptr) |
void | svm_destroy_param (svm_parameter *param) |
const char * | svm_check_parameter (const svm_problem *prob, const svm_parameter *param) |
int | svm_check_probability_model (const svm_model *model) |
void | svm_set_print_string_function (void(*print_func)(const char *)) |
Variables | |
int | libsvm_version = LIBSVM_VERSION |
static void(* | svm_print_string )(const char *) = &print_string_stdout |
static const char * | svm_type_table [] |
static const char * | kernel_type_table [] |
static char * | line = NULL |
static int | max_line_len |
#define INF HUGE_VAL |
#define Malloc | ( | type, | |
n | |||
) | (type *)malloc((n)*sizeof(type)) |
#define TAU 1e-12 |
Referenced by Solver::select_working_set(), Solver_NU::select_working_set(), and Solver::Solve().
|
inlinestatic |
References basic::T().
Referenced by Kernel::Kernel(), Solver::Solve(), and SVC_Q::SVC_Q().
|
static |
Referenced by Solver::do_shrinking(), numeric::nls::lm_lmdif(), multiclass_probability(), utility::json_spirit::read_range_or_throw(), Solver::reconstruct_gradient(), sigmoid_train(), Solver::Solve(), solve_c_svc(), solve_epsilon_svr(), solve_nu_svc(), solve_nu_svr(), svm_svr_probability(), svm_train(), and svm_train_one().
|
inlinestatic |
References numeric::crick_equations::y().
Referenced by numeric::boltzmann_accept_probability(), utility::io::ozstream::buffer_size(), Cache::Cache(), Solver::calculate_rho(), Solver_NU::calculate_rho(), numeric::coordinate_fitting::FlatLookup< Real *, numeric::Size, Real >::closest_match(), numeric::deriv::dihedral_deriv_second(), Solver_NU::do_shrinking(), numeric::kdtree::HyperRectangle::extend(), numeric::coordinate_fitting::FlatLookup< Real *, numeric::Size, Real >::first_match(), numeric::kdtree::get_percentile_bounds(), utility::get_undefined_size(), numeric::fourier::kiss_fftndr(), numeric::fourier::kiss_fftndri(), utility::graph::RingDetection< Graph >::LengthOfSmallestCycleWithVertex(), utility::max(), numeric::max(), numeric::xyzVector< T >::maximum_value(), multiclass_probability(), numeric::expression_parser::MaxExpression::operator()(), numeric::deriv::p1_theta_deriv(), numeric::proj_angl(), numeric::fourier::kiss_fftndr_state::resize(), numeric::xyzTransform< numeric::Real >::rotation_axis(), numeric::model_quality::rsym_eigenval(), Solver_NU::select_working_set(), utility::io::skip(), Solver::Solve(), basic::svd::SVD_Solver::svdcmp(), svm_predict_probability(), numeric::kdtree::transform_percentile(), and numeric::deriv::x_and_dtheta_dx().
|
inlinestatic |
References numeric::crick_equations::y().
Referenced by numeric::boltzmann_accept_probability(), Solver::calculate_rho(), Solver_NU::calculate_rho(), numeric::deriv::dihedral_deriv_second(), numeric::kdtree::HyperRectangle::extend(), numeric::kdtree::get_percentile_bounds(), options_class::getMarkdownPage(), utility::graph::RingDetection< Graph >::LengthOfSmallestCycleWithVertex(), utility::options::OptionCollection::merged(), utility::min(), numeric::min(), numeric::xyzVector< T >::minimum_value(), utility::options::OptionCollection::n_part_prefix_match(), numeric::kdtree::nearest_neighbor(), numeric::kdtree::nearest_neighbors(), numeric::expression_parser::MinExpression::operator()(), numeric::deriv::p1_theta_deriv(), numeric::proj_angl(), numeric::random::reservoir_sample_accept_prob(), numeric::xyzTransform< numeric::Real >::rotation_axis(), utility::options::OptionCollection::show_option_help(), Solver::Solve(), solve_nu_svc(), solve_nu_svr(), basic::svd::SVD_Solver::svdcmp(), svm_check_parameter(), svm_predict_probability(), numeric::kdtree::transform_percentile(), numeric::kdtree::KDPointList::worst_distance(), utility::options::OptionCollection::wrapped(), and numeric::deriv::x_and_dtheta_dx().
References info(), Malloc, and max().
Referenced by svm_predict_probability().
Referenced by Kernel::k_function(), and Kernel::kernel_poly().
|
static |
Referenced by svm_set_print_string_function().
|
static |
References line.
Referenced by svm_load_model().
Referenced by svm_predict_probability().
|
static |
References info(), numeric::log(), and Malloc.
Referenced by svm_binary_svc_probability().
|
static |
References svm_parameter::eps, info(), svm_problem::l, svm_parameter::shrinking, Solver::Solve(), svm_problem::y, and numeric::crick_equations::y().
Referenced by svm_train_one().
|
static |
References svm_parameter::C, svm_parameter::eps, info(), svm_problem::l, svm_parameter::p, svm_parameter::shrinking, Solver::Solve(), svm_problem::y, and numeric::crick_equations::y().
Referenced by svm_train_one().
|
static |
References svm_parameter::eps, info(), svm_problem::l, min(), svm_parameter::nu, Solver::SolutionInfo::obj, Solver::SolutionInfo::r, Solver::SolutionInfo::rho, svm_parameter::shrinking, Solver_NU::Solve(), Solver::SolutionInfo::upper_bound_n, Solver::SolutionInfo::upper_bound_p, svm_problem::y, and numeric::crick_equations::y().
Referenced by svm_train_one().
|
static |
References C, svm_parameter::C, svm_parameter::eps, info(), svm_problem::l, min(), svm_parameter::nu, Solver::SolutionInfo::r, svm_parameter::shrinking, Solver_NU::Solve(), numeric::sum(), svm_problem::y, and numeric::crick_equations::y().
Referenced by svm_train_one().
|
static |
References svm_parameter::eps, svm_problem::l, svm_parameter::nu, svm_parameter::shrinking, and Solver::Solve().
Referenced by svm_train_one().
|
static |
References basic::options::OptionKeys::begin, svm_parameter::C, basic::options::OptionKeys::end, svm_problem::l, svm_model::label, Malloc, svm_parameter::nr_weight, svm_parameter::probability, sigmoid_train(), svm_destroy_param(), svm_free_and_destroy_model(), svm_predict_values(), svm_train(), swap(), svm_parameter::weight, svm_parameter::weight_label, svm_problem::x, and svm_problem::y.
Referenced by svm_train().
const char* svm_check_parameter | ( | const svm_problem * | prob, |
const svm_parameter * | param | ||
) |
References svm_parameter::C, C_SVC, svm_parameter::cache_size, svm_parameter::degree, svm_parameter::eps, EPSILON_SVR, svm_parameter::gamma, svm_parameter::kernel_type, svm_problem::l, svm_model::l, svm_model::label, LINEAR, Malloc, min(), svm_model::nr_class, svm_parameter::nu, NU_SVC, NU_SVR, ONE_CLASS, svm_parameter::p, POLY, PRECOMPUTED, svm_parameter::probability, RBF, svm_parameter::shrinking, SIGMOID, svm_parameter::svm_type, and svm_problem::y.
References C_SVC, EPSILON_SVR, NU_SVC, NU_SVR, svm_model::param, svm_model::probA, svm_model::probB, and svm_parameter::svm_type.
void svm_cross_validation | ( | const svm_problem * | prob, |
const svm_parameter * | param, | ||
int | nr_fold, | ||
double * | target | ||
) |
References basic::options::OptionKeys::begin, C_SVC, basic::options::OptionKeys::end, svm_problem::l, svm_model::l, svm_model::label, Malloc, svm_model::nr_class, NU_SVC, svm_parameter::probability, svm_free_and_destroy_model(), svm_get_nr_class(), svm_group_classes(), svm_predict(), svm_predict_probability(), svm_train(), svm_parameter::svm_type, swap(), svm_problem::x, and svm_problem::y.
Referenced by svm_svr_probability().
void svm_destroy_param | ( | svm_parameter * | param | ) |
References svm_parameter::weight, and svm_parameter::weight_label.
Referenced by svm_binary_svc_probability().
void svm_free_and_destroy_model | ( | svm_model ** | model_ptr_ptr | ) |
References svm_free_model_content().
Referenced by svm_binary_svc_probability(), and svm_cross_validation().
void svm_free_model_content | ( | svm_model * | model_ptr | ) |
References svm_model::label, and svm_model::nr_class.
References svm_model::nr_class.
Referenced by utility::libsvm::Svm_rosetta::get_nr_class(), utility::libsvm::Svm_rosetta::predict_probability(), and svm_cross_validation().
References svm_model::l.
References svm_model::l, and svm_model::sv_indices.
References svm_model::param, and svm_parameter::svm_type.
References EPSILON_SVR, NU_SVR, svm_model::param, svm_model::probA, and svm_parameter::svm_type.
|
static |
References svm_problem::l, svm_model::l, svm_model::label, Malloc, svm_model::nr_class, and svm_problem::y.
Referenced by svm_cross_validation(), and svm_train().
svm_model* svm_load_model | ( | const char * | model_file_name | ) |
References svm_parameter::coef0, utility::io::oc::cout, svm_parameter::degree, svm_model::free_sv, svm_parameter::gamma, svm_node::index, svm_parameter::kernel_type, kernel_type_table, svm_model::l, svm_model::label, line, Malloc, svm_model::nr_class, svm_model::nSV, svm_model::param, svm_model::probA, svm_model::probB, readline(), svm_model::rho, svm_model::SV, svm_model::sv_coef, svm_parameter::svm_type, svm_type_table, and svm_node::value.
Referenced by utility::libsvm::Svm_rosetta::Svm_rosetta().
References EPSILON_SVR, Malloc, svm_model::nr_class, NU_SVR, ONE_CLASS, svm_model::param, svm_predict_values(), and svm_parameter::svm_type.
Referenced by utility::libsvm::Svm_rosetta::predict(), svm_cross_validation(), and svm_predict_probability().
double svm_predict_probability | ( | const svm_model * | model, |
const svm_node * | x, | ||
double * | prob_estimates | ||
) |
References C_SVC, svm_model::label, Malloc, max(), min(), multiclass_probability(), svm_model::nr_class, NU_SVC, svm_model::param, svm_model::probA, svm_model::probB, sigmoid_predict(), svm_predict(), svm_predict_values(), and svm_parameter::svm_type.
Referenced by utility::libsvm::Svm_rosetta::predict_probability(), and svm_cross_validation().
References EPSILON_SVR, Kernel::k_function(), svm_model::l, svm_model::label, Malloc, svm_model::nr_class, svm_model::nSV, NU_SVR, ONE_CLASS, svm_model::param, svm_model::rho, numeric::sum(), svm_model::SV, svm_model::sv_coef, and svm_parameter::svm_type.
Referenced by svm_binary_svc_probability(), svm_predict(), and svm_predict_probability().
References svm_parameter::coef0, svm_parameter::degree, svm_parameter::gamma, svm_node::index, svm_parameter::kernel_type, kernel_type_table, svm_model::l, svm_model::label, svm_model::nr_class, svm_model::nSV, svm_model::param, POLY, PRECOMPUTED, svm_model::probA, svm_model::probB, RBF, svm_model::rho, SIGMOID, svm_model::SV, svm_model::sv_coef, svm_parameter::svm_type, svm_type_table, and svm_node::value.
void svm_set_print_string_function | ( | void(*)(const char *) | print_func | ) |
References print_string_stdout(), and svm_print_string.
|
static |
References info(), svm_problem::l, Malloc, svm_model::param, svm_parameter::probability, svm_cross_validation(), and svm_problem::y.
Referenced by svm_train().
svm_model* svm_train | ( | const svm_problem * | prob, |
const svm_parameter * | param | ||
) |
References decision_function::alpha, svm_parameter::C, EPSILON_SVR, svm_model::free_sv, info(), svm_problem::l, svm_model::l, svm_model::label, Malloc, svm_model::nr_class, svm_model::nSV, NU_SVR, ONE_CLASS, svm_model::param, svm_model::probA, svm_parameter::probability, svm_model::probB, svm_model::rho, decision_function::rho, svm_model::SV, svm_model::sv_coef, svm_model::sv_indices, svm_binary_svc_probability(), svm_group_classes(), svm_svr_probability(), svm_train_one(), svm_parameter::svm_type, svm_parameter::weight, svm_parameter::weight_label, svm_problem::x, numeric::crick_equations::x(), and svm_problem::y.
Referenced by svm_binary_svc_probability(), and svm_cross_validation().
|
static |
References decision_function::alpha, C_SVC, EPSILON_SVR, info(), svm_problem::l, Malloc, NU_SVC, NU_SVR, Solver::SolutionInfo::obj, ONE_CLASS, Solver::SolutionInfo::rho, decision_function::rho, solve_c_svc(), solve_epsilon_svr(), solve_nu_svc(), solve_nu_svr(), solve_one_class(), svm_parameter::svm_type, Solver::SolutionInfo::upper_bound_n, Solver::SolutionInfo::upper_bound_p, and svm_problem::y.
Referenced by svm_train().
|
inlinestatic |
References basic::T(), numeric::crick_equations::x(), and numeric::crick_equations::y().
Referenced by Cache::get_data(), utility::insert_middle(), utility::json_spirit::Value_impl< Config >::operator=(), svm_binary_svc_probability(), svm_cross_validation(), utility::keys::SmallKeyMap< K, T >::swap(), utility::keys::SmallKeyVector< PathVectorOptionKey, PathVectorOption >::swap(), utility::vectorL< SSize, T, A >::swap(), utility::keys::swap(), numeric::MathMatrix< Real >::swap_cols(), Cache::swap_index(), Kernel::swap_index(), Solver::swap_index(), SVC_Q::swap_index(), ONE_CLASS_Q::swap_index(), SVR_Q::swap_index(), and numeric::MathMatrix< Real >::swap_rows().
|
static |
Referenced by svm_load_model(), and svm_save_model().
int libsvm_version = LIBSVM_VERSION |
|
static |
Referenced by utility::file_contents(), utility::options::OptionCollection::load_options_from_stream(), basic::resource_manager::locator::FileListResourceLocator::locate_resource_stream(), basic::sampling::orientations::QuaternionGrid::QuaternionGrid(), numeric::interpolation::Histogram< typename, typename >::read_from_db(), utility::ReadFromFileOrDie(), readline(), utility::slurp(), numeric::interpolation::spline_from_file(), and svm_load_model().
|
static |
|
static |
Referenced by svm_set_print_string_function().
|
static |
Referenced by svm_load_model(), and svm_save_model().