ARD Reference
The RegressionARD class implements Automatic Relevance Determination
(ARD) via the Sparse Bayesian Learning (SBL) algorithm [^1][^2]. When used
with cv=True, the model internally runs K-fold cross-validation at each
ARD iteration and selects the best-performing model state via retrospective
selection.
Cross-Validation Methods
Three scoring methods are available through the cv_method parameter:
| Method | Description |
|---|---|
'bayesian' |
Predictive log-likelihood CV with per-fold centering — the training data within each fold is centered independently using only that fold's statistics, and the validation data is transformed with the training-fold statistics. This eliminates the data-leakage that would result from centering on the full dataset before splitting. The score is \(\log p(y_{\text{val}} \mid X_{\text{val}}, \mathcal{D}_{\text{train}})\), i.e. the log predictive density of the held-out data under the ARD posterior fitted on the training fold. This is the recommended method. |
'predictive' |
Alias for 'bayesian'. |
'ridge' |
Legacy Ridge-regression CV (sklearn.linear_model.Ridge). Evaluates the current active feature set using a non-sparse L2-penalised model, which is statistically inconsistent with the ARD framework. Retained for backward compatibility only. |
All methods use 10-fold CV with a fixed random seed (42) for reproducibility. The best model iteration is chosen retrospectively after all ARD iterations complete, avoiding the instability of early-stopping heuristics.
Per-Fold Centering (v0.5.2+)
Prior to v0.5.2, CV was performed on data that had been centered using the full dataset mean before splitting. This leaked information from the validation fold into the centering transformation, producing systematically optimistic CV scores. The current implementation centres each fold independently:
The posterior \(\mathbf{m}, \mathbf{S}\) is computed from \(\mathbf{X}_{\text{train}}^{(c)}\) and predictions are converted back to original scale via \(\hat{\mathbf{y}}_{\text{val}} = \mathbf{X}_{\text{val}}^{(c)} \mathbf{m} + \bar{y}_{\text{train}}\).
[^1]: Tipping, M. E., & Faul, A. C. (2003). Fast marginal likelihood maximisation for sparse Bayesian models. AISTATS. [^2]: Tipping, M. E., & Faul, A. C. (2001). Analysis of sparse Bayesian learning. NeurIPS.
shapleyx.utilities.ARD
Backward-compatibility shim — delegates to shapleyx.ard._sbl.
The canonical implementation of RegressionARD and update_precisions
now lives at shapleyx.ard._sbl. This module is kept so that existing
code with from shapleyx.utilities.ARD import RegressionARD continues
to work.
RegressionARD(n_iter=300, tol=0.001, fit_intercept=True, copy_X=True, verbose=False, cv_tol=0.1, cv=False, cv_method='bayesian', cv_folds=10, retrospective_selection=True, store_history=False, threshold_lambda=10000.0, algorithm='sequential', alpha_1=1e-06, alpha_2=1e-06, lambda_1=1e-06, lambda_2=1e-06, return_std=False)
Bases: RegressorMixin, LinearModel
Regression with Automatic Relevance Determination (ARD) using Sparse Bayesian Learning.
This class implements a fast version of ARD regression, which is a Bayesian approach to regression that automatically determines the relevance of each feature. It is based on the Sparse Bayesian Learning (SBL) algorithm, which promotes sparsity in the model by estimating the precision of the coefficients.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
References
[1] Tipping, M. E., & Faul, A. C. (2003). Fast marginal likelihood maximisation for sparse Bayesian models. In Proceedings of the Ninth International Workshop on Artificial Intelligence and Statistics (pp. 276-283).
[2] Tipping, M. E., & Faul, A. C. (2001). Analysis of sparse Bayesian learning. In Advances in Neural Information Processing Systems (pp. 383-389).
Note
The RegressionARD class code has been adapted from the original implementation by Amazasp Shaumyan https://github.com/AmazaspShumik/sklearn-bayes
Source code in shapleyx/ard/_sbl.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
fit(X, y)
Fit the ARD regression model to the data.
Parameters
X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data, matrix of explanatory variables.
array-like, shape (n_samples,)
Target values.
Returns
self : object Returns the instance itself.
Source code in shapleyx/ard/_sbl.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
predict_dist(X)
Computes predictive distribution for test set. Predictive distribution for each data point is one dimensional Gaussian and therefore is characterised by mean and variance.
Parameters
X : {array-like, sparse matrix}, shape (n_samples_test, n_features) Test data, matrix of explanatory variables.
Returns
y_hat : array, shape (n_samples_test,) Estimated values of targets on the test set (mean of the predictive distribution).
array, shape (n_samples_test,)
Variance of the predictive distribution.
Source code in shapleyx/ard/_sbl.py
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
update_precisions(Q, S, q, s, A, active, tol, n_samples, clf_bias)
Updates the precision parameters (alpha) for features in a sparse Bayesian learning model by selecting a feature to add, recompute, or delete based on its impact on the log marginal likelihood. The function also checks for convergence.
Parameters:
Q : numpy.ndarray Quality parameters for all features. S : numpy.ndarray Sparsity parameters for all features. q : numpy.ndarray Quality parameters for features currently in the model. s : numpy.ndarray Sparsity parameters for features currently in the model. A : numpy.ndarray Precision parameters (alpha) for all features. active : numpy.ndarray (bool) Boolean array indicating whether each feature is currently in the model. tol : float Tolerance threshold for determining convergence based on changes in precision. n_samples : int Number of samples in the dataset, used to normalize the change in log marginal likelihood. clf_bias : bool Flag indicating whether the model includes a bias term (used in classification tasks).
Returns:
list A list containing two elements: - Updated precision parameters (A) for all features. - A boolean flag indicating whether the model has converged.
Notes:
The function performs the following steps: 1. Computes the change in log marginal likelihood for adding, recomputing, or deleting features. 2. Identifies the feature that causes the largest change in likelihood. 3. Updates the precision parameter (alpha) for the selected feature. 4. Checks for convergence based on whether no features are added/deleted and changes in precision are below the specified tolerance. 5. Returns the updated precision parameters and convergence status.
Convergence is determined by two conditions: - No features are added or deleted. - The change in precision for features already in the model is below the tolerance threshold.
The function ensures that the bias term is not removed in classification tasks.
Source code in shapleyx/ard/_sbl.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | |