57 std::vector<std::vector<std::pair<Int, double> > >
sequences;
62 SVMData(std::vector<std::vector<std::pair<Int, double> > >& seqs, std::vector<double>& lbls);
210 void predict(
struct svm_problem* problem, std::vector<double>& predicted_labels);
303 std::vector<SVMData>& problems);
322 void predict(
const std::vector<svm_node*>& vectors, std::vector<double>& predicted_rts);
328 static void getLabels(svm_problem* problem, std::vector<double>& labels);
336 const bool is_labeled,
337 const std::map<SVM_parameter_type, double>& start_values_map,
338 const std::map<SVM_parameter_type, double>& step_sizes_map,
339 const std::map<SVM_parameter_type, double>& end_values_map,
340 Size number_of_partitions,
342 std::map<SVM_parameter_type, double>& best_parameters,
343 bool additive_step_sizes =
true,
345 String performances_file_name =
"performances.txt",
346 bool mcc_as_performance_measure =
false);
375 static double kernelOligo(
const std::vector<std::pair<int, double> >& x,
376 const std::vector<std::pair<int, double> >& y,
377 const std::vector<double>& gauss_table,
378 int max_distance = -1);
387 static double kernelOligo(
const svm_node* x,
const svm_node* y,
const std::vector<double>& gauss_table,
double sigma_square = 0,
Size max_distance = 50);
392 void getSignificanceBorders(svm_problem* data, std::pair<double, double>& borders,
double confidence = 0.95,
Size number_of_runs = 5,
Size number_of_partitions = 5,
double step_size = 0.01,
Size max_iterations = 1000000);
398 std::pair<double, double>& sigmas,
399 double confidence = 0.95,
400 Size number_of_runs = 5,
401 Size number_of_partitions = 5,
402 double step_size = 0.01,
403 Size max_iterations = 1000000);
411 double getPValue(
double sigma1,
double sigma2, std::pair<double, double> point);
472 void getSVCProbabilities(
struct svm_problem* problem, std::vector<double>& probabilities, std::vector<double>& prediction_labels);
477 void setWeights(
const std::vector<Int>& weight_labels,
const std::vector<double>& weights);
487 const std::vector<double>& step_sizes,
488 const std::vector<double>& end_values,
489 const bool additive_step_sizes,
490 std::vector<double>& actual_values);
514 svm_problem* training_set_ =
nullptr;
515 svm_problem* training_problem_ =
nullptr;
Definition: MathFunctions.h:352
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
Serves as a wrapper for the libsvm.
Definition: SVMWrapper.h:82
static void calculateGaussTable(Size border_length, double sigma, std::vector< double > &gauss_table)
void setWeights(const std::vector< Int > &weight_labels, const std::vector< double > &weights)
Sets weights for the classes in C_SVC (see libsvm documentation for further details)
void saveModel(std::string modelFilename) const
saves the svm model
void setTrainingSample(SVMData &training_sample)
This is used for being able to perform predictions with non libsvm standard kernels.
svm_problem * computeKernelMatrix(const SVMData &problem1, const SVMData &problem2)
computes the kernel matrix using the actual svm parameters and the given data
static void printToVoid_(const char *)
This function is passed to lib svm for output control.
svm_problem * computeKernelMatrix(svm_problem *problem1, svm_problem *problem2)
computes the kernel matrix using the actual svm parameters and the given data
Size border_length_
the actual kernel type
Definition: SVMWrapper.h:513
static double kernelOligo(const svm_node *x, const svm_node *y, const std::vector< double > &gauss_table, double sigma_square=0, Size max_distance=50)
calculates the oligo kernel value for the encoded sequences 'x' and 'y'
void createRandomPartitions(const SVMData &problem, Size number, std::vector< SVMData > &problems)
You can create 'number' equally sized random partitions.
static svm_problem * mergePartitions(const std::vector< svm_problem * > &problems, Size except)
You can merge partitions excluding the partition with index 'except'.
static void getLabels(svm_problem *problem, std::vector< double > &labels)
Stores the stored labels of the encoded SVM data at 'labels'.
void setParameter(SVM_parameter_type type, double value)
sets the double parameters of the svm
std::vector< double > sigmas_
for the combined oligo kernel (amount of positional smearing)
Definition: SVMWrapper.h:509
Int train(struct svm_problem *problem)
trains the svm
double sigma_
for the oligo kernel (amount of positional smearing)
Definition: SVMWrapper.h:508
SVM_kernel_type
Kernel type.
Definition: SVMWrapper.h:107
Math::RandomShuffler shuffler_
random shuffler to create training partitions
Definition: SVMWrapper.h:517
bool nextGrid_(const std::vector< double > &start_values, const std::vector< double > &step_sizes, const std::vector< double > &end_values, const bool additive_step_sizes, std::vector< double > &actual_values)
find next grid search parameter combination
void createRandomPartitions(svm_problem *problem, Size number, std::vector< svm_problem * > &partitions)
You can create 'number' equally sized random partitions.
std::vector< std::vector< double > > gauss_tables_
lookup table for fast computation of the combined oligo kernel
Definition: SVMWrapper.h:511
Size kernel_type_
the actual kernel type
Definition: SVMWrapper.h:512
double getPValue(double sigma1, double sigma2, std::pair< double, double > point)
calculates a p-value for a given data point using the model parameters
SVM_parameter_type
Parameters for the svm to be set from outside.
Definition: SVMWrapper.h:92
@ GAMMA
the gamma parameter of the POLY, RBF and SIGMOID kernel
Definition: SVMWrapper.h:99
@ SVM_TYPE
the svm type cab be NU_SVR or EPSILON_SVR
Definition: SVMWrapper.h:93
@ C
the C parameter of the svm
Definition: SVMWrapper.h:96
@ PROBABILITY
Definition: SVMWrapper.h:100
@ P
the epsilon parameter for epsilon-SVR
Definition: SVMWrapper.h:98
@ NU
the nu parameter for nu-SVR
Definition: SVMWrapper.h:97
@ DEGREE
the degree for the polynomial- kernel
Definition: SVMWrapper.h:95
@ KERNEL_TYPE
the kernel type
Definition: SVMWrapper.h:94
@ SIGMA
Definition: SVMWrapper.h:101
void loadModel(std::string modelFilename)
loads the model
Size getNumberOfEnclosedPoints_(double m1, double m2, const std::vector< std::pair< double, double > > &points)
double getSVRProbability()
Returns the probability parameter sigma of the fitted Laplace model.
virtual ~SVMWrapper()
destructor
void getDecisionValues(svm_problem *data, std::vector< double > &decision_values)
stores the prediction values for the encoded data in 'decision_values'
Int train(SVMData &problem)
trains the svm
void predict(const SVMData &problem, std::vector< double > &results)
predicts the labels using the trained model
static void mergePartitions(const std::vector< SVMData > &problems, Size except, SVMData &merged_problem)
You can merge partitions excluding the partition with index 'except'.
std::vector< double > gauss_table_
lookup table for fast computation of the oligo kernel
Definition: SVMWrapper.h:510
svm_model * model_
the learned svm discriminant
Definition: SVMWrapper.h:507
void scaleData(svm_problem *data, Int max_scale_value=-1)
Scales the data such that every column is scaled to [-1, 1].
void setTrainingSample(svm_problem *training_sample)
This is used for being able to perform predictions with non libsvm standard kernels.
void setParameter(SVM_parameter_type type, Int value)
You can set the parameters of the svm:
Int getIntParameter(SVM_parameter_type type)
You can get the actual int- parameters of the svm.
void initParameters_()
Initializes the svm with standard parameters.
void predict(const std::vector< svm_node * > &vectors, std::vector< double > &predicted_rts)
predicts the labels using the trained model
void predict(struct svm_problem *problem, std::vector< double > &predicted_labels)
predicts the labels using the trained model
double performCrossValidation(svm_problem *problem_ul, const SVMData &problem_l, const bool is_labeled, const std::map< SVM_parameter_type, double > &start_values_map, const std::map< SVM_parameter_type, double > &step_sizes_map, const std::map< SVM_parameter_type, double > &end_values_map, Size number_of_partitions, Size number_of_runs, std::map< SVM_parameter_type, double > &best_parameters, bool additive_step_sizes=true, bool output=false, String performances_file_name="performances.txt", bool mcc_as_performance_measure=false)
Performs a CV for the data given by 'problem'.
void getSignificanceBorders(svm_problem *data, std::pair< double, double > &borders, double confidence=0.95, Size number_of_runs=5, Size number_of_partitions=5, double step_size=0.01, Size max_iterations=1000000)
calculates the significance borders of the error model and stores them in 'sigmas'
double getDoubleParameter(SVM_parameter_type type)
You can get the actual double- parameters of the svm.
SVMData training_data_
the training set (different encoding)
Definition: SVMWrapper.h:516
void getSVCProbabilities(struct svm_problem *problem, std::vector< double > &probabilities, std::vector< double > &prediction_labels)
This function fills probabilities with the probability estimates for the first class.
static double kernelOligo(const std::vector< std::pair< int, double > > &x, const std::vector< std::pair< int, double > > &y, const std::vector< double > &gauss_table, int max_distance=-1)
returns the value of the oligo kernel for sequences 'x' and 'y'
svm_parameter * param_
the parameters for the svm
Definition: SVMWrapper.h:506
void getSignificanceBorders(const SVMData &data, std::pair< double, double > &sigmas, double confidence=0.95, Size number_of_runs=5, Size number_of_partitions=5, double step_size=0.01, Size max_iterations=1000000)
calculates the significance borders of the error model and stores them in 'sigmas'
SVMWrapper()
standard constructor
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Data structure used in SVMWrapper.
Definition: SVMWrapper.h:56
std::vector< double > labels
Definition: SVMWrapper.h:58
bool store(const String &filename) const
bool operator==(const SVMData &rhs) const
bool load(const String &filename)
std::vector< std::vector< std::pair< Int, double > > > sequences
Definition: SVMWrapper.h:57
SVMData(std::vector< std::vector< std::pair< Int, double > > > &seqs, std::vector< double > &lbls)