Learn R Programming

creditmodel (version 1.0)

lasso_filter: Selected Variables by LASSO

Description

lasso_filter filter variables by lasso.

Usage

lasso_filter(dat_train, dat_test = NULL, target = NULL,
  x_list = NULL, pos_flag = list(1, "1", "bad"), ex_cols = NULL,
  best_lambda = "lambda.min", sim_sign = "negtive",
  save_data = FALSE, parallel = FALSE, plot.it = TRUE, seed = 46,
  file_name = NULL, dir_path = tempdir())

Arguments

dat_train

A data.frame with independent variables and target variable.

dat_test

A data.frame of test data. Default is NULL.

target

The name of target variable.

x_list

Names of independent variables.

pos_flag

The value of positive class of target variable, default: "1".

ex_cols

A list of excluded variables. Regular expressions can also be used to match variable names. Default is NULL.

best_lambda

Best lanmbda stardards. one of ("lambda.min", "lambda.1se", "lambda.05se" , "lambda.sim_sign"). Default is "lambda.min".

sim_sign

The coefficients of all variables should be all negetive or positive, after turning to woe. Default is "negetive" for pos_flag is "1".

save_data

Logical, save results in locally specified folder. Default is TRUE

parallel

Logical, parallel computing. Default is FALSE.

plot.it

Logical, shrinkage plot. Default is TRUE.

seed

Random number seed. Default is 46.

file_name

The name for periodically saved results files. Default is "Feature_selected_LASSO".

dir_path

The path for periodically saved results files. Default is "./variable".

Value

A list of filtered x variables by lasso.

Examples

Run this code
# NOT RUN {
lasso_filter(dat_train = UCICreditCard[1:1000,c(4,12:15,26)],
            target = "default.payment.next.month",
            best_lambda = "lambda.min", save_data = FALSE,plot.it = FALSE)
# }

Run the code above in your browser using DataLab