Question 8.1
A
- The RF model has correctly identifed that v6-v10 isnt important
set.seed(200)
simulated <- mlbench.friedman1(200, sd = 1)
simulated <- cbind(simulated$x, simulated$y)
simulated <- as.data.frame(simulated)
colnames(simulated)[ncol(simulated)] <- "y"
model1 <- randomForest(y ~ ., data = simulated,importance = TRUE,ntree = 1000)
rfImp1 <- varImp(model1, scale = FALSE)
rfImp1
## Overall
## V1 8.732235404
## V2 6.415369387
## V3 0.763591825
## V4 7.615118809
## V5 2.023524577
## V6 0.165111172
## V7 -0.005961659
## V8 -0.166362581
## V9 -0.095292651
## V10 -0.074944788
B
- The duplicate vairablesclearly take away from the variable importance
- The model is randomly choosing the correlated predcictors some of the time over our original V1
simulated$duplicate1 <- simulated$V1 + rnorm(200) * .1
cor(simulated$duplicate1, simulated$V1)
## [1] 0.9460206
model1 <- randomForest(y ~ ., data = simulated,importance = TRUE,ntree = 1000)
rfImp1 <- varImp(model1, scale = FALSE)
rfImp1
## Overall
## V1 5.69119973
## V2 6.06896061
## V3 0.62970218
## V4 7.04752238
## V5 1.87238438
## V6 0.13569065
## V7 -0.01345645
## V8 -0.04370565
## V9 0.00840438
## V10 0.02894814
## duplicate1 4.28331581
simulated$duplicate2 <- simulated$V1 + rnorm(200) * .1
cor(simulated$duplicate1, simulated$V1)
## [1] 0.9460206
model1 <- randomForest(y ~ ., data = simulated,importance = TRUE,ntree = 1000)
rfImp1 <- varImp(model1, scale = FALSE)
rfImp1
## Overall
## V1 4.91687329
## V2 6.52816504
## V3 0.58711552
## V4 7.04870917
## V5 2.03115561
## V6 0.14213148
## V7 0.10991985
## V8 -0.08405687
## V9 -0.01075028
## V10 0.09230576
## duplicate1 3.80068234
## duplicate2 1.87721959
C
- All of the variable importance calls generally follow the same trend
# rfModel <- randomForest(y ~ ., data = simulated,importance = TRUE,ntrees = 1000, method = "cforest" )
# rfImp1 <- varImp(rfModel, scale = FALSE)
# rfImp1
#
# ?randomForest
# #method = "rf" or method = "cforest".
set.seed(200)
simulated <- mlbench.friedman1(200, sd = 1)
simulated <- cbind(simulated$x, simulated$y)
simulated <- as.data.frame(simulated)
colnames(simulated)[ncol(simulated)] <- "y"
model1 <- randomForest(y ~ ., data = simulated,importance = TRUE,ntree = 1000)
rfImp1 <- varImp(model1, scale = FALSE)
rfImp1
## Overall
## V1 8.732235404
## V2 6.415369387
## V3 0.763591825
## V4 7.615118809
## V5 2.023524577
## V6 0.165111172
## V7 -0.005961659
## V8 -0.166362581
## V9 -0.095292651
## V10 -0.074944788
baggedTree <- party::cforest(y ~ ., data = simulated)
non_conditional<- party::varimp(baggedTree,conditional = FALSE)
condtitional <- party::varimp(baggedTree,conditional = TRUE)
cbind(rfImp1,non_conditional,condtitional)
## Overall non_conditional condtitional
## V1 8.732235404 8.7468487424 5.361033209
## V2 6.415369387 6.6111386740 4.921941000
## V3 0.763591825 0.0251324481 0.020360250
## V4 7.615118809 8.3216311809 6.385159554
## V5 2.023524577 2.0053334352 1.326730935
## V6 0.165111172 0.0001915275 0.006724338
## V7 -0.005961659 -0.0017520711 -0.032085548
## V8 -0.166362581 -0.0178123815 -0.003736865
## V9 -0.095292651 -0.0290695242 -0.014184225
## V10 -0.074944788 -0.0454872070 -0.029568133
plot(condtitional)

D
gbmModel <- gbm(y ~ ., data = simulated, distribution = "gaussian")
summary(gbmModel)

