def prediction(models, fields, args, session_file=None): """Computes a supervised model prediction for each entry in the `test_set`. """ test_set = args.test_set test_set_header = args.test_header output = args.predictions test_reader = TestReader(test_set, test_set_header, fields, None, test_separator=args.test_separator) with UnicodeWriter(output, lineterminator="\n") as output: # columns to exclude if input_data is added to the prediction field exclude = use_prediction_headers(args.prediction_header, output, test_reader, fields, args, args.objective_field, quality="probability") # Local predictions: Predictions are computed locally message = u.dated("Creating local predictions.\n") u.log_message(message, log_file=session_file, console=args.verbosity) local_prediction(models, test_reader, output, args, exclude=exclude) test_reader.close()
def lr_prediction(linear_regressions, fields, args, session_file=None): """Computes a linear regression prediction for each entry in the `test_set`. """ test_set = args.test_set test_set_header = args.test_header output = args.predictions test_reader = TestReader(test_set, test_set_header, fields, None, test_separator=args.test_separator) with UnicodeWriter(output, lineterminator="\n") as output: # columns to exclude if input_data is added to the prediction field exclude = use_prediction_headers( args.prediction_header, output, test_reader, fields, args, args.objective_field, quality="probability") # Local predictions: Predictions are computed locally message = u.dated("Creating local predictions.\n") u.log_message(message, log_file=session_file, console=args.verbosity) local_prediction(linear_regressions, test_reader, output, args, exclude=exclude) test_reader.close()