knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Introduction
AIC stands for Akaike’s Information Criterion. It estimates the quality of a model, relative to each of other models. The lower AIC score is, the better the model is. Therefore, a model with lowest AIC - in comparison to others, is chosen.
AIC = n*log(residual sum of squares/n) + 2K
where:
Function
aic(y, y_pred, p)
Parameters:
True target variable(s)
y_pred: array-like of shape = (n_samples) or (n_samples, n_outputs)
Fitted target variable(s) obtained from your regression model
p: int
Return:
y <- c(1,2,3,4) y_pred <- c(5,6,7,8) p <- 3 aic(y, y_pred, p)
Introduction:
BIC stands for Bayesian Information Criterion. Like AIC, it also estimates the quality of a model. When fitting models, it is possible to increase model fitness by adding more parameters. Doing this may results in model overfit. Both AIC and BIC helps to resolve this problem by using a penalty term for the number of parameters in the model. This term is bigger in BIC than in AIC.
BIC = n*log(residual sum of squares/n) + K*log(n)
where:
bic(y, y_pred, p)
Parameters:
True target variable(s)
y_pred: array-like of shape = (n_samples) or (n_samples, n_outputs)
Fitted target variable(s) obtained from your regression model
p: int
Return:
y <- c(1,2,3,4) y_pred <- c(5,6,7,8) p <- 3 bic(y, y_pred, p)
Introduction
Mallow's C_p is named for Colin Lingwood Mallows. It is used to assess the fit of regression model, finding the best model involving a subset of predictive variables available for predicting some outcome.
C_p = (SSE_p/MSE) - (n - 2p)
where:
p
explanatory
variables counting the intercept.k
explanatory variables of interest)mallow(y, y_pred, y_sub, p, k)
Parameters:
True target variable(s)
y_pred: vector of shape = (n_samples) or (n_samples, n_outputs)
Fitted target variable(s) obtained from your regression model
y_sub: vector of shape = (n_samples) or (n_samples, n_outputs)
Fitted target variable(s) obtained from your subset regression model
k: int
Number of predictive variable(s) used in the model
p: int
Return:
y <- c(1,2,3,4) y_pred <- c(5,6,7,8) y_sub <- c(1,2,3,5) p <- 3 k <-2 mallow(y, y_pred, y_sub, p, k)
broom
package has a function finish_glance
that outputs some of regression metrics in a table:
Log likelihoods
AIC
BIC
Deviance
* Residual degrees of freedom
Although this function provides a table with some of the key metrics that we want to include in our package (AIC, BIC), it lacks of other metrics such as MSE and Mallow's C_p. Additionally, finish_glance
's output table only include metrics for 1 model which might not be as easy to compare metrics of all models as out intended output table of comparison. That being said, our package can solve this problem, and be a united source for all popular regression model comparison metrics.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.