kraken19 / woeR

Weight of Evidence binning of a variable
6 stars 2 forks source link

Error in cut.default(df[, variable], breaks = breaks, include.lowest = T, : lengths of 'breaks' and 'labels' differ #1

Open ssobel opened 6 years ago

ssobel commented 6 years ago

Hello, I am getting the above captioned error. Can you help me resolve? Thank you very much.

Here is my data and command below: dftest <- data.frame(V2 <- c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, 11, 4, 2, 4, 10, 2, 4, 13, 4, 4, 4, 4, 2, 2, 9, 4, 9, 4, 4, 6, 11, 2, 2, 11, 11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 10, 14, 8, 4, 2, 8, 8, 11, 4, 11, 9, 4, 7, 11, 11, 2, 11, 11, 12, 2, 16, 11, 4, 12, 4, 11, 4, 4, 3, 11, 4, 13, 16, 7, 4, 4, 4, 14, 4, 14, 11, 14, 14, 14, 8, 11, 4, 14, 16, 11, 11, 2, 14, 14, 14, 14, 14, 11, 4, 11, 11, 12, 9, 9, 4, 11, 14, 11, 11, 9, 14, 16, 14, 14, 14, 16, 14, 16, 11, 11, 9, 14, 23, 11, 11, 11, 11, 11, 11, 11, 11, 16, 14, 9, 14, 11, 4, 21, 11, 14, 23, 14, 11, 16, 4, 14, 11, 14, 14, 14, 14, 14, 14, 14, 14, 9, 14, 11, 11, 4, 11, 16, 16, 21, 21, 16, 21, 18, 23, 16, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 21, 21, 14, 16, 23, 14, 23, 16, 9, 9, 16, 14, 16, 21, 14, 18, 16, 11, 23, 21, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 23, 21, 22, 11, 23, 23, 23, 14, 21, 26, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 16, 21, 23, 23, 35, 74, 2, 6, 2, 2, 2, 4, 2, 2, 3, 4, 3, 4, 3, 4, 2, 2, 4, 1, 4, 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 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1))

woe_binning(df = dftest, variable = "V2", dv = "target", min_perc = 0.1, initial_bins = 20, woe_cutoff = 0.1)

kraken19 commented 6 years ago

Hi @ssobel ,

Thanks for pointing out the bug. Apologies for the delay in response. For some reason I missed your post here.

I have updated the code to fix the issue mentioned by you and will release it in the next update to the package. In the meantime, you can use the development version of the package from the below link: https://github.com/kraken19/woeR/

I also ran the updated code on your dataset. The IV for variable V2 = 0.527 and breaks are : c(-Inf, 2, 9, 11, Inf) .

Please let me know if you face any another issue while using this package.

Thanks Kashish

linards-kalvans commented 5 years ago

Encountered the same bug in CRAN version, seems to be fixed with github version.