public void learnAndSave ( ) { System . out . println ( "======== Learning Classifier" ) ; // Either load pre-computed words or compute the words from the training images AssignCluster < double [ ] > assignment ; if ( new File ( CLUSTER_FILE_NAME ) . exists ( ) ) { assignment = UtilIO . load ( CLUSTER_FILE_NAME ) ; } else { System . out . println ( " Computing clusters" ) ; assignment = computeClusters ( ) ; } // Use these clusters to assign features to words FeatureToWordHistogram_F64 featuresToHistogram = new FeatureToWordHistogram_F64 ( assignment , HISTOGRAM_HARD ) ; // Storage for the work histogram in each image in the training set and their label List < HistogramScene > memory ; if ( ! new File ( HISTOGRAM_FILE_NAME ) . exists ( ) ) { System . out . println ( " computing histograms" ) ; memory = computeHistograms ( featuresToHistogram ) ; UtilIO . save ( memory , HISTOGRAM_FILE_NAME ) ; } }
Process all the data in the training data set to learn the classifications . See code for details .