/* ====================================================================== David W. Aha NGE: printing.c: Printing file for NGE ====================================================================== */ #include "nge.h" /* ====================================================================== Prints unchanging info to outputfile. ====================================================================== */ void print_general_info(fp) FILE *fp; /* (Outputfile) */ { fprintf(fp,"Trainingfile: %s\n",trainingfile); fprintf(fp,"Testingfile: %s\n",testingfile); if (greedy) fprintf(fp,"Algorithm: Greedy NGE\n"); else fprintf(fp,"Algorithm: NGE (not greedy)\n"); fprintf(fp,"Feature adjustment rate: %4.2f\n",feature_adjustment_rate); fprintf(fp,"Normalization method: Linear, done before training\n"); } /* ====================================================================== On printing the results of the experiments. ====================================================================== */ void print_classification_results(output_file,num_processed) FILE *output_file; register int num_processed; { /*==== Subfunctions ====*/ float classify_test_set(); /*==== Local Variables ====*/ register int; float percent_correct = classify_test_set(); /*==== 2. Print Testing Information to File ====*/ fprintf(output_file, "%4.2f percent (after %d Training Instances, %d exemplars)\n", percent_correct,num_processed, number_of_exemplars); printf("%4.2f percent (after %d Training Instances, %d exemplars)\n", percent_correct,num_processed, number_of_exemplars); printf("Returning to training...\n"); } /* ====================================================================== Classifies the test set using the current set of stored exemplars. Yields the percentage of test instances that were classified correctly. ====================================================================== */ float classify_test_set() { /*==== Subfunctions ====*/ extern int compute_distances(); /* Training.c */ extern void find_nearest_exemplar(); /* Training.c */ void print_instance(); void print_exemplars_distances(); /*==== Local variables ====*/ register int num_correct_on_test_set = 0, inst_num, num_stored; float percent_correct; /*==== Setup ====*/ printf("Testing...\n"); /*==== 1. Compute the number of correct classifications ====*/ for(inst_num=0; inst_num