43 #include "EST_Wagon.h"
44 #include "EST_cutils.h"
45 #include "EST_multistats.h"
46 #include "EST_Token.h"
47 #include "EST_cmd_line.h"
49 static int ols_test_main(
int argc,
char **argv);
80 int main(
int argc,
char **argv)
83 ols_test_main(argc,argv);
89 static int ols_test_main(
int argc,
char **argv)
101 "ols_test <options>\n"+
102 "program to test OLS on data\n"+
103 "-desc <ifile> Field description file\n"+
104 "-data <ifile> Datafile, one vector per line\n"+
105 "-coeffs <ifile> File containing OLS coefficients\n"+
106 "-predict Predict for each vector returning value\n"+
107 "-o <ofile> File to save output in\n",
114 dataset.load_description(al.
val(
"-desc"),NIL);
118 cerr << argv[0] <<
": no description file specified" << endl;
122 if (coeffs.
load(al.
val(
"-coeffs")) != format_ok)
124 cerr << argv[0] <<
": no coefficients file specified" << endl;
129 wgn_load_dataset(dataset,al.
val(
"-data"));
132 cerr << argv[0] <<
": no data file specified" << endl;
137 outfile = al.
val(
"-o");
144 load_ols_data(X,Y,dataset);
145 ols_apply(X,coeffs,pred);
146 if (ols_test(Y,pred,cor,rmse))
147 printf(
";; RMSE %f Correlation is %f\n",rmse,cor);
149 printf(
";; varation too small RMSE %f but no correlation\n",rmse);
161 X.
resize(d.length(),d.width());
164 for (n=0,p=d.head(); p != 0; p=p->next(),n++)
166 Y(n,0) = d(p)->get_flt_val(0);
168 for (m=1; m < d.width(); m++)
169 X(n,m) = d(p)->get_flt_val(m);