1
$\begingroup$

I'm using R for machine learning. The objective is to classify the onset of disease (Two-class).

Before conducting a machine learning algorithm, I ran the glmnet (to utilize elastic net) to reduce the number of total variables.

My dataset has a lot of categorical variables such as gender, educational level, marital status, living regions, ...

Whereas some variables are binary (i.e., male/female in gender), others are more than two (i.e., elementary/middle/high/college/professional in educational level).

To enter those variables in the glmnet, I converted them into the dummy variables. For example, 'gender' was split in two ('male' (1 for male and 0 for female) and 'female' (1 for female and 0 for male), and educational level was split in 5 ('elementary', 'middle', 'high', 'college', 'professional'). This way, all the categorical variables were split in by the number of their levels.

After the glmnet was conducted, I got the coefs for each dummy variable as following.

male0           0.159 
male1           0.000 
female0         0.000 
female1         0.004 
elementary0     -0.127 
elementary1     0.000
middle0         .
middle1         .
high0           .
high1           .
college0        0.719 
college1        .
professional0   1.360 
professional1   -0.084 
......

My question is two.

(1) Can I drop only dummy variables with coef = . in the final machine learning model?

(2) How can I interpret the importance of the 'gender' and 'education' but not the splitted dummy variables (male, female, elementary, ...) ?

Thanks.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.