@@ -0,0 +1,2014 @@
+#! /usr/bin/env python%0A%0Aimport argparse%0Aimport logging%0A%0Aimport keras%0Aimport pandas as pd%0A%0Afrom uno_data import DataFeeder%0Afrom uno_baseline_keras2 import evaluate_prediction, log_evaluation%0A%0Adef log_evaluation(metric_outputs, description='Comparing y_true and y_pred:'):%0A    print(description)%0A    for metric, value in metric_outputs.items():%0A        print('  %7B%7D: %7B:.4f%7D'.format(metric, value))%0A%0A%0Adef get_parser():%0A    parser = argparse.ArgumentParser(description='Uno infer script')%0A    parser.add_argument(%22--data%22,%0A                       help=%22data file to infer on. expect exported file from uno_baseline_keras2.py%22)%0A    parser.add_argument(%22--model_file%22, help=%22json model description file%22)%0A    parser.add_argument(%22--weights_file%22, help=%22model weights file%22)%0A%0A    return parser%0A%0A%0Adef main():%0A    parser = get_parser()%0A    args = parser.parse_args()%0A%0A    test_gen = DataFeeder(filename=args.data, batch_size=1024)%0A%0A    if 'json' == args.model_file.split('.')%5B-1%5D:%0A        with open(args.model_file, 'r') as f:%0A            model_json = f.read()%0A            print(model_json)%0A            model = keras.models.model_from_json(model_json)%0A            model.load_weights(args.weights_file)%0A    else:%0A        model = keras.models.load_model(args.model_file, compile=False)%0A        model.load_weights(args.weights_file)%0A%0A    model.summary()%0A%0A    y_test_pred = model.predict_generator(test_gen, test_gen.steps)%0A    y_test_pred = y_test_pred.flatten()%0A%0A    df_y = test_gen.get_response(copy=True)%0A    y_test = df_y%5B'Growth'%5D.values%0A    scores = evaluate_prediction(y_test, y_test_pred)%0A    log_evaluation(scores, description='Testing on data from %7B%7D (%7B%7D)'.format(args.data, len(y_test_pred)))%0A%0A    # save to tsv%0A    df_pred = df_y.assign(PredictedGrowth=y_test_pred, GrowthError=y_test_pred-y_test)%0A    df_pred.sort_values(%5B'Sample', 'Drug1', 'Drug2', 'Dose1', 'Dose2', 'Growth'%5D, inplace=True)%0A    df_pred.to_csv('prediction.tsv', sep='%5Ct', index=False, float_format='%25.4g')%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A%0A

add infer code