📄 pair-main.c
字号:
/****************************************************************************** pair-main.c - driver program for program to do paired test******************************************************************************/#include <stdio.h>#include <math.h>#include "ripper.h"/******************************************************************************/char *Program="pair";char *Help_str[] = { "syntax: pair pred1 pred2", " perform a paired test on two prediction files", "", "options are:", " -v N set verbosity", NULL};/*****************************************************************************/int main(argc,argv)int argc;char *argv[];{ char pred1[BUFSIZ],act1[BUFSIZ],pred2[BUFSIZ],act2[BUFSIZ]; int p1,n1,p2,n2; char *file1,*file2; FILE *fp1,*fp2; BOOL right1,right2; int wins,losses,disagrees,total; double pwin,se; int o; while ((o=getopt(argc,argv,"v:h"))!=EOF) { switch (o) { case 'v': set_trace_level(atoi(optarg)); break; case 'h': case '?': default: give_help(); if (o=='h') exit(0); else fatal("option not implemented"); } } if (optind<argc) file1 = argv[optind++]; else { give_help(); fatal("prediction files must be specified"); } if (optind<argc) file2 = argv[optind++]; else { give_help(); fatal("prediction files must be specified"); } if (optind<argc) { warning("not all arguments were used: %s ...",argv[optind]); } if ((fp1=fopen(file1,"r"))==NULL) fatal("can't open %s",file1); if ((fp2=fopen(file2,"r"))==NULL) fatal("can't open %s",file2); total = wins = losses = disagrees = 0; while (!feof(fp1)) { total++; fscanf(fp1,"%s %d %d %s\n",pred1,&p1,&n1,act1); if (feof(fp2)) fatal("prediction files are of different lengths"); fscanf(fp2,"%s %d %d %s\n",pred2,&p2,&n2,act2); if (strcmp(act1,act2)!=0) fatal("prediction files out of sync at line %d",total); right1 = (strcmp(pred1,act1)==0); right2 = (strcmp(pred2,act2)==0); if (right1!=right2) { disagrees++; trace(LONG) { printf("// %d: c1=%s c2=%s actual=%s\n",pred1,pred2,act1); } if (right1) wins++; else losses++; } } if (!feof(fp2)) fatal("prediction files are of different lengths"); printf("%s vs %s W-L-T record:\n",file1,file2); printf("\t%d wins %d losses %d ties\n",wins,losses,total-disagrees); if (disagrees) { pwin = ((double) wins)/disagrees; se = sqrt( (pwin * (1-pwin)) / (disagrees-1.0) ); printf("\tprob(win|disagree) %.4f +/- %.4f",pwin,se); if (se>0) printf("\t%.4f su>0.5\n",(pwin-0.5)/se); else printf("\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -