#include #include #include "linklist.h" #include inline INT (double val) { return val < 0 ? (int) (val - 0.5) : int (val + 0.5) ; } int main ( int argc, char *argv[] ) { ifstream ResultsFile, IdtFile; ofstream OutFile; double prob; int nvar , counter ; int nlines; int SoughtIdt, IdtIdt; LinkedList DataLine; double purity, efficiency; double threshold; float suppression; int nright[5000] = {0} , nwrong[5000] = {0}; int ntotal[5000] = {0} ; double dummy ; int nn; ResultsFile.open (argv[1], ios::nocreate ); IdtFile.open (argv[2], ios::nocreate ); OutFile.open (argv[3]); if (argc != 9) { // error treating cout << "check " << " <# neighbours>" << endl ; exit (0) ; } nvar = atoi (argv[4]); nlines = atoi (argv[5]); SoughtIdt = atoi (argv[6]); suppression = atof (argv[7]); nn = atoi (argv[8]); while (nlines-- ) { for ( counter = 0 ; counter++ <= nvar ; ) { IdtFile >> dummy ; DataLine.UnOrdInsert (dummy) ; } DataLine.End (); // idt is in the last column IdtIdt = INT (DataLine.GetValue ()); DataLine.Emptify (); ResultsFile >> prob; for (int cnt = 0; cnt < nn; cnt++ ) { threshold = (double)cnt*(1.0/nn) + 0.0001 ; if (abs (IdtIdt) == SoughtIdt) { ntotal[cnt]++; if (prob > threshold ) nright[cnt]++; } else if (prob > threshold ) nwrong[cnt]++; } } for ( int cnt = 0; cnt < nn; cnt++ ) { threshold = (double) cnt*(1.0/nn) + 0.0001; efficiency = (double) nright[cnt] / ntotal[cnt]; purity = (double) nright[cnt] / (nright[cnt] + suppression * nwrong[cnt]); OutFile << threshold << " " << efficiency << " " << purity << endl ; } ResultsFile.close (); IdtFile.close (); OutFile.close (); return 1; }