58 typedef std::map<String, std::pair<double, double> >
ScaleMap;
87 void setup(
PredictorMap& predictors,
const std::map<Size, double>& outcomes,
bool classification =
true);
98 void predict(std::vector<Prediction>& predictions,
99 std::vector<Size> indexes = std::vector<Size>())
const;
135 std::vector<std::vector<struct svm_node> > nodes_;
138 struct svm_problem data_;
141 struct svm_parameter svm_params_;
153 std::vector<double>
log2_C_, log2_gamma_, log2_p_;
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Simple interface to support vector machines for classification and regression (via LIBSVM).
Definition: SimpleSVM.h:51
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:162
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:150
struct svm_model * model_
Pointer to SVM model (LIBSVM format)
Definition: SimpleSVM.h:144
std::vector< std::vector< std::vector< double > > > SVMPerformance
Classification (or regression) performance for different param. combinations (C/gamma/p):
Definition: SimpleSVM.h:132
std::map< double, double > probabilities
Class label (or regression value) and their predicted probabilities.
Definition: SimpleSVM.h:67
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:55
double outcome
Predicted class label (or regression value)
Definition: SimpleSVM.h:64
const ScaleMap & getScaling() const
Get data range of predictors before scaling to [0, 1].
SVMPerformance performance_
Cross-validation results.
Definition: SimpleSVM.h:159
std::vector< double > log2_C_
Parameter values to try during optimization.
Definition: SimpleSVM.h:153
SimpleSVM()
Default constructor.
std::map< String, std::pair< double, double > > ScaleMap
Mapping from predictor name to predictor min and max.
Definition: SimpleSVM.h:58
std::vector< String > predictor_names_
Names of predictors in the model (excluding uninformative ones)
Definition: SimpleSVM.h:147
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:156
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:62
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22