// bin.C #include #include #include #include #include "../Basics/pipeostream.h" #include "../Basics/basic.h" #include "../Basics/chrono.h" #include "../Basics/exception.h" #include "../Matrices/Matrix.h" #include "../Matrices/binMatrix.h" #include "main_def.h" #include "multiDS.h" #include "cutPtsSet.h" int main () { try { //------------------------------------------- //Collect general information for the batch //------------------------------------------- char inFile[80], outFile[80], choice[80]; // Declaration of all parameters, with default values int Kfold=0; float percFrom=10.0; float percTo=10.0; float percInter=1.0; int nbIter=1; int nbSizes=1; int initSeed=0; float confi=0.0; int binMeasure=1; int CPgeneration=0; int CPOrdering=0; boolean filter=false; float filterLimit=1.0; boolean minimizeCP=true; float separability=1.0; boolean compress=false; #if _batch_mode trace=0; #else cout<<"Trace level (1=normal, 2=debug): "; cin>>trace; #endif cout.setf(ios::fixed | ios::showpoint); cout<<"Prefix XXX of the file (.all) with original data : "; cin>>inFile; cout<<"Prefix XXX for the files (.tra, .tes) with binarized data : "; cin>>outFile; sprintf(choice,"%s-bin.out",outFile); ofstream fout(choice); fout<<"Prefix XXX of the file (.all) with original data : " <>Kfold; fout<=-1 && Kfold<=1 ) { Kfold=1; cout<<(fout<<="Training set's size (in %) from: "); cin>>percFrom; fout<>percTo; fout<>percInter; fout<>nbIter; fout<1 ? 100.0-100.0/Kfold : 100.0/(-Kfold))); cout<<"#iterations of each " << absolute(Kfold) << "-folding : "; fout<<"#iterations of each " << absolute(Kfold) << "-folding : "; cin>>nbIter; fout<>initSeed; fout<>binMeasure; fout<>choice; fout<>confi; fout<>CPgeneration; fout<>choice; fout<>CPOrdering; fout<>filterLimit; fout<>choice; fout<>separability; fout< seed(nbSizes,nbIter); fixSeed(initSeed); if(singleExp) seed(0,0)= initSeed; else for (int size=0; size whole, training, testing; Matrix Kparts; //---------------------------------------------------------- //Read the data, reorganize them and check for consistancy //---------------------------------------------------------- dataSet wholeDS; inFile>>wholeDS; whole.separate(wholeDS); whole.sort().checkMult().reorganize(); // Added if (!whole.isConsistant()) return 0; cout<<(fout<<="\nFile: "); cout<<(fout<<=inFile); cout<<(fout<<=", "); cout<<(fout<<=whole.ds[1].card()); cout<<(fout<<=" positive points ("); cout<<(fout<<=whole.ds[1].distinct()); cout<<(fout<<=" different),\n\t"); cout<<(fout<<=whole.ds[0].card()); cout<<(fout<<=" negative points ("); cout<<(fout<<=whole.ds[0].distinct()); cout<<(fout<<=" different), "); cout<<(fout<<=whole.ds[0].dim()); cout<<(fout<<=" attributes.\n\n"); int cSize; float perc; for (perc=percFrom, cSize=0; perc<=percTo; perc+=percInter, cSize++) { Matrix stat(1,8,0.0), statS(1,8,0.0), statSSQ(1,8,0.0), statMin(1,8,+1E10), statMax(1,8,-1E10); int iterXfold=0; flog<10 ? Iter%20==0 : (!Iter && (!cSize || (((cSize-1)*nbSizes)/20 != (cSize*nbSizes)/20))) ) { cout<<(fout<<= "Perc- |#-cut-pts| |train-sz--and-test-sz| |min| |bin|\n"); cout<<(fout<<= " -Iter |gen-final| |difP-difN---difP-difN| |err| |tim|\n"); } else if ( Kfold!=1 ) cout<<(fout<<="\n"); fixSeed(seed(cSize, Iter)); flog<1 ) cout<<"\n*** training data:\n"< candidate(training,confiL,CPgeneration,CPOrdering); if ( trace>1 ) cout<<"\n*** candidate cut points:\n"<1 ) cout<<"\n*** normalized training data:\n"<>filterLimit; } if ( binMeasure==1 ) cout<<"Minimal # of cut points separating each pair " <<"of points"; else cout<<"Minimal separability of each pair of points"; cout<<" (optimization): "; cin>>separability; separL=separability; } if ( filter ) // keep only the first candidates cut points { candidate.reduce(training,binMeasure-1,filterLimit,confiL); if ( trace>1 ) cout<<"\n*** remaining cut points after filter:\n" <1 ) cout<<"\n*** remaining cut points after optimization:\n" <=3 { Matrix hcn; cout<<"Size of the hypercube (2..20): "; int hcSize; cin>>hcSize; training.mapCube(hcn,hcSize); training.binarize(hcn); testing.binarize(hcn); stat(ii++) = training.dim(); } if ( trace>1 ) cout<<"\n*** binarized training data:\n"<1) { cout<<" mean"; coefWidth(cout,6); coefPrecision(cout,1); cout<