From 680b1fec0ada8a801e37816e596509222f4a2509 Mon Sep 17 00:00:00 2001 From: Jack Wright Date: Mon, 5 Aug 2024 20:49:27 +0100 Subject: [PATCH] fix heatmap plot regression --- nextorch/bo.py | 7 +++++-- nextorch/plotting.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nextorch/bo.py b/nextorch/bo.py index 7fb1e61..0cace26 100644 --- a/nextorch/bo.py +++ b/nextorch/bo.py @@ -1175,7 +1175,8 @@ def predict(self, def predict_real(self, X_test: MatrixLike2d, - show_confidence: Optional[bool] = False + show_confidence: Optional[bool] = False, + scale_X: bool = True ) -> Union[Matrix, Tuple[Matrix, Matrix, Matrix]]: """Use GP model for prediction at X_test @@ -1188,6 +1189,8 @@ def predict_real(self, show_confidence : Optional[bool], optional by default False, only return posterior mean If True, return the mean, and lower, upper confidence interval + scale_X: bool, optional + by default True, convert X to unit scale if not scaled already. Returns ------- @@ -1198,7 +1201,7 @@ def predict_real(self, Y_test_upper_real: numpy matrix The upper confidence interval in a real scale """ - X_test_real = ut.unitscale_X(X_test, self.X_ranges) + X_test_real = ut.unitscale_X(X_test, self.X_ranges) if scale_X else X_test Y_real, Y_lower_real, Y_upper_real = model_predict_real(self.model, X_test_real, self.Y_mean, diff --git a/nextorch/plotting.py b/nextorch/plotting.py index 9c54843..3ec2969 100644 --- a/nextorch/plotting.py +++ b/nextorch/plotting.py @@ -1443,8 +1443,8 @@ def response_heatmap_exp( baseline=baseline, mesh_size=mesh_size) - # Make prediction using the GP model - Y_test = Exp.predict_real(X_test) + # Make prediction using the GP model, don't scale X as it's already scaled + Y_test = Exp.predict_real(X_test, scale_X=False) Y_test_2d = transform_Y_mesh_2d(Y_test, mesh_size=mesh_size) # select the sample points X_train = None