I am using the smbinning R package to compute the variables information value included in my dataset.
The function smbinning()
is pretty simple and it has to be used as follows:
result = smbinning(df= dataframe, y= "target_variable", x="characteristic_variable", p = 0.05)
So, df
is the dataset you want to analyse, y
the target variable and x
is the variable of which you want to compute the information value statistics; I enumerate all the characteristic variables as z1, z2, ... z417
to be able to use a for loop to mechanize all the analysis process.
I tried to use the following for loop:
for (i in 1:417) {
result = smbinning(df=DATA, y = "FLAG", x = "DATA[,i]", p=0.05)
}
in order to be able to compute the information value for each variable corresponding to i
column of the dataframe.
The DATA
class is "data.frame" while the result
one is "character"
.
So, my question is how to compute the information value of each variable and store that in the object denominated result
?
Thanks! Any help will be appreciated!
No sample data is provided I can only hazard a guess that the following will work:
results_list = list()
for (i in 1:417) {
current_var = paste0('z', i)
current_result = smbinning(df=DATA, y = "FLAG", x = current_var, p=0.05)
results_list[i] = current_result$iv
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With