* figures.do * * Figure 1 of "Which H2O frame should you use to explain your model?" * Exports fig_pdp_x4.pdf and fig_ice_x4.pdf, the paired partial dependence * and ICE plots for x4, both estimated on the trainvalid frame. * . clear all set more off set seed 20260729 set obs 4000 gen double x1 = runiform(-3,3) gen double x2 = rnormal() gen double x3 = 0.9*x2 + sqrt(1-0.9^2)*rnormal() gen double x4 = runiform(-2,2) gen byte g = runiform()<0.5 gen double x5 = runiform() gen byte x6 = runiform()<0.5 gen double y = 4*sin(1.5*x1) + 2*x2 + 3*x4*(2*g-1) + rnormal(0,1.5) h2o init * EXACTLY the construction shown in the post _h2oframe put, into(all) _h2oframe split all, into(train valid test) split(0.6 0.2 0.2) rseed(19) _h2oframe rbind train valid, into(trainvalid) _h2oframe change train quietly h2oml gbregress y x1 x2 x3 x4 g x5 x6, /// ntrees(500) maxdepth(12) minobsleaf(1) lrate(0.1) h2orseed(19) h2omlgraph pdp x4, sd frame(trainvalid) name(pdp_x4, replace) /// title("Partial dependence of x4") subtitle("true PD(x4) = 0") graph export fig_pdp_x4.pdf, replace h2omlgraph ice x4, frame(trainvalid) name(ice_x4, replace) /// title("ICE curves for x4") subtitle("two bundles: slopes +3 and -3") graph export fig_ice_x4.pdf, replace di "=== metrics mentioned in the post ===" h2omlpostestframe _train h2omlestat metrics h2omlpostestframe test h2omlestat metrics di "----figures.do successful----"