Changeset 33141 for other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaAccuracyCalculator.java
- Timestamp:
- 2019-06-10T13:48:01+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaAccuracyCalculator.java
r33097 r33141 1 2 1 import java.io.File; 3 2 import java.io.BufferedReader; … … 5 4 import java.io.FileReader; 6 5 import java.io.FileWriter; 7 8 9 6 public class javaAccuracyCalculator{ 10 11 public static void main(String[] args) { 12 7 8 //Read in log.txt, grab first item in array of each line 9 //Counter for everytime have readline 10 //Calculate accuracy rate 11 public static void main(String[] args) { 13 12 try { 14 13 if (args.length != 3) { … … 21 20 FileReader fileReader = new FileReader(inputFilename); 22 21 BufferedReader buf = new BufferedReader(fileReader); 23 FileWriter fw = new FileWriter(outputFilename );22 FileWriter fw = new FileWriter(outputFilename,true); 24 23 String line = null; 25 24 String[] item; 26 float accuracyRate = 0; 27 int trueCount = 0; 28 int lineCount = 0; 29 30 //RENAME CLASSIFIER NUMBER TO ACTUALL CLASSIFIER 31 if(classifierType.equals("1")){classifierType = "Probabilistic HoughLines";} 32 25 float trueAccuracyRate =0; 26 float falseAccuracyRate =0; 27 int trueCount = 0; 28 int falseCount = 0; 29 int sheetMusicCount = 0; 30 int notSheetMusicCount = 0; 33 31 //Splits into each record, since readLine splits by "\n" 34 32 while ((line = buf.readLine()) != null) { 35 lineCount++; 36 //Splits by tab, leaves "" for every blank entry 37 item = line.split("\t"); 38 //Check first element (true or false) 39 if(item[0].equals("1")){ 40 trueCount++; 33 item = line.split("\t"); 34 //Calculate AccuracyRates 35 if(item[1].contains("TestImages/SheetMusic/")){ 36 sheetMusicCount++; 37 if(item[3].equals("true")){ 38 trueCount++; 39 } 40 } 41 if(item[1].contains("TestImages/NotSheetMusic/")){ 42 notSheetMusicCount++; 43 if(item[3].equals("true")){ 44 falseCount++; 45 } 41 46 } 42 47 } 43 accuracyRate = ((float)trueCount/(float)lineCount)*(float)100; 44 fw.write("Classifier:" + classifierType + "\t" + accuracyRate + "%" + "\n"); 48 49 //Amount of sheetMusic classified images / total amount of images read 50 trueAccuracyRate = ((float)trueCount/(float)sheetMusicCount)*(float)100; 51 //Amount of notSheetMusic classified images / total amount of images read 52 falseAccuracyRate = ((float)falseCount/(float)notSheetMusicCount)*(float)100; 53 54 fw.write("Classifier: " + classifierType + '\t' + "SheetMusicAccuracyRate: " + trueAccuracyRate + "%" + '\t' + "NotSheetMusicAccuracyRate :" + falseAccuracyRate + "%" + "\n"); 45 55 buf.close(); 46 fw.close(); 47 48 //Read in log.txt, grab first item in array of each line 49 //counter for everytime have readline 50 51 //Calculate accuracy rate 52 56 fw.close(); 53 57 } 54 58 }
Note:
See TracChangeset
for help on using the changeset viewer.