def get_predictions(df, idxs=(0, -1)):
    data = torch.tensor(df[idxs[0]:idxs[1]].values, dtype=torch.float)
    pred = model(data).detach().numpy()
    data = data.detach().numpy()

    data_df = pd.DataFrame(data, columns=df.columns)
    pred_df = pd.DataFrame(pred, columns=df.columns)

    # Unnormalize
    unnormalized_data_df = utils.custom_unnormalize(data_df)
    unnormalized_pred_df = utils.custom_unnormalize(pred_df)

    # Handle variables with discrete distributions
    unnormalized_pred_df['N90Constituents'] = unnormalized_pred_df['N90Constituents'].round()
    uniques = unnormalized_data_df['ActiveArea'].unique()
    utils.round_to_input(unnormalized_pred_df, uniques, 'ActiveArea')

    data = unnormalized_data_df.values
    pred = unnormalized_pred_df.values

    return data, pred, unnormalized_data_df, unnormalized_pred_df
예제 #2
0
            bn_wd=False,
        )
        learn.model_dir = grid_search_folder + model_folder + '/' + 'models/'
        learn.load(saved_model_fname)
        learn.model.eval()

        idxs = (0, -1)  # Pick events to compare
        data = torch.tensor(test[idxs[0]:idxs[1]].values, dtype=torch.float)
        pred = model(data).detach().numpy()
        data = data.detach().numpy()

        data_df = pd.DataFrame(data, columns=test.columns)
        pred_df = pd.DataFrame(pred, columns=test.columns)

        # Unnormalize
        unnormalized_data_df = utils.custom_unnormalize(data_df)
        unnormalized_pred_df = utils.custom_unnormalize(pred_df)

        # Handle variables with discrete distributions
        unnormalized_pred_df['N90Constituents'] = unnormalized_pred_df[
            'N90Constituents'].round()
        uniques = unnormalized_data_df['ActiveArea'].unique()
        utils.round_to_input(unnormalized_pred_df, uniques, 'ActiveArea')

        data = unnormalized_data_df.values
        pred = unnormalized_pred_df.values

        # Residuals
        residuals = (pred - data) / data
        diff = (pred - data)