topepo / APM_Exercises

Exercises for the book Applied Predictive Modeling by Kuhn and Johnson (2013)
194 stars 158 forks source link

in Chap 13, we hit the following error #8

Open vkjuju opened 7 years ago

vkjuju commented 7 years ago

nbTraining <- training[, c("Class", nbPredictors)] Error in [.data.frame(training, , c("Class", nbPredictors)) : undefined columns selected

any advice would be appreciated

vkjuju commented 7 years ago

nbPredictors [1] "NumCI" "NumDR" "NumECI" [4] "NumPS" "NumSCI" "NumSR" [7] "NumUNK" "CI.1940" "CI.1945" [10] "CI.1950" "CI.1955" "DR.1955" [13] "PS.1955" "CI.1960" "PS.1960" [16] "CI.1965" "PS.1965" "CI.1970" [19] "CI.1975" "CI.1980" "CI.AsiaPacific" [22] "CI.Australia" "DR.Australia" "PS.Australia" [25] "CI.EasternEurope" "CI.GreatBritain" "CI.MiddleEastandAfrica" [28] "CI.NewZealand" "CI.NorthAmerica" "CI.SouthAfrica" [31] "CI.TheAmericas" "CI.WesternEurope" "CI.English" [34] "DR.English" "PS.English" "CI.OtherLang" [37] "CI.PhD" "DR.PhD" "PS.PhD" [40] "Success.CI" "Unsuccess.CI" "Success.DR" [43] "Success.PS" "Unsuccess.PS" "CI.Dept1033" [46] "CI.Dept1038" "CI.Dept1098" "CI.Dept1258" [49] "CI.Dept2053" "CI.Dept2103" "CI.Dept2153" [52] "CI.Dept2163" "CI.Dept2178" "CI.Dept2253" [55] "CI.Dept2498" "CI.Dept2523" "CI.Dept2533" [58] "CI.Dept2538" "CI.Dept2553" "CI.Dept2558" [61] "CI.Dept2563" "CI.Dept2578" "CI.Dept2603" [64] "CI.Dept2628" "CI.Dept2653" "CI.Dept2668" [67] "CI.Dept2678" "PS.Dept2678" "CI.Dept2713" [70] "CI.Dept2728" "CI.Dept2763" "CI.Dept2768" [73] "CI.Dept2813" "CI.Dept2828" "CI.Dept2853" [76] "CI.Dept2893" "CI.Dept2923" "CI.Dept3028" [79] "CI.Dept3048" "CI.Dept3098" "CI.Dept3123" [82] "CI.Dept3198" "CI.Dept3258" "CI.Dept3268" [85] "CI.Dept528" "CI.Dept593" "CI.Dept653" [88] "CI.Dept803" "CI.Dept828" "CI.Faculty1" [91] "CI.Faculty13" "CI.Faculty19" "CI.Faculty22" [94] "CI.Faculty25" "DR.Faculty25" "PS.Faculty25" [97] "CI.Faculty31" "PS.Faculty31" "CI.Faculty34" [100] "CI.Faculty4" "CI.Faculty46" "CI.Faculty7" [103] "Duration0to5" "Duration10to15" "Duration5to10" [106] "DurationGT15" "DurationLT0" "DurationUnk" [109] "Astar.CI" "A.CI" "B.CI" [112] "C.CI" "Astar.PS" "A.PS" [115] "C.PS" "AstarTotal" "ATotal" [118] "BTotal" "CTotal" "RFCD250103" [121] "RFCD270103" "RFCD270106" "RFCD270199" [124] "RFCD270201" "RFCD270299" "RFCD270603" [127] "RFCD270708" "RFCD320202" "RFCD320305" [130] "RFCD320502" "RFCD320602" "RFCD320701" [133] "RFCD320702" "RFCD320799" "RFCD320899" [136] "RFCD321003" "RFCD321004" "RFCD321006" [139] "RFCD321010" "RFCD321013" "RFCD321014" [142] "RFCD321015" "RFCD321016" "RFCD321021" [145] "RFCD321024" "RFCD321028" "RFCD321029" [148] "RFCD321202" "RFCD321204" "RFCD321206" [151] "RFCD321208" "RFCD321216" "RFCD321299" [154] "RFCD380103" "RFCD430101" "SEO670401" [157] "SEO670403" "SEO671401" "SEO700103" [160] "SEO730101" "SEO730102" "SEO730104" [163] "SEO730105" "SEO730106" "SEO730107" [166] "SEO730108" "SEO730109" "SEO730110" [169] "SEO730111" "SEO730113" "SEO730114" [172] "SEO730115" "SEO730116" "SEO730118" [175] "SEO730199" "SEO730201" "SEO730202" [178] "SEO730203" "SEO730204" "SEO730206" [181] "SEO730211" "SEO730213" "SEO730214" [184] "SEO730218" "SEO730219" "SEO730299" [187] "SEO730303" "SEO730305" "SEO730306" [190] "SEO740201" "SEO740301" "SEO750901" [193] "SEO750902" "SEO770101" "SEO770703" [196] "SEO780101" "SEO780102" "SEO780103" [199] "SEO780105" "SEO780108" "Apr" [202] "Aug" "Dec" "Feb" [205] "Jan" "Jul" "Jun" [208] "May" "Nov" "Oct" [211] "Sep" "Fri" "Mon" [214] "Sat" "Thurs" "Tues" [217] "Wed" "Day" "SponsorCode" [220] "ContractValueBand" "Month" "Weekday"

vkjuju commented 7 years ago

any advice would be appreciated.

vkjuju commented 7 years ago

Hi, Max, our professor selected your book as our courseware, please take a look at this issue once you get a chance , Thanks... your book: Applied predictive modeling->Chap13->computing

We also found some syntax errors and solution on Chap10, we're glad to provide you our findings... please also check your email(mxkuhn@gmail.com) once available.. Regards, .jOe

topepo commented 7 years ago

There are no solutions to the chapter 13 exercises posted here. You will need to provide a lot more detail about what exactly you are doing, with what code, what versions of R and other packages, etc.

vkjuju commented 7 years ago

in this link: https://github.com/cran/AppliedPredictiveModeling/blob/master/inst/chapters/13_Non-Linear_Class.R from Line 357 to Line 367(error occured on Line 367):

Section 13.6 Naive Bayes

Create factor versions of some of the predictors so that they are treated as categories and not dummy variables

factors <- c("SponsorCode", "ContractValueBand", "Month", "Weekday") nbPredictors <- factorPredictors[factorPredictors %in% reducedSet] nbPredictors <- c(nbPredictors, factors)

The following code hit error message:

nbPredictors <- nbPredictors[nbPredictors != "SponsorUnk"] nbTraining <- training[, c("Class", nbPredictors)] Error in [.data.frame(training, , c("Class", nbPredictors)) : undefined columns selected

Required packages installed as follows: AppliedPredictiveModeling, caret, doMC , kernlab, klaR, lattice, latticeExtra, MASS, mda, nnet, pROC

R 3.4 on windows , Ubuntu, Mac, none of them worked

I have also sent your original files and csv to your gmail(mxkuhn@gmail.com), email subject: "Applied predictive modeling chap13 error" , all my classmates hit the same error, we could be flunked without your advice .

Steps to reproduce:

  1. Run CreateGrantData.R to generate grantData.RData
  2. Run 13_Non-Linear_Class.R and see if you can reproduce it on Line 367
  3. all associated files have been sent to your gmail

BTW: Have you got my email ? from: joeyangx@yahoo.com, Thanks

vkjuju commented 7 years ago

@topepo Here's our book: https://drive.google.com/file/d/0B3n0L-fAmNEXMlhKMWNKSXY0UEk/view?usp=sharing , any prompt update would be appreciated