45 static void ols_load_selected_feats(
const EST_FMatrix &
X,
81 for (i=0; i<included.
length(); i++)
99 int i,j,singularity=-1;
103 cerr <<
"OLS: less rows than columns, so cannot find solution." 109 cerr <<
"OLS: `included' list wrong size: internal error." 116 ols_load_selected_feats(X,included,Xl);
126 for (s=i=0; i<singularity; i++)
129 while ((included(s) ==
FALSE) ||
133 if (included(s) ==
FALSE)
135 cerr <<
"OLS: found singularity twice, shouldn't happen" 141 cerr <<
"OLS: omitting singularity in column " << s << endl;
163 static void ols_load_selected_feats(
const EST_FMatrix &
X,
169 for (width=i=0; i<included.
length(); i++)
170 if (included(i) ==
TRUE)
177 if (included(j) ==
TRUE)
212 float best_score=0.0,bscore;
218 if (!ols_stepwise_find_best(X,Y,included,coeffsl,
219 bscore,best_feat,Xtest,Ytest,
222 cerr <<
"OLS: stepwise failed" << endl;
225 if ((bscore - (bscore * (limit/100))) <= best_score)
231 included[best_feat] =
TRUE;
232 printf(
"FEATURE %d %s: %2.4f\n",
234 (
const char *)feat_names.
nth(best_feat),
244 static int ols_stepwise_find_best(
const EST_FMatrix &X,
260 for (i=0; i < included.
length(); i++)
273 printf(
"tested %d %s %f best %f\n",
274 i,(
const char *)feat_names.
nth(i),cor,bscore);
275 if (fabs(cor) > bscore)
321 rmse = sqrt(se.
mean());
335 correlation = (xy.
mean() - (x.
mean()*y.
mean()))/ sqrt(v3);
343 if ((correlation <= 1.0) && (correlation >= -1.0))
ssize_t num_columns() const
return number of columns
double mean(void) const
mean of currently cummulated values
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
ssize_t num_rows() const
return number of rows
T & nth(int n)
return the Nth value
EST_Track error(EST_Track &ref, EST_Track &test, int relax=0)
int ols_apply(const EST_FMatrix &samples, const EST_FMatrix &coeffs, EST_FMatrix &res)
INLINE ssize_t length() const
number of items in vector.
int robust_ols(const EST_FMatrix &X, const EST_FMatrix &Y, EST_FMatrix &coeffs)
int stepwise_ols(const EST_FMatrix &X, const EST_FMatrix &Y, const EST_StrList &feat_names, float limit, EST_FMatrix &coeffs, const EST_FMatrix &Xtest, const EST_FMatrix &Ytest, EST_IVector &included)
void multiply(const EST_DMatrix &a, const EST_DMatrix &b, EST_DMatrix &ab)
int pseudo_inverse(const EST_FMatrix &a, EST_FMatrix &inv)
pseudo inverse (for non-square matrices)
float correlation(EST_Track &a, EST_Track &b, ssize_t channel)
INLINE const T & a_no_check(ssize_t row, ssize_t col) const
const access with no bounds check, care recommend
void resize(int rows, int cols, int set=1)
resize matrix
int ols_test(const EST_FMatrix &real, const EST_FMatrix &predicted, float &correlation, float &rmse)
int ols(const EST_FMatrix &X, const EST_FMatrix &Y, EST_FMatrix &coeffs)
void resize(int n, int set=1)
resize vector