Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Functions | Variables
Svm.cc File Reference
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdarg>
#include <climits>
#include <clocale>
#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

using Qfloat = float
 
using schar = signed char
 

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_modelsvm_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_modelsvm_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 = nullptr
 
static int max_line_len
 

Macro Definition Documentation

#define INF   HUGE_VAL
#define Malloc (   type,
 
)    (type *)malloc((n)*sizeof(type))
#define TAU   1e-12

Typedef Documentation

using Qfloat = float
using schar = signed char

Function Documentation

template<class S , class T >
static void clone ( T *&  dst,
S src,
int  n 
)
inlinestatic
static void info ( const char *  fmt,
  ... 
)
static
template<class T >
static T max ( T  x,
T  y 
)
inlinestatic

References numeric::crick_equations::y().

Referenced by pyrosetta.EnergyMethod::__call__(), PyMOL-RosettaServer.Matrix::__init__(), numeric::xyzTransform< numeric::Real >::align(), ExposedStrandMover::apply(), HBondReporter::bfactor(), ObjexxFCL::format::bite(), numeric::boltzmann_accept_probability(), utility::io::ozstream::buffer_size(), Cache::Cache(), Solver::calculate_rho(), Solver_NU::calculate_rho(), ObjexxFCL::DimensionExpressionMax::clone(), numeric::coordinate_fitting::FlatLookup< Real *, numeric::Size, Real >::closest_match(), numeric::coordinate_fitting::FlatLookup< Real *, numeric::Size, Real >::closest_match_subset(), numeric::fourier::SO3coeffs::coefLoc(), pyrosetta.numeric.alignment.rmsd_calc::coordinate_array_rmsd(), correct_rama(), numeric::deriv::dihedral_deriv_second(), Solver_NU::do_shrinking(), ObjexxFCL::format::E(), numeric::kdtree::HyperRectangle::extend(), ObjexxFCL::format::F(), ObjexxFCL::FArray1D< double >::FArray1D(), ObjexxFCL::FArray2D< double >::FArray2D(), ObjexxFCL::FArray3D< typename >::FArray3D(), ObjexxFCL::FArray4D< typename >::FArray4D(), ObjexxFCL::FArray5D< typename >::FArray5D(), ObjexxFCL::FArray6D< typename >::FArray6D(), mutant_modeler::figure_out_WT_seq(), numeric::coordinate_fitting::FlatLookup< Real *, numeric::Size, Real >::first_match(), fmt::BasicFormatter< CharType, ArgFormatter >::format(), full_length_rmsd_over_reside_list_general(), gen_pep_bb_sequential(), numeric::fourier::SO3coeffs::genWigner_ds(), pyrosetta.PyMOLRosettaServer::get_ends(), PyMOL-RosettaServer::get_ends(), numeric::kdtree::get_percentile_bounds(), arls_impl::get_procs_per_case(), utility::get_undefined_real(), utility::get_undefined_size(), numeric::VoxelGrid< typename >::GetIndex(), harvest_scores(), ObjexxFCL::format::I(), ObjexxFCL::KeyFArray1D< typename >::KeyFArray1D(), ObjexxFCL::KeyFArray2D< typename >::KeyFArray2D(), ObjexxFCL::KeyFArray3D< typename >::KeyFArray3D(), ObjexxFCL::KeyFArray4D< typename >::KeyFArray4D(), ObjexxFCL::KeyFArray5D< typename >::KeyFArray5D(), ObjexxFCL::KeyFArray6D< typename >::KeyFArray6D(), numeric::fourier::kiss_fftndr(), numeric::fourier::kiss_fftndri(), utility::graph::RingDetection< Graph >::LengthOfSmallestCycleWithVertex(), utility::tag::XMLErrorHandler::lines_near_error(), main(), utility::max(), ObjexxFCL::max(), numeric::max(), ObjexxFCL::Chunk< T >::max_size(), ObjexxFCL::ChunkVector< typename >::max_size(), numeric::xyzVector< core::Real >::maximum_value(), multiclass_probability(), numeric::interpolation::multilinear_interpolation(), pyrosetta.io.silent_file_map::open_compressed(), ObjexxFCL::DimensionExpressionMax::operator()(), numeric::expression_parser::MaxExpression::operator()(), numeric::deriv::p1_theta_deriv(), fmt::internal::parse_nonnegative_int(), DockFragmentsMover::process_fragfile(), numeric::proj_angl(), ObjexxFCL::format::repeat(), numeric::fourier::kiss_fftndr_state::resize(), numeric::xyzTransform< numeric::Real >::rotation_axis(), numeric::model_quality::rsym_eigenval(), ConsensusFragmentMover::run(), Solver_NU::select_working_set(), numeric::VoxelGrid< typename >::SetObjects(), numeric::VoxelGrid< typename >::SetupGrid(), ObjexxFCL::format::skip(), utility::io::skip(), numeric::fourier::SHT::so3CombineCoef(), Solver::Solve(), ObjexxFCL::format::space(), numeric::linear_algebra::svdcmp(), basic::svd::SVD_Solver::svdcmp(), svm_predict_probability(), pyrosetta.utility.array::to_structured_array(), numeric::kdtree::transform_percentile(), ObjexxFCL::Fstring::trimmed_whitespace_range(), ObjexxFCL::DimensionExpressionMax::value(), numeric::fourier::SO3coeffs::wignerSynthesis(), numeric::fourier::SO3coeffs::wignerSynthesisDiffSign(), numeric::fourier::SO3coeffs::wignerSynthesisSameSign(), ObjexxFCL::format::X(), numeric::deriv::x_and_dtheta_dx(), and numeric::HomogeneousTransform< double >::xform_magnitude().