## var rel.inf
## V4 V4 31.5263562
## V1 V1 25.6582158
## V2 V2 22.6288332
## V5 V5 12.3172094
## V3 V3 7.6762241
## V9 V9 0.1931612
## V6 V6 0.0000000
## V7 V7 0.0000000
## V8 V8 0.0000000
## V10 V10 0.0000000
# gbmModel <- gbm(y ~ ., data = simulated, distribution = "gaussian",method= 'permutation.test.gbm')
# summary(gbmModel)
simulated[,1:10]
## V1 V2 V3 V4 V5
## 1 0.533772448 0.6478064333 0.850785258 0.181599574 0.929039760
## 2 0.583765033 0.4381527551 0.672726594 0.669249143 0.163797838
## 3 0.589578298 0.5879064940 0.409671080 0.338127280 0.894093335
## 4 0.691039888 0.2259547510 0.033354474 0.066912736 0.637445191
## 5 0.667331498 0.8188985116 0.716760786 0.803242873 0.083068641
## 6 0.839293735 0.3862983445 0.646188573 0.861054306 0.630389472
## 7 0.711600085 0.1162793254 0.767706224 0.859962373 0.520582290
## 8 0.096501224 0.8445782231 0.153528016 0.412814007 0.746725963
## 9 0.523824728 0.2514584265 0.285196133 0.452202451 0.506808798
## 10 0.235350536 0.4317718598 0.780373945 0.072122673 0.100005680
## 11 0.454364888 0.1192040211 0.220170008 0.351687343 0.001755818
## 12 0.649252912 0.0973321993 0.598340076 0.734892188 0.669684836
## 13 0.153727122 0.0128550101 0.608990930 0.633952646 0.094662402
## 14 0.649288674 0.1866738056 0.365308329 0.045665963 0.806304601
## 15 0.383213673 0.4608722613 0.345225364 0.735293760 0.217474412
## 16 0.307298063 0.4219112301 0.979319583 0.144514926 0.489620249
## 17 0.566767377 0.7811157859 0.890115921 0.995679246 0.413354418
## 18 0.131787853 0.1998720246 0.379945722 0.570354241 0.932332295
## 19 0.922177571 0.4675492314 0.010254486 0.008189635 0.789955666
## 20 0.646329618 0.7929329765 0.053864328 0.652274119 0.226417012
## 21 0.460360692 0.0697931792 0.784207606 0.686981049 0.379707196
## 22 0.098747006 0.2313314399 0.520667098 0.298788559 0.058919030
## 23 0.206593813 0.6473270494 0.606014522 0.086910314 0.536598262
## 24 0.922339834 0.6342856146 0.888005181 0.503549783 0.504815002
## 25 0.319426806 0.0545100805 0.381021996 0.999287510 0.982473919
## 26 0.265324291 0.8564205186 0.050943109 0.395974373 0.937435226
## 27 0.717369557 0.2948283439 0.736812766 0.919277884 0.128039610
## 28 0.380335360 0.0004408562 0.733275530 0.345613460 0.443263867
## 29 0.030620939 0.2731315538 0.903001443 0.758067884 0.147233479
## 30 0.521419376 0.3537345366 0.830735998 0.393664814 0.671653698
## 31 0.263748623 0.5057117699 0.140882633 0.678475745 0.562049805
## 32 0.166053713 0.2998292497 0.377729565 0.270103104 0.711894969
## 33 0.483074695 0.5088484667 0.636458001 0.654003645 0.616297887
## 34 0.325727710 0.9247118952 0.817825248 0.371338245 0.382548874
## 35 0.925363897 0.2371832319 0.010075368 0.345586454 0.547638883
## 36 0.560558849 0.4270182950 0.313384585 0.610149687 0.802779849
## 37 0.178553036 0.4352612651 0.153328084 0.549069691 0.356350074
## 38 0.972322052 0.6359792664 0.445975145 0.899534479 0.268725364
## 39 0.493773325 0.3447996511 0.445896353 0.449058379 0.003265168
## 40 0.485940594 0.8554888491 0.813352563 0.045685444 0.880070203
## 41 0.586856649 0.2803302526 0.037726685 0.018251117 0.150030803
## 42 0.720570024 0.9092058453 0.210796098 0.875075159 0.094086062
## 43 0.691673029 0.5930176671 0.420771204 0.247303587 0.983297946
## 44 0.176150461 0.7141316915 0.741954805 0.197583070 0.836461429
## 45 0.952475880 0.8493538222 0.317191089 0.925082660 0.607305124
## 46 0.689011891 0.7483011317 0.807849665 0.877950979 0.967313918
## 47 0.157799606 0.6691785671 0.353649540 0.368825636 0.377917988
## 48 0.576220999 0.8380715831 0.609410121 0.191988432 0.172759505
## 49 0.653276739 0.9181834545 0.893769723 0.622584245 0.327600596
## 50 0.832807913 0.2265766494 0.355865418 0.047708418 0.547652281
## 51 0.067187183 0.1867572814 0.053412318 0.788249273 0.069746084
## 52 0.118626094 0.4984532818 0.081841033 0.847314714 0.095897603
## 53 0.892374709 0.9191673915 0.179852584 0.484247719 0.850093837
## 54 0.557935121 0.9555177600 0.070927210 0.284588894 0.860588939
## 55 0.515005544 0.6027795288 0.491738453 0.258037420 0.287011503
## 56 0.134100055 0.7252116359 0.862601955 0.610891974 0.280598821
## 57 0.149258960 0.1695368735 0.566346588 0.563854012 0.273068628
## 58 0.161343819 0.2199983387 0.222847626 0.136463749 0.596218371
## 59 0.561064044 0.7804879546 0.169082082 0.368560432 0.294977250
## 60 0.671786989 0.5629266184 0.306758978 0.797413421 0.402194366
## 61 0.147402651 0.9183623586 0.999923422 0.435399952 0.960000194
## 62 0.570647350 0.8898196355 0.359521539 0.807744707 0.942994522
## 63 0.758280237 0.4162223253 0.651333184 0.088788726 0.318467662
## 64 0.565787035 0.2931080312 0.935225714 0.254972817 0.682191425
## 65 0.775718143 0.2964265901 0.815802228 0.778016577 0.345414489
## 66 0.677378375 0.2773598756 0.627044755 0.937812351 0.439045849
## 67 0.218266052 0.7430458625 0.370964498 0.678309920 0.850654966
## 68 0.281448058 0.2555278649 0.540702318 0.102928993 0.499993075
## 69 0.094555768 0.6770530874 0.857065403 0.147499445 0.190941744
## 70 0.593106887 0.6049814720 0.829584161 0.068155296 0.812524924
## 71 0.355217626 0.9024892272 0.162602290 0.167165469 0.786120466
## 72 0.153351908 0.5403167598 0.522081524 0.131646728 0.303439272
## 73 0.466252540 0.2189726466 0.649081210 0.876677948 0.373312224
## 74 0.275116619 0.5810471375 0.328282601 0.821013230 0.365157783
## 75 0.397941506 0.0506482811 0.736786507 0.069037383 0.465576746
## 76 0.311401952 0.8876241017 0.829994129 0.273672034 0.822258464
## 77 0.586229856 0.6614987573 0.510906287 0.863162806 0.946865431
## 78 0.150715668 0.0240218288 0.293724078 0.763388061 0.337483510
## 79 0.644267766 0.5393897707 0.438592263 0.678769260 0.816074158
## 80 0.006409079 0.3240858268 0.081627410 0.388581997 0.143550989
## 81 0.816851889 0.8537856233 0.217289788 0.442311989 0.143528348
## 82 0.742108528 0.2384303520 0.580422256 0.720915187 0.629143175
## 83 0.654247520 0.5939083034 0.994853858 0.936799756 0.912532976
## 84 0.440734623 0.8666409499 0.564446902 0.379492091 0.822953047
## 85 0.442322013 0.2467340643 0.826851101 0.198192747 0.346601916
## 86 0.786464168 0.9204477360 0.150473845 0.543170314 0.512502319
## 87 0.459340288 0.2267787226 0.645397100 0.169832431 0.382568107
## 88 0.984272037 0.7370369236 0.306019300 0.648133427 0.114868225
## 89 0.371441818 0.1517067349 0.995130365 0.887727774 0.512004345
## 90 0.997792503 0.6529070695 0.098833617 0.917166736 0.471261014
## 91 0.474391870 0.6010630331 0.278657043 0.790569007 0.927579608
## 92 0.220132116 0.6547463359 0.537419467 0.345841283 0.043483641
## 93 0.031105185 0.6107613579 0.025156959 0.909916925 0.158163789
## 94 0.229582377 0.6054298035 0.639548430 0.572823923 0.743228543
## 95 0.609273809 0.9123187338 0.725720419 0.461442270 0.011241655
## 96 0.370745452 0.0759057687 0.361935701 0.433070669 0.090679155
## 97 0.307162299 0.6478466513 0.830584273 0.446856117 0.350730690
## 98 0.157705784 0.3871437064 0.703486373 0.566900127 0.685163247
## 99 0.448205397 0.8644333375 0.422698680 0.633362517 0.233479040
## 100 0.683045527 0.9840194189 0.611699514 0.531140843 0.797903161
## 101 0.686627647 0.6046307203 0.167846072 0.456818942 0.607740600
## 102 0.831901784 0.2939653466 0.672954567 0.803079295 0.280210467
## 103 0.113058501 0.2546948988 0.218817725 0.057622184 0.279840802
## 104 0.556645789 0.8126982844 0.692510723 0.966434979 0.351036289
## 105 0.192172982 0.3423131080 0.496556215 0.413942024 0.088539597
## 106 0.048556563 0.9640056610 0.605707243 0.566484744 0.508386431
## 107 0.636388587 0.4812663090 0.156460918 0.863360892 0.745412975
## 108 0.002806243 0.9363095718 0.649450997 0.242205442 0.870268838
## 109 0.501964895 0.7322653499 0.968477561 0.455123628 0.558531469
## 110 0.479473393 0.8101365152 0.371763220 0.896207781 0.851932624
## 111 0.904642434 0.7766639574 0.927888780 0.170289954 0.499319865
## 112 0.076446557 0.3885678530 0.869672049 0.631985184 0.508797599
## 113 0.171706995 0.6642553948 0.447441930 0.109595960 0.687226565
## 114 0.598192136 0.8803027971 0.934215342 0.184075910 0.930016244
## 115 0.494660591 0.5270667071 0.165982118 0.279556816 0.548412474
## 116 0.822326746 0.0874312406 0.339381942 0.624753956 0.139959793
## 117 0.884809928 0.2049752097 0.351055704 0.772163214 0.897429584
## 118 0.195553894 0.1479548330 0.547592697 0.426198894 0.233539708
## 119 0.463013117 0.4677024283 0.079132932 0.123636657 0.209901525
## 120 0.007715050 0.9759014850 0.647108061 0.623121100 0.489483954
## 121 0.623211886 0.7964882990 0.725319422 0.268862381 0.873370248
## 122 0.632887607 0.6062786465 0.027653304 0.215499579 0.437937672
## 123 0.313287797 0.6479254356 0.003295714 0.679255102 0.590496615
## 124 0.775744612 0.1102327388 0.168523920 0.228762099 0.965724084
## 125 0.998992379 0.8608238841 0.913439707 0.130730744 0.663723183
## 126 0.751483215 0.3711484901 0.757779663 0.436154100 0.914117961
## 127 0.512864344 0.4433466932 0.777240771 0.131851328 0.666940580
## 128 0.594934646 0.6147596298 0.629629193 0.029415055 0.156732836
## 129 0.108193488 0.0456732074 0.553760919 0.836029727 0.991577258
## 130 0.213286245 0.6094768783 0.343689348 0.090614796 0.383258829
## 131 0.511472948 0.8676087293 0.542017557 0.964182970 0.315437378
## 132 0.653088958 0.0627070705 0.925106390 0.035819308 0.250788742
## 133 0.680070220 0.4819761757 0.543910673 0.283038010 0.721935218
## 134 0.594429644 0.9517888685 0.487364555 0.429615057 0.077726093
## 135 0.566119617 0.7702909564 0.283901030 0.481008470 0.085473549
## 136 0.292137912 0.4600951856 0.031411853 0.355790904 0.714166709
## 137 0.621721983 0.8975026356 0.486688155 0.237542561 0.754609415
## 138 0.734009909 0.7064418797 0.685221680 0.159361927 0.678954404
## 139 0.250146729 0.2166299177 0.828084011 0.759835896 0.783513594
## 140 0.725502808 0.3214482346 0.801824650 0.683726188 0.785781410
## 141 0.518633971 0.1892801912 0.636985009 0.216002044 0.823852410
## 142 0.353793057 0.1187343048 0.771915119 0.228639466 0.026823693
## 143 0.536732926 0.5057627214 0.544558276 0.408174795 0.220592264
## 144 0.827716813 0.1134541789 0.151092910 0.249067954 0.167421041
## 145 0.799086446 0.2226722005 0.314966519 0.644402519 0.296044190
## 146 0.121202702 0.5125092892 0.736546513 0.173788953 0.987242828
## 147 0.965792880 0.2959974960 0.281766439 0.181185599 0.460291081
## 148 0.655097562 0.9138811582 0.685150367 0.203402501 0.556077081
## 149 0.523663767 0.3619226965 0.790130149 0.296799039 0.181327148
## 150 0.406266008 0.1738398047 0.437415589 0.528837076 0.650578036
## 151 0.811131607 0.4745276461 0.736739275 0.090695082 0.734380059
## 152 0.195899217 0.1883440749 0.036628024 0.037811573 0.361777857
## 153 0.901721909 0.7641276480 0.975725230 0.649152147 0.125422492
## 154 0.419387562 0.7132732121 0.537194521 0.663290517 0.813946252
## 155 0.502626143 0.1582271636 0.926717208 0.752402752 0.534871275
## 156 0.505678876 0.5922643617 0.249804128 0.229866606 0.489065639
## 157 0.914411720 0.3216436969 0.149495436 0.232416035 0.057981907
## 158 0.148558215 0.5582501232 0.832446445 0.294442032 0.117299439
## 159 0.937065663 0.7175001081 0.341711296 0.826616130 0.589513207
## 160 0.975472900 0.4723303919 0.144815880 0.495536016 0.437703832
## 161 0.424515043 0.6310416884 0.783094346 0.510714823 0.314462922
## 162 0.812289485 0.6547854072 0.352954853 0.395277522 0.834191832
## 163 0.029440868 0.7336349678 0.287532780 0.481363036 0.646652654
## 164 0.917813970 0.6703584662 0.014808858 0.308127946 0.908841855
## 165 0.214090701 0.3539453736 0.441450395 0.704947843 0.190465599
## 166 0.553994835 0.3797423861 0.426848450 0.406387825 0.583469785
## 167 0.087216421 0.0444812854 0.887981009 0.334847389 0.958314174
## 168 0.051853288 0.5381637057 0.287162258 0.544222318 0.580674538
## 169 0.153477015 0.7609185344 0.588195231 0.726811070 0.869440276
## 170 0.585922012 0.6343205774 0.114031907 0.054257943 0.132969180
## 171 0.915327054 0.6440016078 0.582549772 0.953309200 0.661264660
## 172 0.021536301 0.3673074185 0.137482502 0.985332304 0.359814066
## 173 0.175545276 0.5064939184 0.364339191 0.650103795 0.942291794
## 174 0.083142271 0.1788396279 0.373116091 0.705161238 0.367621270
## 175 0.491874318 0.4900236735 0.297881532 0.331352153 0.870221517
## 176 0.665890210 0.6166888489 0.978142474 0.226049843 0.988691468
## 177 0.028172681 0.3769877132 0.719316378 0.022271170 0.711718217
## 178 0.879781784 0.7322189799 0.869278736 0.649725121 0.669133191
## 179 0.795590631 0.2757800566 0.781217543 0.406130929 0.115849692
## 180 0.066798607 0.4353600563 0.641473262 0.070881601 0.725632793
## 181 0.369471576 0.2884542705 0.375342084 0.381129961 0.752541286
## 182 0.111091629 0.5124843172 0.743466425 0.401846189 0.632692037
## 183 0.825969449 0.7803220809 0.425994063 0.961734195 0.726619251
## 184 0.612556007 0.9145965697 0.257388497 0.629601910 0.375935599
## 185 0.637976925 0.1076111828 0.280669488 0.654566472 0.932735895
## 186 0.722749287 0.4142492083 0.976476628 0.461700869 0.261488323
## 187 0.088224613 0.3651040641 0.112417366 0.427385604 0.630677684
## 188 0.206456413 0.6789903478 0.269728941 0.026255392 0.533788505
## 189 0.271994818 0.4532893968 0.732908373 0.710368193 0.555094344
## 190 0.520548412 0.3144283574 0.803517855 0.349941988 0.498034912
## 191 0.776805477 0.9616133086 0.754222457 0.091987771 0.551281321
## 192 0.289232634 0.8427688032 0.202012851 0.496472600 0.546778636
## 193 0.989449516 0.2357514210 0.704040867 0.447436986 0.046436282
## 194 0.310988950 0.4760307493 0.771920531 0.274742047 0.416478656
## 195 0.581546503 0.0395606223 0.147069360 0.853941998 0.729293162
## 196 0.701018440 0.7045858139 0.531901518 0.318705286 0.510770075
## 197 0.539472235 0.1585750368 0.654213027 0.492335809 0.606566809
## 198 0.011292625 0.9602364919 0.776298914 0.773416284 0.594650894
## 199 0.603909890 0.9586990301 0.875057548 0.093729714 0.825522528
## 200 0.089178660 0.6006974212 0.113622466 0.825916705 0.558199830
## V6 V7 V8 V9 V10
## 1 0.361790597 0.8266608594 0.421408064 0.59111440 0.588621560
## 2 0.453059313 0.6489600763 0.844623926 0.92819306 0.758400814
## 3 0.026819108 0.1785614495 0.349590781 0.01759542 0.444118458
## 4 0.525006367 0.5133613953 0.797025980 0.68986918 0.445071622
## 5 0.223441572 0.6644906041 0.903891937 0.39696995 0.550080800
## 6 0.437038906 0.3360117343 0.648917723 0.53116033 0.906618237
## 7 0.990291612 0.0084998407 0.072795420 0.97395768 0.440172910
## 8 0.662056439 0.4722572784 0.381633542 0.75877525 0.710887919
## 9 0.019370317 0.3058403293 0.525661726 0.43136410 0.400128186
## 10 0.294671116 0.3228343336 0.960311741 0.92426620 0.832559698
## 11 0.149134940 0.1315679180 0.939230266 0.46228702 0.775593376
## 12 0.668878612 0.7618696443 0.550847133 0.08637756 0.524860506
## 13 0.616397752 0.4806034924 0.485595847 0.54158360 0.081258474
## 14 0.476613421 0.4200604216 0.282479481 0.62596273 0.003172379
## 15 0.350192171 0.6595693664 0.469818084 0.03909819 0.706367689
## 16 0.516859321 0.6941591527 0.917750880 0.33898498 0.689810129
## 17 0.379292418 0.1693497750 0.290054937 0.69159996 0.120331543
## 18 0.175180161 0.1774999567 0.724190771 0.14320681 0.075203559
## 19 0.846729845 0.6109301876 0.182253540 0.20626788 0.247241936
## 20 0.510733424 0.1655056404 0.996789995 0.57239957 0.970613467
## 21 0.434224161 0.8696455043 0.480284780 0.94174627 0.525216599
## 22 0.321473247 0.2200369346 0.543487359 0.91963756 0.948926731
## 23 0.592455531 0.6324701225 0.833171203 0.91811502 0.181142754
## 24 0.519335387 0.6703429641 0.285668603 0.84918471 0.397776954
## 25 0.515890769 0.0101521015 0.960430558 0.23506862 0.230721395
## 26 0.983467527 0.2522400960 0.634320574 0.87522970 0.635452710
## 27 0.414260471 0.6650384206 0.650785477 0.28744271 0.616526859
## 28 0.558792540 0.0648198922 0.178094681 0.56876498 0.428627433
## 29 0.146207562 0.6192647608 0.146737191 0.33908035 0.938806834
## 30 0.573219036 0.3292513283 0.042337252 0.86859891 0.880950373
## 31 0.812396222 0.2824812313 0.332542812 0.95191869 0.763801782
## 32 0.103405041 0.2051616914 0.785139066 0.04968553 0.968671421
## 33 0.399691042 0.6479521065 0.175871460 0.67905283 0.730759681
## 34 0.441881776 0.3500645757 0.635448656 0.89620270 0.575594178
## 35 0.201830557 0.8686830916 0.324884567 0.03161212 0.849832683
## 36 0.815573796 0.6281718945 0.651751797 0.69222388 0.442386812
## 37 0.094069178 0.5401211150 0.802915463 0.51344968 0.959669129
## 38 0.903799011 0.0954262505 0.271751555 0.91415621 0.535858047
## 39 0.759522119 0.3189930974 0.487114596 0.38007261 0.068724414
## 40 0.513183234 0.0987321541 0.398785473 0.70468780 0.814099950
## 41 0.053033940 0.8256829928 0.274217872 0.24911536 0.363809015
## 42 0.585604633 0.4254488801 0.543745558 0.56771488 0.586587886
## 43 0.427623936 0.6002272039 0.303179812 0.30442762 0.996330470
## 44 0.296208750 0.0993871398 0.726330749 0.51122937 0.574089565
## 45 0.803849567 0.3573383761 0.659334866 0.82108557 0.880166529
## 46 0.574638351 0.3369224169 0.171208087 0.58813299 0.298467441
## 47 0.298162997 0.7216083466 0.347465995 0.45980972 0.522110901
## 48 0.113711787 0.1637666794 0.465182498 0.67228512 0.549377529
## 49 0.832185488 0.0661412831 0.662970975 0.67190601 0.712600555
## 50 0.939744496 0.5044657106 0.684693513 0.23367805 0.853776497
## 51 0.175875548 0.4450478635 0.954027392 0.87891811 0.228369326
## 52 0.953105583 0.8620285194 0.258589442 0.96154879 0.437253388
## 53 0.771444682 0.0236228870 0.676012672 0.37005100 0.260396947
## 54 0.018207328 0.1452215833 0.955375290 0.70495617 0.882332698
## 55 0.054381748 0.3742820916 0.214503606 0.13091783 0.462896239
## 56 0.785266264 0.5384509673 0.037968947 0.61604382 0.535041264
## 57 0.328188200 0.2577628391 0.186539843 0.93924713 0.942935549
## 58 0.105031757 0.2109247684 0.363152975 0.22155711 0.789319306
## 59 0.618674891 0.4573113865 0.197379992 0.41096121 0.626259638
## 60 0.169488368 0.2189239766 0.259368576 0.39850931 0.322176775
## 61 0.746313307 0.9801436167 0.418736819 0.50638210 0.791115409
## 62 0.850621036 0.2792056827 0.632583834 0.92330341 0.663045999
## 63 0.789343349 0.6202754262 0.088279070 0.26778657 0.207211251
## 64 0.116470202 0.6345477444 0.994484988 0.67288102 0.949158964
## 65 0.608970067 0.1516102208 0.669617534 0.12557122 0.392013110
## 66 0.796132486 0.0638373715 0.153521036 0.22166633 0.123506922
## 67 0.108555941 0.3630222164 0.350279308 0.14200169 0.041529058
## 68 0.200114859 0.0141349288 0.663475810 0.67553172 0.501539484
## 69 0.593200353 0.5267603784 0.429941210 0.97828898 0.885561631
## 70 0.272600746 0.6532241760 0.671208466 0.65576477 0.673768810
## 71 0.253500610 0.2219880908 0.476079757 0.71183447 0.425648322
## 72 0.406195677 0.1531321660 0.691954747 0.65801907 0.426056444
## 73 0.500154867 0.5008657877 0.040073613 0.92800985 0.381413696
## 74 0.574757167 0.9806543912 0.819187354 0.84159996 0.896280786
## 75 0.526418373 0.9244000583 0.198013207 0.23337787 0.116631588
## 76 0.576108309 0.0099979453 0.295807930 0.90356056 0.885416760
## 77 0.895700728 0.2356902743 0.506900013 0.55981430 0.534760828
## 78 0.572278405 0.3650656492 0.810620838 0.11388461 0.410755347
## 79 0.739229684 0.7987873172 0.366785977 0.60186782 0.973480208
## 80 0.586718400 0.5599248759 0.116578872 0.34580507 0.714962742
## 81 0.926974642 0.7522757188 0.026414874 0.34715430 0.836363711
## 82 0.597393914 0.8865377689 0.061911004 0.97803556 0.612240904
## 83 0.215555561 0.0590573207 0.684142034 0.71260502 0.255351776
## 84 0.368613384 0.7768231640 0.850076108 0.17097505 0.408350330
## 85 0.981209712 0.4138241454 0.755554634 0.92548457 0.945293089
## 86 0.773290500 0.9818397635 0.945009324 0.68008657 0.510965007
## 87 0.076924091 0.2916908523 0.702514261 0.85496045 0.604653787
## 88 0.384680568 0.1587244619 0.582193831 0.05235641 0.486561552
## 89 0.986306011 0.0014450864 0.128084549 0.47699398 0.679715703
## 90 0.157362159 0.2105985023 0.884157248 0.18779775 0.402003791
## 91 0.305082921 0.8245949268 0.793933963 0.53137582 0.756866812
## 92 0.429867428 0.0445211111 0.460617797 0.58243842 0.944980194
## 93 0.016845753 0.5918905353 0.485206415 0.77555244 0.542896184
## 94 0.887359502 0.0303562423 0.324637733 0.98245833 0.605254818
## 95 0.763862459 0.6099704383 0.731502909 0.49410755 0.882788646
## 96 0.101371452 0.0619420919 0.788262721 0.32567336 0.790985481
## 97 0.442842154 0.6019777379 0.718690965 0.24367231 0.571871065
## 98 0.440206385 0.7470110336 0.789140293 0.18306352 0.852484180
## 99 0.103215690 0.5261754794 0.983355801 0.37887188 0.765290411
## 100 0.597651707 0.4876051969 0.122928050 0.08177731 0.848134163
## 101 0.314174908 0.9011508890 0.617960313 0.12460480 0.702702949
## 102 0.998987383 0.0003387642 0.388927228 0.97821702 0.104494945
## 103 0.239368085 0.9080805883 0.905519754 0.60285307 0.877587634
## 104 0.281969752 0.4965877566 0.636728981 0.79705572 0.319453278
## 105 0.727522285 0.8487957353 0.912640729 0.11477043 0.155581983
## 106 0.614031048 0.0822484379 0.955071241 0.06021731 0.421584291
## 107 0.765995033 0.1611803344 0.599529999 0.26890232 0.188167820
## 108 0.335062859 0.1425062015 0.571244097 0.74935739 0.464775090
## 109 0.644129353 0.4653496440 0.651546226 0.95540449 0.564070737
## 110 0.277587108 0.1981665948 0.999560626 0.57950670 0.127039001
## 111 0.493327187 0.8408644302 0.437424371 0.93131402 0.133683814
## 112 0.512153390 0.9164640335 0.395302785 0.63386223 0.888060797
## 113 0.990115111 0.3355441941 0.030395976 0.20250656 0.053323140
## 114 0.015515274 0.6774176396 0.696283764 0.75913311 0.809930917
## 115 0.006808892 0.9650529190 0.449902425 0.57304399 0.753339031
## 116 0.881927748 0.1141603340 0.863953833 0.95345440 0.380650506
## 117 0.373503622 0.4158274462 0.713239111 0.60102539 0.635894833
## 118 0.459527157 0.1791522284 0.834004079 0.20838605 0.592570851
## 119 0.249119067 0.5624954123 0.710008362 0.18311621 0.394101708
## 120 0.913406589 0.9726133470 0.842078145 0.93576851 0.956083941
## 121 0.629094972 0.4887156698 0.887054311 0.31041901 0.510736341
## 122 0.412266847 0.9838132532 0.585472636 0.14732752 0.086574405
## 123 0.988463188 0.4743697466 0.242674318 0.42347788 0.868947359
## 124 0.842011251 0.2407878560 0.447328788 0.66467369 0.494879879
## 125 0.934387672 0.1783671109 0.503948929 0.16230501 0.187285239
## 126 0.487309208 0.4367017439 0.344732890 0.42201320 0.437095925
## 127 0.893005643 0.3784207169 0.273177421 0.11701698 0.547305345
## 128 0.675986912 0.1147928145 0.103627008 0.16504249 0.275940885
## 129 0.029231649 0.3586573373 0.238100665 0.68896641 0.177130092
## 130 0.830723291 0.2376520939 0.312197204 0.25109129 0.997579731
## 131 0.805567415 0.7941833863 0.433608739 0.76234330 0.569325565
## 132 0.872808259 0.5684747580 0.312200866 0.11102144 0.240327878
## 133 0.261010709 0.9834440248 0.023838794 0.16816803 0.999992477
## 134 0.396774478 0.8681481183 0.755061130 0.16099688 0.581953628
## 135 0.392161391 0.2529283839 0.309956316 0.35376172 0.576154274
## 136 0.646736944 0.2954634046 0.686869082 0.23401367 0.743752910
## 137 0.993754126 0.7287589125 0.934555566 0.27740693 0.256602708
## 138 0.522533498 0.5105628674 0.330980633 0.32516244 0.474497675
## 139 0.528184886 0.4536720926 0.385358283 0.03655417 0.171900066
## 140 0.368117954 0.0308236629 0.654293299 0.92551144 0.435859671
## 141 0.130777703 0.3351621642 0.409007091 0.67315717 0.996981804
## 142 0.470881379 0.6144252147 0.651714271 0.12889572 0.633149029
## 143 0.716128180 0.1153656312 0.793603583 0.55421117 0.356097830
## 144 0.812992523 0.7361220436 0.177242560 0.03421274 0.872309444
## 145 0.010295009 0.9072946333 0.738731097 0.26822183 0.173052300
## 146 0.128936096 0.8854910310 0.688096952 0.75856509 0.669689639
## 147 0.428525911 0.0388078641 0.214172413 0.61253457 0.207942491
## 148 0.384476536 0.3260785770 0.810973278 0.39199971 0.370241001
## 149 0.809934170 0.7807700243 0.578197747 0.70276752 0.123103430
## 150 0.017366972 0.7907638911 0.208587777 0.05438854 0.766739978
## 151 0.640642888 0.7937673274 0.208766474 0.83636350 0.858343330
## 152 0.891157788 0.1613148297 0.654811297 0.66729678 0.115404263
## 153 0.843844815 0.7080952730 0.903838935 0.31193910 0.969527644
## 154 0.346468189 0.5305830529 0.004698141 0.48546810 0.259277162
## 155 0.519248105 0.1885056335 0.079913177 0.57972754 0.905628399
## 156 0.002901212 0.5161641990 0.466810009 0.76300679 0.944087471
## 157 0.278796293 0.6012678132 0.025244068 0.19821959 0.402928842
## 158 0.885807658 0.6169876396 0.499346328 0.32760646 0.266050707
## 159 0.927866664 0.7895973460 0.786763847 0.07832531 0.312945329
## 160 0.338820112 0.0390002122 0.015907055 0.57958929 0.502512869
## 161 0.086185409 0.4199729285 0.538111618 0.94932648 0.535985540
## 162 0.642550439 0.5129533098 0.613649708 0.26589918 0.269859831
## 163 0.586816839 0.6883663596 0.515120720 0.64359538 0.473454136
## 164 0.511950091 0.2867906420 0.219839853 0.16326702 0.120969625
## 165 0.788839862 0.9943477523 0.381418612 0.81146453 0.136825552
## 166 0.982102466 0.2593658050 0.461603611 0.68922230 0.171518739
## 167 0.631051316 0.5809806921 0.810821845 0.21677497 0.741042868
## 168 0.138133082 0.9927047875 0.928290160 0.48741662 0.881588204
## 169 0.140277030 0.3948761285 0.914971805 0.04233756 0.987049844
## 170 0.262855512 0.9569103546 0.694013482 0.97705820 0.012435718
## 171 0.182328664 0.5889326367 0.509478116 0.64141950 0.365601074
## 172 0.504694133 0.6114409810 0.830605455 0.52658278 0.065911923
## 173 0.238556437 0.4287582068 0.366665906 0.86474573 0.016379327
## 174 0.640988169 0.1562757776 0.463090256 0.02956841 0.971855537
## 175 0.530976141 0.0453625068 0.177558171 0.10203368 0.505838658
## 176 0.411653516 0.6969831374 0.631295626 0.58758911 0.247838673
## 177 0.537131623 0.1762444021 0.080035930 0.84510174 0.700015211
## 178 0.397410648 0.2357786680 0.385391619 0.62558152 0.954732809
## 179 0.363247100 0.5439273247 0.627847850 0.88854501 0.855865543
## 180 0.845899404 0.8102693288 0.839098028 0.15944836 0.379626432
## 181 0.080834012 0.0133081947 0.168556706 0.10525675 0.771278932
## 182 0.334856320 0.6584848959 0.287486323 0.12728033 0.041241815
## 183 0.637834937 0.3847984066 0.117578465 0.96804658 0.902288517
## 184 0.271460483 0.1876184577 0.798065790 0.92881170 0.884292413
## 185 0.974294363 0.0729941991 0.472175947 0.07752809 0.744791487
## 186 0.760588499 0.7420141906 0.437308198 0.66531113 0.045803222
## 187 0.064398194 0.4334616780 0.849088030 0.46642330 0.779457425
## 188 0.339906024 0.6745903494 0.986013835 0.50686606 0.312909630
## 189 0.429670967 0.3680351812 0.496575716 0.49428027 0.447099152
## 190 0.495041399 0.6922219021 0.011549961 0.57885152 0.406213945
## 191 0.733340201 0.0971158685 0.412869229 0.97960020 0.136601998
## 192 0.428116115 0.1838154087 0.210182422 0.04580357 0.427214286
## 193 0.493715242 0.5494235111 0.720276414 0.29912111 0.994646956
## 194 0.183150188 0.7455740881 0.886575559 0.25383887 0.521175744
## 195 0.166967576 0.8809142739 0.322509774 0.66346270 0.930126207
## 196 0.799619116 0.6664053195 0.267326644 0.24159338 0.606167757
## 197 0.903776626 0.8829731958 0.123415505 0.99102161 0.073506513
## 198 0.984942808 0.2567906741 0.309302658 0.05267484 0.698478227
## 199 0.624501048 0.5021552520 0.334554489 0.03080467 0.395422508
## 200 0.084706127 0.6627391470 0.959779277 0.09184009 0.219858172
gbmGrid <- expand.grid(interaction.depth = seq(1, 7, by = 2),
n.trees= seq(100, 1000, by = 50),
shrinkage = c(0.01, 0.1),n.minobsinnode=5 )
set.seed(100)
gbmTune <- train(simulated[,1:10], simulated$y,method = "gbm", tuneGrid = gbmGrid,verbose = FALSE)
#gbmTune$
varImp(gbmTune)
## gbm variable importance
##
## Overall
## V4 100.0000
## V1 92.1317
## V2 86.8359
## V5 37.4263
## V3 31.9971
## V6 2.7878
## V7 2.3789
## V8 0.7181
## V9 0.1236
## V10 0.0000
cubistTuned <- train(simulated[,1:10], simulated$y, method = "cubist", importance=TRUE)
varImp(cubistTuned)
## cubist variable importance
##
## Overall
## V1 100.00
## V2 75.69
## V4 68.06
## V3 58.33
## V5 55.56
## V6 15.28
## V9 0.00
## V8 0.00
## V10 0.00
## V7 0.00
8.2
set.seed(200)
simulated <- mlbench.friedman1(200, sd = 1)
simulated <- cbind(simulated$x, simulated$y)
simulated <- as.data.frame(simulated)
colnames(simulated)[ncol(simulated)] <- "y"
trctrl <- trainControl(method = "repeatedcv", number = 10, repeats = 3)
rpartTree <- rpart(y ~ ., data = simulated)
varImp(rpartTree)
## Overall
## V1 1.61675805
## V10 0.52544906
## V2 2.15453588
## V3 0.79147160
## V4 3.02099652
## V5 2.45400266
## V6 0.54723044
## V7 0.51139268
## V8 0.09454648
## V9 0.20541040
dtree_fit <- train(y ~., data = simulated, method = "rpart",
parms = list(split = "information"),
trControl=trctrl,
tuneLength = 10)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info =
## trainInfo, : There were missing values in resampled performance measures.
varImp(dtree_fit)
## rpart variable importance
##
## Overall
## V4 100.000
## V5 67.882
## V2 61.759
## V1 55.572
## V7 24.307
## V3 18.131
## V10 16.373
## V6 13.763
## V9 4.107
## V8 0.000
set.seed(624)
X1 <- rep(11:20, each=20)
Y <- X1 + rnorm(200, mean=0, sd=4)
set.seed(624)
X2 <- rnorm(200, mean=0, sd=2)
X2
## [1] 3.012047862 -4.604179906 -1.518828805 1.085872741 0.105922166
## [6] 0.484066032 2.792675037 -4.962769823 -3.085888266 -2.921138910
## [11] 0.505428991 -1.228477475 3.305283882 0.265996704 2.517764171
## [16] 1.224125064 0.195823980 -0.743892080 2.116293624 0.081271916
## [21] -1.198186108 -1.643274109 -1.654844951 -2.161345842 -3.983033137
## [26] -1.146009033 2.693049549 -0.020160160 -2.832923205 -4.735728190
## [31] -1.176736039 2.721981500 0.299271677 4.932335414 -0.118340059
## [36] 1.804251931 1.036926791 0.729935421 0.738551458 1.842357154
## [41] -0.459474212 0.058065883 0.858312721 -5.264584912 0.544187913
## [46] 2.221982135 -1.133598343 -3.734697261 2.597729670 0.693150793
## [51] -1.493499986 -2.013389755 1.654158651 0.827594173 -1.640962379
## [56] 0.291427438 -0.135591337 -1.491490077 -1.154878308 0.194432022
## [61] -1.986270703 -0.672161076 -1.956910944 -1.759251859 2.921373272
## [66] -0.139598393 0.339862239 -3.451317867 -0.840191599 1.192280282
## [71] 1.978750624 -2.748588328 -0.087813772 -2.334647544 1.427963515
## [76] 1.533471947 0.166487706 -0.313408076 -0.797960148 -3.773821881
## [81] 1.347792436 -0.519800476 -1.007603202 -0.444038393 -1.671918901
## [86] -0.780306452 -1.636934094 -2.721781081 -4.042883425 -2.413798696
## [91] -0.089426327 1.129298073 -1.699751523 0.120451114 -3.013284777
## [96] 1.538181763 -0.310928336 3.008825095 -1.279189499 -1.401860907
## [101] 2.473443508 -4.895724772 0.954819988 -1.133061079 0.145513447
## [106] -1.050133176 -0.694271915 -3.054808688 -2.949610583 -1.791491448
## [111] -3.272345123 1.966555022 2.479500363 -0.765227558 1.260949895
## [116] 2.022074882 -3.255621812 -0.477409747 0.770710583 2.909507552
## [121] -0.647773452 -3.011931036 1.103928167 0.173478616 -0.964556740
## [126] 0.821870851 2.880523509 -1.427059373 -3.129908061 1.548432104
## [131] -1.312704846 -0.588857216 -1.515857692 1.547705784 0.374178709
## [136] 1.773429233 -1.307948291 -2.372632679 0.697866161 -1.185259368
## [141] -1.128419430 -3.366323895 0.222052571 -0.845267329 -3.583309724
## [146] 1.141478291 0.003870702 1.119953494 -1.871950673 1.510288280
## [151] 2.180111319 0.571100441 -1.832166569 1.348692770 -0.855303784
## [156] 1.523838752 2.273577785 0.672847324 -0.848950978 -2.779740278
## [161] 2.760496039 3.161251569 -1.295446653 4.407017439 -1.558194889
## [166] -0.204405636 -2.385549822 0.048347376 -0.622835687 -1.446585499
## [171] -2.148300049 -1.758024372 -0.746294695 -0.643501402 1.553242137
## [176] -0.788049052 -0.483303959 0.596631211 2.735482406 -2.867016681
## [181] -0.826965600 3.186305659 -1.409820568 -2.237431668 1.941521025
## [186] -1.680087686 -1.946696730 1.285705457 -0.179029633 -3.014429798
## [191] -2.072033032 -0.038765947 1.100157046 1.353432549 2.150267047
## [196] 2.485108319 4.128951571 1.846076052 0.516004706 1.970653724
simData <- data.frame(Y=Y, X1=X1, X2=X2)
# set.seed(624)
fit <- rpart(Y ~ ., data = simData)
varImp(fit)
## Overall
## X1 3.543150
## X2 4.789933
set.seed(624)
X1 <- rep(16:20, each=40)
Y <- X1 + rnorm(200, mean=0, sd=4)
set.seed(624)
X2 <- rnorm(200, mean=0, sd=2)
simData <- data.frame(Y=Y, X1=X1, X2=X2)
# set.seed(624)
fit2 <- rpart(Y ~ ., data = simData)
varImp(fit2)
## Overall
## X1 3.803285
## X2 3.652489
set.seed(624)
X1 <- rep(19:20, each=100)
Y <- X1 + rnorm(200, mean=0, sd=4)
set.seed(624)
X2 <- rnorm(200, mean=0, sd=2)
simData <- data.frame(Y=Y, X1=X1, X2=X2)
# set.seed(624)
fit3 <- rpart(Y ~ ., data = simData)
varImp(fit3)
## Overall
## X1 0.8849928
## X2 4.7209459
# fit1 <- rpart(y ~., data = simulated, control = list(maxdepth = 2,minsplit=1,minbucket=1))
# fit2 <- rpart(y ~., data = simulated, control = list(maxdepth = 3,minsplit=1,minbucket=1))
# fit3 <- rpart(y ~., data = simulated, control = list(maxdepth = 5,minsplit=1,minbucket=1))
# fit4 <- rpart(y ~., data = simulated, control = list(maxdepth = 10,minsplit=1,minbucket=1))
# fit5 <- rpart(y ~., data = simulated, control = list(maxdepth = 30,minsplit=1,minbucket=1))
# plot(fit1)
# plot(fit2)
# plot(fit3)
# plot(fit4)
# plot(fit5)
# summary(fit4)
# fit4$cptable
# varImp(fit1)
# varImp(fit2)
#
# varImp(fit3)
# varImp(fit4)
# varImp(fit5)
# ?varImp
# simulated
#
# set.seed(12)
# test <- mlbench.friedman1(2000, sd = 1)
# test <- cbind(test$x, test$y)
# test <- as.data.frame(test)
# colnames(test)[ncol(test)] <- "y"
# test_y <- test$y
# test <- test[,-11]
# fit1_pred <- predict(fit1,test)
# fit2_pred <- predict(fit2,test)
# fit3_pred <- predict(fit3,test)
# fit4_pred <- predict(fit4,test)
# fit5_pred <- predict(fit5,test)
#
#
# rmse(test_y,fit1_pred)
# rmse(test_y,fit2_pred)
# rmse(test_y,fit3_pred)
# rmse(test_y,fit4_pred)
# rmse(test_y,fit5_pred)
#
# library(rpart)
# #fancyRpartPlot(fit1)
#
# #max(rpart:::tree.depth(nodes))
8.7
data("ChemicalManufacturingProcess")
completedData <- read.csv("imputed.csv")
complete_df_imputed <- completedData
my_df <- ChemicalManufacturingProcess[,-1]
processPredictors <- as.matrix(my_df)
yield <- ChemicalManufacturingProcess[,1]
## eliminate high correlation and near zero var
corrplot::corrplot(cor(completedData))

