Medial Code Documentation
Loading...
Searching...
No Matches
SimpleEnsemble.h
1#pragma once
4
5
7public:
8 // Model
9 vector<MedPredictor *> predictors;
10 MedPredictor *combiner = NULL;
11 vector<float> weights;
12 int n_preds = 1;
13 float p_combine = 0;
14
16 vector<string> predictor_names;
17 vector<string> predictor_params;
18 string combiner_name = "";
19 string combiner_params = "";
20
21
22 // Function
24
26
27 int set_params(map<string, string>& mapper);
28
29 void init_defaults() { predictors.clear(); weights.clear(); predictor_names.clear(); predictor_params.clear(); combiner_name = ""; combiner_params = ""; p_combine = 0; };
30
31 // learn simply calls init from file
32 int learn(MedMat<float> &x, MedMat<float> &y, const vector<float> &wgts);
33 int Learn(float *x, float *y, int nsamples, int nftrs) { HMTHROW_AND_ERR("SimpleEnsemble: Learn(float *,...) not implemented, used the MedMat API instead\n"); };
34 int Learn(float *x, float *y, const float *w, int nsamples, int nftrs) { HMTHROW_AND_ERR("SimpleEnsemble: Learn(float *,...) not implemented, used the MedMat API instead\n"); };
35
36 // predict - we only have the medmat option
37 int predict_pre_combine(MedMat<float> &x, MedMat<float> &preds) const;
38 int predict(MedMat<float> &x, vector<float> &preds) const;
39 int Predict(float *x, float *&preds, int nsamples, int nftrs) { HMTHROW_AND_ERR("SimpleEnsemble: Predict(float *,...) not implemented, used the MedMat API instead\n"); };
40 int Predict(float *x, float *&preds, int nsamples, int nftrs, int transposed_flag) { HMTHROW_AND_ERR("SimpleEnsemble: Predict(float *,...) not implemented, used the MedMat API instead\n"); };
41
42 int n_preds_per_sample() { return n_preds; }
43
44 ADD_CLASS_NAME(MedSimpleEnsemble)
45 ADD_SERIALIZATION_FUNCS(classifier_type, predictors, weights, predictor_names, predictor_params, combiner, combiner_name, combiner_params, p_combine, n_preds)
46};
47
49
Logger.h - allowing logs with more control.
MedAlgo - APIs to different algorithms: Linear Models, RF, GBM, KNN, and more.
@ MODEL_SIMPLE_ENSEMBLE
to_use: "simple_ensemble" , give 1 or more models to train, and ensemble them with given weights from...
Definition MedAlgo.h:65
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
Definition MedMat.h:63
Base Interface for predictor.
Definition MedAlgo.h:78
MedPredictorTypes classifier_type
The Predicotr enum type.
Definition MedAlgo.h:80
Definition SimpleEnsemble.h:6
int set_params(map< string, string > &mapper)
Definition SimpleEnsemble.cpp:18
int learn(MedMat< float > &x, MedMat< float > &y, const vector< float > &wgts)
MedMat x,y : will transpose/normalize x,y if needed by algorithm The convention is that untransposed ...
Definition SimpleEnsemble.cpp:87
int Learn(float *x, float *y, const float *w, int nsamples, int nftrs)
Learn should be implemented for each model.
Definition SimpleEnsemble.h:34
vector< string > predictor_names
Parameters.
Definition SimpleEnsemble.h:16