Description Usage Arguments Value Examples
Plots coefficients from regularizing various models.
1 | regularization_plot(model, lambda, tol = 1e-07, x, y)
|
model: |
String specifying lasso, ridge regression, or logistic regression with L2-regularization. Argument should be one of "lasso", "ridge", or "logistic". |
lambda: |
Vector of penalty constant(s) multiplying the regularization term. Larger value corresponds to stronger regularization. |
tol: |
Coefficients less than this will be treated as zero. |
x: |
n x d dataframe of features. |
y: |
n x 1 dataframe of response values. |
ggplot object. Plot returned depends on length of lambda. length(lambda)==1: Plot displays magnitude of model coefficients, where coefficients with magnitude less than 'tol' are treated as zero. length(lambda)>1: Plot displays counts of nonzero coefficients in each model, where coefficients with magnitude less than 'tol' are treated as zero.
1 2 3 4 5 | X <- mtcars[-1]
Y <- data.frame(mtcars$mpg)
regularization_plot('ridge', lambda=2^c(1,0,1), x=X, y=Y)
regularization_plot('lasso', lambda=2, x=X, y=Y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.