84 typedef std::map<String, std::pair<double, double> >
ScaleMap;
113 void setup(
PredictorMap& predictors,
const std::map<Size, double>& outcomes,
bool classification =
true);
124 void predict(std::vector<Prediction>& predictions,
125 std::vector<Size> indexes = std::vector<Size>())
const;
161 std::vector<std::vector<struct svm_node> > nodes_;
164 struct svm_problem data_;
167 struct svm_parameter svm_params_;
179 std::vector<double>
log2_C_, log2_gamma_, log2_p_;
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Simple interface to support vector machines for classification and regression (via LIBSVM).
Definition: SimpleSVM.h:77
void convertData_(const PredictorMap &predictors)
Convert predictors to LIBSVM format.
void optimizeParameters_(bool classification)
Run cross-validation to optimize SVM parameters.
~SimpleSVM() override
Destructor.
static void printNull_(const char *)
Dummy function to suppress LIBSVM output.
Definition: SimpleSVM.h:188
void predict(PredictorMap &predictors, std::vector< Prediction > &predictions) const
Predict class labels or regression values (and probabilities).
Size n_parts_
Number of partitions for cross-validation.
Definition: SimpleSVM.h:176
struct svm_model * model_
Pointer to SVM model (LIBSVM format)
Definition: SimpleSVM.h:170
std::vector< std::vector< std::vector< double > > > SVMPerformance
Classification (or regression) performance for different param. combinations (C/gamma/p):
Definition: SimpleSVM.h:158
std::map< double, double > probabilities
Class label (or regression value) and their predicted probabilities.
Definition: SimpleSVM.h:93
void predict(std::vector< Prediction > &predictions, std::vector< Size > indexes=std::vector< Size >()) const
Predict class labels or regression values (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::tuple< double, double, double > chooseBestParameters_(bool higher_better) const
Choose best SVM parameters based on cross-validation results.
std::map< String, std::vector< double > > PredictorMap
Mapping from predictor name to vector of predictor values.
Definition: SimpleSVM.h:81
double outcome
Predicted class label (or regression value)
Definition: SimpleSVM.h:90
const ScaleMap & getScaling() const
Get data range of predictors before scaling to [0, 1].
SVMPerformance performance_
Cross-validation results.
Definition: SimpleSVM.h:185
std::vector< double > log2_C_
Parameter values to try during optimization.
Definition: SimpleSVM.h:179
SimpleSVM()
Default constructor.
std::map< String, std::pair< double, double > > ScaleMap
Mapping from predictor name to predictor min and max.
Definition: SimpleSVM.h:84
std::vector< String > predictor_names_
Names of predictors in the model (excluding uninformative ones)
Definition: SimpleSVM.h:173
void setup(PredictorMap &predictors, const std::map< Size, double > &outcomes, bool classification=true)
Load data and train a model.
ScaleMap scaling_
Mapping from predictor name to predictor min and max.
Definition: SimpleSVM.h:182
void getFeatureWeights(std::map< String, double > &feature_weights) const
Get the weights used for features (predictors) in the SVM model.
SVM/SVR prediction result.
Definition: SimpleSVM.h:88
A more convenient string class.
Definition: String.h:60
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:48