template<class T >
static T min ( T  x,
T  y 
)
inlinestatic

References numeric::crick_equations::y().

Referenced by PyMOL-RosettaServer.Matrix::__init__(), numeric::xyzTransform< numeric::Real >::align(), ExposedStrandMover::apply(), zlib_stream::basic_zip_streambuf< Elem, Tr, ElemA, ByteT, ByteAT >::basic_zip_streambuf(), numeric::boltzmann_accept_probability(), calc_rama_scores(), calc_scores(), Solver::calculate_rho(), Solver_NU::calculate_rho(), ObjexxFCL::DimensionExpressionMin::clone(), DockFragmentsMover::cluster_frags(), ObjexxFCL::Fstring::copy(), correct_dunbrack(), correct_rama(), numeric::deriv::dihedral_deriv_second(), pyrosetta.bindings.pose::display_secstruct(), basic::thread_manager::RosettaThreadManager::do_multistage_work_vector_in_threads(), basic::thread_manager::RosettaThreadManager::do_work_vector_in_threads(), basic::thread_manager::RosettaThreadManager::do_work_vector_in_threads_no_locking(), ObjexxFCL::format::E(), numeric::kdtree::HyperRectangle::extend(), ObjexxFCL::format::F(), ObjexxFCL::FArray1D< double >::FArray1D(), ObjexxFCL::FArray2D< double >::FArray2D(), ObjexxFCL::FArray3D< typename >::FArray3D(), ObjexxFCL::FArray4D< typename >::FArray4D(), ObjexxFCL::FArray5D< typename >::FArray5D(), ObjexxFCL::FArray6D< typename >::FArray6D(), auto-DRRAFTER_setup_next_round::figure_out_next_round(), mutant_modeler::figure_out_WT_seq(), numeric::fourier::SO3coeffs::genWigner_ds(), pyrosetta.PyMOLRosettaServer::get_ends(), PyMOL-RosettaServer::get_ends(), DRRAFTER::get_n_cycles(), numeric::kdtree::get_percentile_bounds(), numeric::VoxelGrid< typename >::GetIndex(), options_class::getMarkdownPage(), go_main(), harvest_scores(), ObjexxFCL::format::I(), ObjexxFCL::KeyFArray1D< typename >::KeyFArray1D(), ObjexxFCL::KeyFArray2D< typename >::KeyFArray2D(), ObjexxFCL::KeyFArray3D< typename >::KeyFArray3D(), ObjexxFCL::KeyFArray4D< typename >::KeyFArray4D(), ObjexxFCL::KeyFArray5D< typename >::KeyFArray5D(), ObjexxFCL::KeyFArray6D< typename >::KeyFArray6D(), utility::graph::RingDetection< Graph >::LengthOfSmallestCycleWithVertex(), utility::tag::XMLErrorHandler::lines_near_error(), get_lowest_scoring_relaxed_models::main(), best_ifaceE::main(), main(), make_fragments(), utility::options::OptionCollection::merged(), utility::min(), ObjexxFCL::min(), numeric::min(), numeric::xyzVector< core::Real >::minimum_value(), numeric::interpolation::multilinear_interpolation(), utility::options::OptionCollection::n_part_prefix_match(), numeric::kdtree::nearest_neighbor(), numeric::kdtree::nearest_neighbors(), ObjexxFCL::DimensionExpressionMin::operator()(), numeric::expression_parser::MinExpression::operator()(), ObjexxFCL::operator<(), ObjexxFCL::operator<=(), ObjexxFCL::operator==(), ObjexxFCL::Fstring::overlay(), numeric::deriv::p1_theta_deriv(), DockFragmentsMover::process_fragfile(), numeric::proj_angl(), numeric::random::reservoir_sample_accept_prob(), ObjexxFCL::ChunkVector< typename >::reshape(), ObjexxFCL::Chunk< T >::resize(), numeric::xyzTransform< numeric::Real >::rotation_axis(), FragmentAssemblyMover::run(), numeric::VoxelGrid< typename >::SetObjects(), numeric::VoxelGrid< typename >::SetupGrid(), utility::options::OptionCollection::show_option_help(), Solver::Solve(), solve_nu_svc(), solve_nu_svr(), binder::split_in_two(), numeric::linear_algebra::svdcmp(), basic::svd::SVD_Solver::svdcmp(), svm_check_parameter(), svm_predict_probability(), pyrosetta.utility.array::to_structured_array(), numeric::kdtree::transform_percentile(), ObjexxFCL::DimensionExpressionMin::value(), numeric::kdtree::KDPointList::worst_distance(), utility::options::OptionCollection::wrapped(), and numeric::deriv::x_and_dtheta_dx().

