BIC/AIC for Model Selection

Validation & Tuning DS practice problem on Onlearn.

Difficulty: medium.

Topics: BIC/AIC for Model Selection, Kullback-Leibler Divergence, Penalty Term, Degrees of Freedom, Log-Likelihood, Overfitting Mitigation, Statistical Inference, Information Theory, Model Evaluation, Optimization Theory, Probability Distributions, Maximum Likelihood Estimation, Regularization Techniques, Model Complexity Analysis, Likelihood Function Derivation, Parameter Estimation.

Implement a function calculate aic bic that computes the Akaike Information Criterion (AIC) and Bayesian Information Criterion (BIC) for model selection in regression problems. These information criteria are fundamental tools for comparing statistical models. They balance model fit (measured by residual error) against model complexity (measured by number of parameters). Lower values indicate better models. Your function should: Accept arrays of true values and predicted values, along with the number of model parameters k Compute the Residual Sum of Squares (RSS) from the predictions Calculate both AIC and BIC using the simplified formulas for Gaussian linear models Return both values as a tuple (AIC, BIC) The function should work for any regression model where you have predictions and can count the number of parameters. The parameter count k should include the intercept term if the model has one. Assume the input arrays have the same length and contain at least 2 samples. You may assume the predictions are not perfect (RSS 0).