74 typedef std::map<String, std::pair<double, double> >
ScaleMap;
113 void predict(std::vector<Prediction>& predictions,
114 std::vector<Size> indexes = std::vector<Size>())
const;
136 std::vector<std::vector<struct svm_node> > nodes_;
139 struct svm_problem data_;
142 struct svm_parameter svm_params_;
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
Simple interface to support vector machines for classification (via LIBSVM).
Definition: SimpleSVM.h:67
void convertData_(const PredictorMap &predictors)
Convert predictors to LIBSVM format.
~SimpleSVM() override
Destructor.
static void printNull_(const char *)
Dummy function to suppress LIBSVM output.
Definition: SimpleSVM.h:163
Int label
Predicted class label.
Definition: SimpleSVM.h:80
std::vector< std::vector< double > > SVMPerformance
Classification performance for different param. combinations (C/gamma):
Definition: SimpleSVM.h:133
Size n_parts_
Number of partitions for cross-validation.
Definition: SimpleSVM.h:151
struct svm_model * model_
Pointer to SVM model (LIBSVM format)
Definition: SimpleSVM.h:145
void setup(PredictorMap &predictors, const std::map< Size, Int > &labels)
Load data and train a model.
void predict(std::vector< Prediction > &predictions, std::vector< Size > indexes=std::vector< Size >()) const
Predict class labels (and probabilities).
void scaleData_(PredictorMap &predictors)
Scale predictor values to range 0-1.
void writeXvalResults(const String &path) const
Write cross-validation (parameter optimization) results to a CSV file.
std::map< String, std::vector< double > > PredictorMap
Mapping from predictor name to vector of predictor values.
Definition: SimpleSVM.h:71
std::map< Int, double > probabilities
Predicted probabilities for different classes.
Definition: SimpleSVM.h:83
const ScaleMap & getScaling() const
Get data range of predictors before scaling to [0, 1].
SVMPerformance performance_
Cross-validation results.
Definition: SimpleSVM.h:160
void optimizeParameters_()
Run cross-validation to optimize SVM parameters.
std::vector< double > log2_C_
Parameter values to try during optimization.
Definition: SimpleSVM.h:154
std::pair< double, double > chooseBestParameters_() const
Choose best SVM parameters based on cross-validation results.
SimpleSVM()
Default constructor.
std::map< String, std::pair< double, double > > ScaleMap
Mapping from predictor name to predictor min and max.
Definition: SimpleSVM.h:74
std::vector< String > predictor_names_
Names of predictors in the model (excluding uninformative ones)
Definition: SimpleSVM.h:148
ScaleMap scaling_
Mapping from predictor name to predictor min and max.
Definition: SimpleSVM.h:157
void getFeatureWeights(std::map< String, double > &feature_weights) const
Get the weights used for features (predictors) in the SVM model.
SVM prediction result.
Definition: SimpleSVM.h:78
A more convenient string class.
Definition: String.h:60
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