diff --git a/skgstat/Variogram.py b/skgstat/Variogram.py index d2c1176..cf1003d 100644 --- a/skgstat/Variogram.py +++ b/skgstat/Variogram.py @@ -2220,6 +2220,7 @@ def residuals(self): ) return self.model_residuals + @property def model_residuals(self) -> np.ndarray: """ @@ -2277,19 +2278,11 @@ def rmse(self): RMSE = \sqrt{\frac{\sum_{i=0}^{i=N(x)} (x-y)^2}{N(x)}} """ - # get the deviations - experimental, model = self.model_deviations() - - # get the sum of squares - rsum = np.nansum(np.fromiter( - map(lambda x, y: (x - y)**2, experimental, model), float) - ) - - return np.sqrt(rsum / len(model)) + return self.root_mean_square @property def mse(self): - r"""RMSE + r"""MSE Calculate the Mean squared error between the experimental variogram and the theoretical model values at corresponding lags. @@ -2383,6 +2376,39 @@ def nrmse(self): """ return self.rmse / np.nanmean(self.experimental) + @property + def root_mean_square(self): + """Root Mean Square (RMS) of the residuals + + Calculates the square root of the mean of squared residuals. + + Returns + ------- + float + Root Mean Square of the residuals. + """ + return np.sqrt(np.nanmean(np.square(self.model_residuals))) + + @property + def residual_sum_of_squares(self): + """Residual Sum of Squares (RSS) + + Calculates the sum of squared differences between the experimental + variogram and theoretical model values. + + Returns + ------- + float + Residual sum of squares (RSS), a measure of the overall model fit + representing the sum of squared deviations between the observed + experimental variogram and the corresponding theoretical model values. + """ + return np.nansum(np.square(self.model_residuals)) + + @property + def rss(self): + return self.residual_sum_of_squares + @property def nrmse_r(self): r"""NRMSE diff --git a/skgstat/tests/test_variogram.py b/skgstat/tests/test_variogram.py index ef10141..f1a6273 100644 --- a/skgstat/tests/test_variogram.py +++ b/skgstat/tests/test_variogram.py @@ -1197,6 +1197,11 @@ def test_mse(self): self.assertAlmostEqual(np.sqrt(V.mse), V.rmse, places=6) + def test_rss(self): + V = Variogram(self.c, self.v, n_lags=15) + + self.assertAlmostEqual(V.rss, 357.76, places=2) + def test_update_kwargs(self): V = Variogram(self.c, self.v, percentile=.3)