geopfa.extrapolation.get_predictions¶
- get_predictions(model, X, kvals_df=None, Y_mean=None, Y_std=None)[source]¶
Generate GP predictions, optionally converting back to original Y-units and optionally reshaping predictions into a 2D grid defined by x/y coordinates.
- Parameters:
model (GPy.models.GPRegression) – Trained GP regression model.
X (numpy.ndarray) – Input features in the same standardized space used during training, shape
(N, D).kvals_df (pandas.DataFrame or dict, optional) – Must contain
'x'and'y'. If provided, predictions are reshaped into a pivoted 2-D grid of shape (len(y_unique), len(x_unique))Y_mean (float or None, optional) – Mean of Y from the training dataset (for de-standardizing predictions).
Y_std (float or None, optional) – Standard deviation of Y from the training dataset.
- Returns:
numpy.ndarray or tuple – If
kvals_dfis None, returns(Y_pred_flat, Y_std_flat)where both arrays have shape(N,). Ifkvals_dfis provided, returns(Y_pred_grid, Y_std_grid, x_unique, y_unique)where the grids have shape(ny, nx)and the coordinate arrays contain the sorted unique values from the pivot.
Notes
- This function reproduces the original behavior precisely:
No additional sorting is applied beyond pandas pivot ordering.
De-standardization (mean/std) is optional and only applied if both parameters are provided.