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);
53 int main(
int argc,
char **argv)
56 ols_test_main(argc,argv);
62 static int ols_test_main(
int argc,
char **argv)
74 "ols_test <options>\n"+
75 "program to test OLS on data\n"+
76 "-desc <ifile> Field description file\n"+
77 "-data <ifile> Datafile, one vector per line\n"+
78 "-coeffs <ifile> File containing OLS coefficients\n"+
79 "-predict Predict for each vector returning value\n"+
80 "-o <ofile> File to save output in\n",
87 dataset.load_description(al.
val(
"-desc"),NIL);
91 cerr << argv[0] <<
": no description file specified" << endl;
95 if (coeffs.
load(al.
val(
"-coeffs")) != format_ok)
97 cerr << argv[0] <<
": no coefficients file specified" << endl;
102 wgn_load_dataset(dataset,al.
val(
"-data"));
105 cerr << argv[0] <<
": no data file specified" << endl;
110 outfile = al.
val(
"-o");
117 load_ols_data(X,Y,dataset);
118 ols_apply(X,coeffs,pred);
119 if (ols_test(Y,pred,cor,rmse))
120 printf(
";; RMSE %f Correlation is %f\n",rmse,cor);
122 printf(
";; varation too small RMSE %f but no correlation\n",rmse);
134 X.
resize(d.length(),d.width());
137 for (n=0,p=d.head(); p != 0; p=p->next(),n++)
139 Y(n,0) = d(p)->get_flt_val(0);
141 for (m=1; m < d.width(); m++)
142 X(n,m) = d(p)->get_flt_val(m);
EST_write_status save(const EST_String &filename, const EST_String &type=EST_FMatrix::default_file_type)
Save in file (ascii or binary)
EST_read_status load(const EST_String &filename)
Load from file (ascii or binary as defined in file)
const int present(const K &rkey) const
Returns true if key is present.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
void resize(int rows, int cols, int set=1)
resize matrix