static void multiclass_probability ( int  k,
double **  r,
double p 
)
static
static double powi ( double  base,
int  times 
)
inlinestatic
static void print_string_stdout ( const char *  s)
static
static char* readline ( FILE *  input)
static

References ObjexxFCL::len(), and line.

Referenced by svm_load_model().

static double sigmoid_predict ( double  decision_value,
double  A,
double  B 
)
static

Referenced by svm_predict_probability().

static void sigmoid_train ( int  l,
const double dec_values,
const double labels,
double A,
double B 
)
static
static void solve_c_svc ( const svm_problem prob,
const svm_parameter param,
double alpha,
Solver::SolutionInfo si,
double  Cp,
double  Cn 
)
static
static void solve_epsilon_svr ( const svm_problem prob,
const svm_parameter param,
double alpha,
Solver::SolutionInfo si 
)
static
static void solve_nu_svc ( const svm_problem prob,
const svm_parameter param,
double alpha,
Solver::SolutionInfo si 
)
static
static void solve_nu_svr ( const svm_problem prob,
const svm_parameter param,
double alpha,
Solver::SolutionInfo si 
)
static
static void solve_one_class ( const svm_problem prob,
const svm_parameter param,
double alpha,
Solver::SolutionInfo si 
)
static
static void svm_binary_svc_probability ( const svm_problem prob,
const svm_parameter param,
double  Cp,
double  Cn,
double probA,
double probB 
)
static
const char* svm_check_parameter ( const svm_problem prob,
const svm_parameter param 
)
int svm_check_probability_model ( const svm_model model)
void svm_cross_validation ( const svm_problem prob,
const svm_parameter param,
int  nr_fold,
double target 
)
void svm_destroy_param ( svm_parameter param)
void svm_free_and_destroy_model ( svm_model **  model_ptr_ptr)
void svm_free_model_content ( svm_model model_ptr)
void svm_get_labels ( const svm_model model,
int label 
)
int svm_get_nr_class ( const svm_model model)
int svm_get_nr_sv ( const svm_model model)

References svm_model::l.

