7#ifndef __MEDBOOSTER__H__
8#define __MEDBOOSTER__H__
30 string internal_booster_model;
31 string internal_booster_params;
46 vector<MedPredictor *> predictors;
51 for (
auto &predictor : predictors)
if (predictor) {
delete predictor; predictor = NULL; }
61 cerr <<
"MedBooster init_from_string ! :: " << initialization_text <<
"\n";
62 params.init_from_string(initialization_text);
66 int init(map<string, string>& mapper) {
67 cerr <<
"MedBooster:: init map :: not supported, only init_from_string supported....\n";
71 int set_params(map<string, string>& mapper) {
72 cerr <<
"MedBooster:: init map :: not supported, only init_from_string supported....\n";
77 void init_defaults() { params.init_from_string(
"boost@booster_type=gradient,loss_func=square,nrounds=10,shrinkage=0.1,internal_model=linear_model@internal_params@rfactor=0.8"); }
79 int Learn(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs) {
80 cerr <<
"MedBooster:: Learn :: API's with MedMat are preferred....\n";
83 return learn(xmat, ymat);
86 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs)
const {
87 cerr <<
"MedBooster:: Learn :: API's with MedMat are preferred....\n";
90 int rc = predict(xmat, vpreds);
91 if (preds == NULL) preds =
new float[nsamples];
92 memcpy(preds, &vpreds[0],
sizeof(
float)*nsamples);
110 int gradient_get_round_alphas(
MedMat<float> &residual, vector<float> &preds, vector<float> &a);
111 int gradient_get_alphas_square_loss(
MedMat<float> &residual, vector<float> &preds, vector<float> &a);
112 int update_round_residuals(
MedMat<float> &y, vector<float> &all_preds,
MedMat<float> &residual, vector<float> &preds, vector<float> &a);
113 int update_round_residuals_single_linear(
MedMat<float> &y, vector<float> &all_preds,
MedMat<float> &residual, vector<float> &preds, vector<float> &a);
MedAlgo - APIs to different algorithms: Linear Models, RF, GBM, KNN, and more.
@ MODEL_BOOSTER
to_use:"booster" general booster (meta algorithm) - creates MedBooster
Definition MedAlgo.h:55
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
Definition MedBooster.h:19
void init_from_string(const string &init_str)
Definition MedBooster.cpp:26
Definition MedBooster.h:40
size_t get_size()
Gets bytes sizes for serializations.
Definition MedBooster.cpp:291
size_t deserialize(unsigned char *blob)
Deserialiazing blob to object. returns number of bytes read.
Definition MedBooster.cpp:305
size_t serialize(unsigned char *blob)
Serialiazing object to blob memory. return number ob bytes wrote to memory.
Definition MedBooster.cpp:298
int init(map< string, string > &mapper)
MedBooster:: init map :: not supported, only init_from_string supported.
Definition MedBooster.h:66
int init_from_string(string initialization_text)
The parsed fields from init command.
Definition MedBooster.h:60
int Predict(float *x, float *&preds, int nsamples, int nftrs) const
Predict should be implemented for each model.
Definition MedBooster.h:86
int Learn(float *x, float *y, const float *w, int nsamples, int nftrs)
Learn should be implemented for each model.
Definition MedBooster.h:79
Base Interface for predictor.
Definition MedAlgo.h:78
MedPredictorTypes classifier_type
The Predicotr enum type.
Definition MedAlgo.h:80