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
Exemple #2
0
        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)

        for kk, key in enumerate(test.keys()):
            if key in diff_list:
                curr_residuals = diff[:, kk]
                if key == 'AverageLArQF':
                    curr_residuals = curr_residuals[
                        np.abs(curr_residuals) < 1000]
                limits = (-1000, 1000)