Exemplo n.º 1
0
def compare_to_previous():
    d = cached_surrogate_data(fname='tsa_p2_d0_q0',
                              k=1,
                              n_real=60,
                              n_samples=150,
                              n_warm=100,
                              n_input=80)
    summary = ktrain(d=d, epochs=50000)
    ratio = summary['test_error'] / TSA_P2_D0_Q0_BEST['test_error']
    summary['test_error_ratio'] = ratio
    return summary
Exemplo n.º 2
0
        keras.metrics.mean_squared_error(y_test_hat[:, 0, 0], d['y_test'][:,
                                                                          0]))
    y_val_hat = model.predict(d['x_val'])
    val_error = float(
        keras.metrics.mean_squared_error(y_val_hat[:, 0, 0], d['y_val'][:, 0]))
    y_train_hat = model.predict(d['x_train'])
    train_error = float(
        keras.metrics.mean_squared_error(y_train_hat[:, 0, 0],
                                         d['y_train'][:, 0]))
    summary = {
        "train_error": train_error,
        "val_error": val_error,
        "test_error": test_error
    }
    return summary


if __name__ == '__main__':
    n_inputs = 80
    epochs = 500
    d = cached_surrogate_data(fname='tsa_p2_d0_q0',
                              k=1,
                              n_real=60,
                              n_samples=150,
                              n_warm=100,
                              n_input=n_inputs)
    best_model = tunertrain(d=d, n_input=n_inputs, epochs=epochs)
    summary = summarize_model(d=d, model=best_model)
    ratio = summary['test_error'] / SLUGGISH_MOVING_AVERAGE_BEST['test_error']
    summary['test_error_ratio'] = ratio
    pprint(summary)
Exemplo n.º 3
0
def compare_to_previous():
   d = cached_surrogate_data(fname='sluggish_moving_average', k=1, n_real=50, n_samples=150, n_warm = 100, n_input=80)
   summary = ktrain(d=d, epochs=1000)
   ratio = summary['test_error'] / SLUGGISH_MOVING_AVERAGE_BEST['test_error']
   summary['test_error_ratio'] = ratio
   return summary
Exemplo n.º 4
0
def compare_to_previous():
   d = cached_surrogate_data(fname='thinking_slow_and_fast', k=1, n_real=50, n_samples=150, n_warm = 100, n_input=80)
   summary = ktrain(d=d, epochs=5000)
   ratio = summary['test_error'] / SLOW_AND_FAST_BEST['test_error']
   summary['test_error_ratio'] = ratio
   return summary
        keras.metrics.mean_squared_error(y_test_hat[:, 0, 0], d['y_test'][:,
                                                                          0]))
    y_val_hat = model.predict(d['x_val'])
    val_error = float(
        keras.metrics.mean_squared_error(y_val_hat[:, 0, 0], d['y_val'][:, 0]))
    y_train_hat = model.predict(d['x_train'])
    train_error = float(
        keras.metrics.mean_squared_error(y_train_hat[:, 0, 0],
                                         d['y_train'][:, 0]))
    summary = {
        "train_error": train_error,
        "val_error": val_error,
        "test_error": test_error
    }
    return summary


if __name__ == '__main__':
    n_inputs = 80
    epochs = 500
    d = cached_surrogate_data(fname='sluggish_moving_average',
                              k=1,
                              n_real=50,
                              n_samples=150,
                              n_warm=100,
                              n_input=n_inputs)
    best_model = tunertrain(d=d, n_input=n_inputs, epochs=epochs)
    summary = summarize_model(d=d, model=best_model)
    ratio = summary['test_error'] / SLUGGISH_MOVING_AVERAGE_BEST['test_error']
    summary['test_error_ratio'] = ratio
    pprint(summary)
Exemplo n.º 6
0
        keras.metrics.mean_squared_error(y_test_hat[:, 0, 0], d['y_test'][:,
                                                                          0]))
    y_val_hat = model.predict(d['x_val'])
    val_error = float(
        keras.metrics.mean_squared_error(y_val_hat[:, 0, 0], d['y_val'][:, 0]))
    y_train_hat = model.predict(d['x_train'])
    train_error = float(
        keras.metrics.mean_squared_error(y_train_hat[:, 0, 0],
                                         d['y_train'][:, 0]))
    summary = {
        "train_error": train_error,
        "val_error": val_error,
        "test_error": test_error
    }
    return summary


if __name__ == '__main__':
    n_inputs = 80
    epochs = 500
    d = cached_surrogate_data(fname='slow_precision_ema_ensemble',
                              k=1,
                              n_real=80,
                              n_samples=150,
                              n_warm=100,
                              n_input=n_inputs)
    best_model = tunertrain(d=d, n_input=n_inputs, epochs=epochs)
    summary = summarize_model(d=d, model=best_model)
    ratio = summary['test_error'] / SLUGGISH_MOVING_AVERAGE_BEST['test_error']
    summary['test_error_ratio'] = ratio
    pprint(summary)
Exemplo n.º 7
0
        overwrite=True,
        max_epochs=2500)

    tuner.search(d['x_train'], d['y_train'], epochs=epochs,
                 validation_data=(d['x_val'], d['y_val']),callbacks = [callback])
    print(tuner.results_summary())
    best_model = tuner.get_best_models()[0]
    return best_model


def summarize_model(d, model):
    y_test_hat = model.predict(d['x_test'])
    test_error = float(keras.metrics.mean_squared_error(y_test_hat[:, 0, 0], d['y_test'][:, 0]))
    y_val_hat = model.predict(d['x_val'])
    val_error = float(keras.metrics.mean_squared_error(y_val_hat[:, 0, 0], d['y_val'][:, 0]))
    y_train_hat = model.predict(d['x_train'])
    train_error = float(keras.metrics.mean_squared_error(y_train_hat[:, 0, 0], d['y_train'][:, 0]))
    summary = {"train_error": train_error,
            "val_error": val_error,
            "test_error": test_error}
    return summary

if __name__=='__main__':
   n_inputs = 80
   epochs = 500
   d = cached_surrogate_data(fname='thinking_slow_and_fast', k=1, n_real=50, n_samples=150, n_warm=100, n_input=n_inputs)
   best_model = tunertrain(d=d,n_input=n_inputs, epochs=epochs)
   summary = summarize_model(d=d, model=best_model)
   ratio = summary['test_error'] / SLUGGISH_MOVING_AVERAGE_BEST['test_error']
   summary['test_error_ratio'] = ratio
   pprint(summary)