def runWithoutWndchrm(self): print "Loading the classifier" classifier = data_io.load_model() imageCollections = data_io.get_valid_df() featureGetter = FeatureGetter() print "Getting the features" fileName = data_io.get_savez_name_test() if not self.load: #Last features calculated from candidates (namesObservations, coordinates, valid) = Utils.calculateFeatures(fileName, featureGetter, imageCollections) else: (namesObservations, coordinates, valid) = Utils.loadFeatures(fileName) print "Making predictions" #valid = normalize(valid, axis=0) #askdfhashdf predictions = classifier.predict(valid) predictions = predictions.reshape(len(predictions), 1) print "Writing predictions to file" data_io.write_submission(namesObservations, coordinates, predictions) data_io.write_submission_nice(namesObservations, coordinates, predictions) print "Calculating final results" return Predictor.finalResults(namesObservations, predictions, coordinates)
def run(self): print "Preparing the environment" self.prepareEnvironment() print "Loading the classifier" classifier = data_io.load_model() imageCollections = data_io.get_valid_df() featureGetter = FeatureGetter() wndchrmWorker = WndchrmWorkerPredict() print "Getting the features" if not self.loadWndchrm: #Last wndchrm set of features fileName = data_io.get_savez_name_test() if not self.load: #Last features calculated from candidates (namesObservations, coordinates, _) = Utils.calculateFeatures(fileName, featureGetter, imageCollections) else: (namesObservations, coordinates, _) = Utils.loadFeatures(fileName) print "Saving images" imageSaver = ImageSaver(coordinates, namesObservations, imageCollections, featureGetter.patchSize) imageSaver.saveImages() print "Executing wndchrm algorithm" valid = wndchrmWorker.executeWndchrm(namesObservations) else: (valid, namesObservations) = wndchrmWorker.loadWndchrmFeatures() print "Making predictions" predictions = classifier.predict(valid) predictions = predictions.reshape(len(predictions), 1) print "Writing predictions to file" data_io.write_submission(namesObservations, coordinates, predictions) data_io.write_submission_nice(namesObservations, coordinates, predictions) print "Calculating final results" return Predictor.finalResults(namesObservations, predictions, coordinates)