8#define XIDX(i,j,ncol) ((i)*(ncol) + (j))
15#define LM_EITER 0.00001
33 MedLMParams() { eiter = (float)EITER; niter = NITER; rfactor = 1.0; rfactors = NULL; corrs = NULL; sumxx = NULL;
get_col = -1; }
56 virtual int set_params(map<string, string>& mapper);
62 int Learn(
float *x,
float *y,
int nsamples,
int nftrs);
63 int Learn(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs);
65 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs)
const;
66 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs,
int transposed_flag)
const;
68 void normalize_x_and_y(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs, vector<float>& x_avg, vector<float>& x_std,
float& y_avg,
float& y_std);
69 int denormalize_model(
float *f_avg,
float *f_std,
float lavel_avg,
float label_std);
70 void print(FILE *fp,
const string& prefix,
int level = 0)
const;
79int init_farray(
string& in,
float **out);
80int init_darray(
string& in,
int **out);
87#define LASSO_NITER 1000
94 MedLassoParams() { lambda = LASSO_LAMBDA; num_iterations = LASSO_NITER; }
123 void init_defaults();
127 int Learn(
float *x,
float *y,
int nsamples,
int nftrs);
128 int Learn(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs);
130 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs)
const;
131 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs,
int transposed_flag)
const;
133 void normalize_x_and_y(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs, vector<float>& x_avg, vector<float>& x_std,
float& y_avg,
float& y_std);
134 int denormalize_model(
float *f_avg,
float *f_std,
float lavel_avg,
float label_std);
136 void initialize_vars(
float *x_in,
float *y_in,
const float *w, vector<float>& b,
int nrow_train,
int n_ftrs);
137 void lasso_regression(vector<float>& b,
int nrow_train,
int n_ftrs,
double lambda,
int num_iterations);
138 void print(FILE *fp,
const string& prefix,
int level = 0)
const;
144int learn_lm(
float *x,
float *_y,
const float *w,
int nsamples,
int nftrs,
int niter,
float eiter,
float *rfactors,
float *b,
float *err,
float *corrs);
146int learn_lm(
float *x,
float *_y,
const float *w,
int nsamples,
int nftrs,
int niter,
float eiter,
float *rfactors,
float *b,
float *err,
float *corrs,
float *sumxx);
MedAlgo - APIs to different algorithms: Linear Models, RF, GBM, KNN, and more.
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
int Predict(float *x, float *&preds, int nsamples, int nftrs) const
Predict should be implemented for each model.
Definition MedLM.cpp:225
MedLMParams params
Parameters.
Definition MedLM.h:46
bool predict_single_not_implemented()
Prepartion function for fast prediction on single item each time.
Definition MedLM.h:72
void calc_feature_contribs(MedMat< float > &x, MedMat< float > &contribs)
Feature contributions explains the prediction on each sample (aka BUT_WHY)
Definition MedLM.cpp:149
virtual int set_params(map< string, string > &mapper)
The parsed fields from init command.
Definition MedLM.cpp:64
int set_params(map< string, string > &mapper)
The parsed fields from init command.
Definition MedLasso.cpp:20
int Predict(float *x, float *&preds, int nsamples, int nftrs) const
Predict should be implemented for each model.
Definition MedLasso.cpp:170
MedLassoParams params
Parameters.
Definition MedLM.h:107
Base Interface for predictor.
Definition MedAlgo.h:78
MedPredictorTypes classifier_type
The Predicotr enum type.
Definition MedAlgo.h:80
int get_col
A simple way to check a single column , default is -1, but if >=0 the algorithm will simply return th...
Definition MedLM.h:25