void svm_get_sv_indices ( const svm_model model,
int indices 
)
int svm_get_svm_type ( const svm_model model)
double svm_get_svr_probability ( const svm_model model)
static void svm_group_classes ( const svm_problem prob,
int nr_class_ret,
int **  label_ret,
int **  start_ret,
int **  count_ret,
int perm 
)
static
svm_model* svm_load_model ( const char *  model_file_name)
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 
)
double svm_predict_values ( const svm_model model,
const svm_node x,
double dec_values 
)
int svm_save_model ( const char *  model_file_name,
const svm_model model 
)
void svm_set_print_string_function ( void(*)(const char *)  print_func)
static double svm_svr_probability ( const svm_problem prob,
const svm_parameter param 
)
static
svm_model* svm_train ( const svm_problem prob,
const svm_parameter param 
)
static decision_function svm_train_one ( const svm_problem prob,
const svm_parameter param,
double  Cp,
double  Cn 
)
static
template<class T >
static void swap ( T x,
T y 
)
inlinestatic

References basic::options::OptionKeys::in::file::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=(), utility::pointer::DeepCopyOP< T >::operator=(), svm_binary_svc_probability(), svm_cross_validation(), utility::pointer::DeepCopyOP< T >::swap(), utility::keys::SmallKeyMap< K, T >::swap(), utility::keys::SmallKeyVector< PathVectorOptionKey, PathVectorOption >::swap(), ObjexxFCL::Cstring::swap(), ObjexxFCL::Dimension::swap(), ObjexxFCL::CArray< typename >::swap(), ObjexxFCL::Chunk< T >::swap(), utility::vectorL< L, bool, A >::swap(), utility::keys::swap(), ObjexxFCL::IndexRange::swap(), utility::vectorL< 1, std::string, A >::swap(), ObjexxFCL::FArray1D< double >::swap(), ObjexxFCL::KeyFArray1D< typename >::swap(), ObjexxFCL::CArrayP< typename >::swap(), ObjexxFCL::FArray2D< double >::swap(), ObjexxFCL::KeyFArray2D< typename >::swap(), ObjexxFCL::FArray3D< typename >::swap(), ObjexxFCL::KeyFArray3D< typename >::swap(), ObjexxFCL::FArray4D< typename >::swap(), ObjexxFCL::KeyFArray4D< typename >::swap(), ObjexxFCL::FArray5D< typename >::swap(), ObjexxFCL::KeyFArray5D< typename >::swap(), ObjexxFCL::swap(), ObjexxFCL::FArray6D< typename >::swap(), ObjexxFCL::KeyFArray6D< typename >::swap(), ObjexxFCL::DynamicIndexRange::swap(), ObjexxFCL::ChunkVector< typename >::swap(), ObjexxFCL::FArray2< T >::swap2DB(), ObjexxFCL::FArray3< T >::swap3DB(), ObjexxFCL::FArray4< T >::swap4DB(), ObjexxFCL::FArray5< T >::swap5DB(), ObjexxFCL::FArray6< T >::swap6DB(), numeric::MathMatrix< float >::swap_cols(), Cache::swap_index(), Kernel::swap_index(), Solver::swap_index(), SVC_Q::swap_index(), ONE_CLASS_Q::swap_index(), SVR_Q::swap_index(), ObjexxFCL::Dimension::swap_no_notify(), ObjexxFCL::DynamicIndexRange::swap_no_notify(), numeric::MathMatrix< float >::swap_rows(), ObjexxFCL::FArray< T >::swapB(), and binder::vector_binder< T, Allocator >::vector_binder().

Variable Documentation

const char* kernel_type_table[]
static
Initial value:
=
{
"linear","polynomial","rbf","sigmoid","precomputed",nullptr
}

Referenced by svm_load_model(), and svm_save_model().

int libsvm_version = LIBSVM_VERSION
char* line = nullptr
static
int max_line_len
static
void(* svm_print_string)(const char *) = &print_string_stdout
static
const char* svm_type_table[]
static
Initial value:
=
{
"c_svc","nu_svc","one_class","epsilon_svr","nu_svr",nullptr
}

Referenced by svm_load_model(), and svm_save_model().