//////////////////////////////////////////////////////////////////////////// //! author="Kieron J Messer" //! lib=RbfUtil //! date="4/7/99" //! rcsid="$Id: doRbfSelect.cc,v 1.9 2000/12/12 13:27:00 ees2km Exp $" #include "amma/Option.hh" #include "amma/Filename.hh" #include "amma/EntryPnt.hh" #include "amma/Num/RbfUtil.hh" #include "amma/DP/FileFormatIO.hh" extern void NumRBFIncludeIOFunc(); int doRbfSelect(int argc, char **argv) { NumRBFIncludeIOFunc(); OptionC opt(argc,argv); FilenameC TrainData = opt.String("i",NULL, "input NumVLDataSet data"); FilenameC TestData = opt.String("test",NULL, "input NumVLDataSet data"); FilenameC OutFile = opt.String("o", NULL, "output file"); FilenameC ResFile = opt.String("r", NULL, "results file"); StringC ModelSel = opt.String("sel", "", "choose which model selection algorithm to use"); IntT StartFrom = opt.Int("start", 1, "start at"); IntT StopAt = opt.Int("stop", 10, "stop at"); IntT Cycles = opt.Int("cyc", 10, "number of cycles of EM algorithm"); IntT Samps = opt.Int("n", 0, "number of samples to use in training step"); IntT ValSamps = opt.Int("nvals", 0, "number of samples to use in validation step"); IntT LocSamps = opt.Int("nwin", 0, "number of window placements"); IntT Seed = opt.Int("seed", 0, "number of window placements"); RealT PLo = opt.Real("plo", 0.1, "starting learning rate for ema lag"); RealT PHi = opt.Real("phi", 0.25, "tolerance on predicted performance"); BooleanT Full = opt.Boolean("full", FALSE, "use full or diagonal covariance matiex"); IntT NCall = opt.Int("ncall", 100, "number of calls in vegas"); IntT Itmx = opt.Int("itmx", 10, "number of iterations in vegas"); StringC EmAlg = opt.String("emalg", "Normal", "Em algorithm [Normal||Ppca]"); IntT Ppca = opt.Int("ppca", 0, "number of dimensions to ue for Ppca"); StringC ValAlg = opt.String("valg", "SampleSame", "Validation algorithm [Same||Diff||Joint]"); StringC ConfAlg = opt.String("calg", "JointConfidence", "Limits algorithm [LineTest]"); opt.Check(); //: set random seed randomIdum=Seed; //: load in data NumVLDataSetC data(TrainData); data.Shuffle(); cout.precision(6); // NumVLDataSetC test(TestData); //: set rbf options RbfOptionC rbfOpt; rbfOpt.StartFrom(StartFrom); rbfOpt.StopAt(StopAt); rbfOpt.Cycles(Cycles); rbfOpt.TrainSamples(Samps); rbfOpt.ValSamples(ValSamps); rbfOpt.LocSamples(LocSamps); rbfOpt.ProbLo(PLo); rbfOpt.ProbHi(PHi); rbfOpt.Full(Full); rbfOpt.NCall(NCall); rbfOpt.Itmx(Itmx); rbfOpt.EmAlgorithm(EmAlg); rbfOpt.PpcaDim(Ppca); rbfOpt.ValAlgorithm(ValAlg); rbfOpt.ConfAlgorithm(ConfAlg); rbfOpt.ModelSelAlgorithm(ModelSel); cout << rbfOpt << endl; //: compute the model NormalRBFuncC rbf = RbfUtil::ModelSelect(data.InputSet(), rbfOpt); //DListC rbfs = RbfUtil::GreedyEM(data.InputSet(), 10); //NormalRBFuncC rbf = RbfUtil::ModelSelect(rbfs, test.InputSet(), rbfOpt); //cout << "best rbf: " << rbf.Size() << endl; //IntT i=1; //cout << endl; //for(DLIterCIt(rbfs);It.IsElm();It.Next()) { // cout << i << ": " << It.Data().NegLogLikelihood(test.InputSet())/(RealT)test.Size() << endl; //} //ofstream ofs(OutFile, ios::app); //ofs << rbf.Size() << " " << rbf.NegLogLikelihood(test.InputSet())/(RealT)test.Size() << endl; //ofs.close(); //: output model if(opt.IsOnCommandLine("o")) StdIO::Save(OutFile, rbf); else cout << rbf << endl; return 0; } //: This puts a wrapper around the main program that catches //: exceptions and turns them into readable error messages. AMMA_ENTRY_POINT(doRbfSelect);