nearZeroVar(completedData)
## [1] 8
correlations <- cor(completedData)
highCorr <- findCorrelation(correlations, cutoff = .75)
completedData <- completedData[, -highCorr]
completedData <- completedData[,-3]
GBM
fitControl <- trainControl(method = "repeatedcv",
repeats = 5,
preProcOptions = list(thresh = 0.95))
gbmGrid <- expand.grid(interaction.depth = seq(4, 6, by = 1),
n.trees= seq(2000, 4000, by = 500),
shrinkage = c(0.01),n.minobsinnode=10)
set.seed(100)
gbmTune <- train(completedData, yield,method = "gbm", tuneGrid = gbmGrid,verbose = FALSE)
#gbmTune$
gbmTune
## Stochastic Gradient Boosting
##
## 176 samples
## 36 predictor
##
## No pre-processing
## Resampling: Bootstrapped (25 reps)
## Summary of sample sizes: 176, 176, 176, 176, 176, 176, ...
## Resampling results across tuning parameters:
##
## interaction.depth n.trees RMSE Rsquared MAE
## 4 2000 1.247578 0.5502498 0.9505465
## 4 2500 1.244986 0.5521889 0.9487557
## 4 3000 1.243571 0.5532701 0.9478211
## 4 3500 1.242632 0.5540278 0.9475109
## 4 4000 1.241774 0.5547013 0.9471427
## 5 2000 1.236111 0.5591455 0.9447760
## 5 2500 1.233683 0.5607636 0.9434386
## 5 3000 1.231927 0.5620530 0.9423792
## 5 3500 1.230670 0.5629623 0.9416365
## 5 4000 1.229745 0.5636486 0.9412084
## 6 2000 1.237204 0.5582136 0.9438385
## 6 2500 1.234706 0.5599288 0.9422316
## 6 3000 1.233168 0.5610440 0.9412871
## 6 3500 1.231818 0.5619718 0.9404083
## 6 4000 1.231046 0.5626175 0.9399537
##
## Tuning parameter 'shrinkage' was held constant at a value of 0.01
##
## Tuning parameter 'n.minobsinnode' was held constant at a value of 10
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were n.trees = 4000,
## interaction.depth = 5, shrinkage = 0.01 and n.minobsinnode = 10.
varImp(gbmTune)
## gbm variable importance
##
## only 20 most important variables shown (out of 36)
##
## Overall
## BiologicalMaterial03 100.00
## ManufacturingProcess17 70.56
## ManufacturingProcess28 53.58
## ManufacturingProcess06 51.16
## ManufacturingProcess36 46.89
## BiologicalMaterial09 41.96
## BiologicalMaterial11 34.49
## ManufacturingProcess39 23.31
## ManufacturingProcess33 22.31
## BiologicalMaterial05 21.90
## ManufacturingProcess20 19.40
## ManufacturingProcess27 17.58
## ManufacturingProcess11 16.90
## ManufacturingProcess30 16.57
## ManufacturingProcess43 15.25
## ManufacturingProcess05 15.15
## ManufacturingProcess01 15.12
## BiologicalMaterial10 14.30
## ManufacturingProcess24 13.48
## ManufacturingProcess16 12.62
# adabbot <- train(completedData ~ yield,
# distribution = "adaboost",
# method = "gbm", bag.fraction = 0.5,
# nTrain = round(nrow(training) *.75),
# trControl = fitControl,
# verbose = TRUE,
# tuneGrid = gbmGrid ))
## Specify which metric to optimize
# metric = "ROC"))