logger.info('Updated image generation parameters: %s', image_generation_params) #Compute predictions num_prediction_steps = num_prediction_steps or ceil(len(input_data) / image_generation_params.batch_size) predictor = Prediction(model, input_params, image_generation_params) predicted_data = predictor.predict(input_data, num_prediction_steps) #Compute accuracy num_matches = (predicted_data[constants.PANDAS_MATCH_COLUMN].to_numpy().nonzero())[0].shape[0] num_mismatches = len(predicted_data[constants.PANDAS_MATCH_COLUMN]) - num_matches accuracy = (num_matches/len(predicted_data[constants.PANDAS_MATCH_COLUMN])) * 100. #Write-out predicted output prediction_result_file = InputDataFile(constants.PREDICTION_RESULT_FILE_NAME_GUIDANCE) prediction_result_file.save(predicted_data, 0, 0) input_files_client.put_all([prediction_result_file.file_name(0, 0)]) print_summary = """ Result Dataframe: {} Total predictions: {} Correct predictions: {} Wrong predictions: {} Accuracy: {} """.format( predicted_data, len(predicted_data), num_matches, num_mismatches, accuracy) #Print summary
#Prepare input files input_files_client = InputFiles(dropbox) input_data = input_files_client.get_all([input_data])[input_data] #Input data as pandas data frame input_data = csv_to_dataframe(input_data) ####################################### Prepare the input dataset [End] ############################################ ####################################### Rebalance the dataset [Start] ############################################ #Rebalance the data and obtain the statistics rebalancer = Rebalancing(input_data, label_col) result, pre_stats, post_stats = rebalancer.rebalance(statistics=True) ####################################### Rebalance the dataset [End] ############################################ #Output to a file dataframe_to_csv(result, output_file) ####################################### Process output [Start] ############################################ #Upload the output to dropbox if dropbox: input_files_client.put_all([output_file]) print_summary = """ Pre-balancing statistics: {} Results: {} Post-balancing statistics: {} """.format(pre_stats, result, post_stats) print(print_summary) ####################################### Process output [End] ############################################