示例#1
0
def compute_predictions(samples, past, future, pool):
    out = OUTPUT.replace('in.csv',
                         'in_{}_{}_{}.csv'.format(SHIPTYPE, past, future))
    print("Writing to {}".format(out))
    future = timedelta(minutes=future)
    with open(out, 'w') as output:
        output.write(EvaluatedPrediction.get_csv_header())
        for prediction in pool.starmap(prediction_worker,
                                       zip(samples, repeat(future))):
            try:
                if prediction: output.write(prediction.to_csv())
            except TypeError as e:
                print(e)
    output.close()
示例#2
0
def compute_final_sts_predictions(input_predictions, input_samples, past,
                                  future):
    out = OUTPUT.replace('.csv',
                         '_{}_{}_{}.csv'.format(SHIPTYPE, past, future))
    print("Writing to {}".format(out))
    with open(out, 'w') as output:
        output.write(EvaluatedPrediction.get_csv_header())
        for counter, sample in enumerate(input_samples):
            sample.id = '{}_{}'.format(counter, sample.id)
            prediction = compute_final_sts_prediction(input_predictions,
                                                      sample, past, future)
            try:
                output.write(prediction.to_csv())
            except TypeError as e:
                print(e)
            except AttributeError as e:
                pass
    output.close()