5
1
0
2

n
u
J

3

]
L
M

.
t
a
t
s
[

3
v
2
0
5
7
.
7
0
4
1
:
v
i
X
r
a

UniversityofLiègeFacultyofAppliedSciencesDepartmentofElectricalEngineering&ComputerSciencePhDdissertationUNDERSTANDINGRANDOMFORESTSfromtheorytopracticebyGillesLouppeAdvisor:Prof.PierreGeurtsJuly2014LGLG 
 
 
 
 
 
JURYMEMBERSLouisWehenkel,ProfessorattheUniversitédeLiège(President);PierreGeurts,ProfessorattheUniversitédeLiège(Advisor);BernardBoigelot,ProfessorattheUniversitédeLiège;RenaudDetry,PostdoctoralResearcherattheUniversitédeLiège;GianlucaBontempi,ProfessorattheUniversitéLibredeBruxelles;GérardBiau,ProfessorattheUniversitéPierreetMarieCurie(France);iiiABSTRACTDataanalysisandmachinelearninghavebecomeanintegrativepartofthemodernscientiﬁcmethodology,offeringautomatedproceduresforthepredictionofaphenomenonbasedonpastobservations,un-ravelingunderlyingpatternsindataandprovidinginsightsabouttheproblem.Yet,cautionshouldavoidusingmachinelearningasablack-boxtool,butratherconsideritasamethodology,witharatio-nalthoughtprocessthatisentirelydependentontheproblemunderstudy.Inparticular,theuseofalgorithmsshouldideallyrequireareasonableunderstandingoftheirmechanisms,propertiesandlimi-tations,inordertobetterapprehendandinterprettheirresults.Accordingly,thegoalofthisthesisistoprovideanin-depthanal-ysisofrandomforests,consistentlycallingintoquestioneachandeverypartofthealgorithm,inordertoshednewlightonitslearn-ingcapabilities,innerworkingsandinterpretability.Theﬁrstpartofthisworkstudiestheinductionofdecisiontreesandtheconstructionofensemblesofrandomizedtrees,motivatingtheirdesignandpur-posewheneverpossible.Ourcontributionsfollowwithanoriginalcomplexityanalysisofrandomforests,showingtheirgoodcomputa-tionalperformanceandscalability,alongwithanin-depthdiscussionoftheirimplementationdetails,ascontributedwithinScikit-Learn.Inthesecondpartofthiswork,weanalyzeanddiscussthein-terpretabilityofrandomforestsintheeyesofvariableimportancemeasures.Thecoreofourcontributionsrestsinthetheoreticalchar-acterizationoftheMeanDecreaseofImpurityvariableimportancemeasure,fromwhichweproveandderivesomeofitspropertiesinthecaseofmultiwaytotallyrandomizedtreesandinasymptoticcon-ditions.Inconsequenceofthiswork,ouranalysisdemonstratesthatvariableimportancesascomputedfromnon-totallyrandomizedtrees(e.g.,standardRandomForest)sufferfromacombinationofdefects,duetomaskingeffects,misestimationsofnodeimpurityorduetothebinarystructureofdecisiontrees.Finally,thelastpartofthisdissertationaddresseslimitationsofran-domforestsinthecontextoflargedatasets.Throughextensiveexper-iments,weshowthatsubsamplingbothsamplesandfeaturessimul-taneouslyprovidesonparperformancewhileloweringatthesametimethememoryrequirements.Overallthisparadigmhighlightsanintriguingpracticalfact:thereisoftennoneedtobuildsinglemod-elsoverimmenselylargedatasets.Goodperformancecanoftenbeachievedbybuildingmodelson(very)smallrandompartsofthedataandthencombiningthemallinanensemble,therebyavoidingallpracticalburdensofmakinglargedataﬁtintomemory.vACKNOWLEDGMENTSAsthesayinggoes,goodpremisesdonotentailgoodstories.Yet,thisdissertationwouldcertainlynothavecometoitssuccessfulcon-clusionwithoutthehelp,supportandtrustofcolleagues,friendsandfamily.Firstandforemost,IwouldliketosincerelythankmyadvisorPierreGeurtsforhishelp,guidanceandforthefreedomIwasgrantedthroughouttheseyears.Iamgratefultoallmembersofthejuryfortheirinterestinthisworkandfortakingthetimetoevaluatethisdissertation.Inalphabeticalorder,Iwouldalsoliketothankmycolleagueswhoallcontributedtocreateandmaintainapleasantandstimulatingworkingenvironment:Antonio,Arnaud,Benjamin,Damien,Fabien,Julien,Loïc,Louis,Marie,Olivier,Raphaël,VanAnh,Vincent.SpecialthanksgotoAntonio,ArnaudandVincentwhoacceptedtoproof-readpartsofthismanuscript.IwanttakethisopportunitytothanktheScikit-Learnteamandallitscontributors.Thisexperiencewithintheopensourceworldreallycontributedtoshapemyvisionofscienceandsoftwaredevelopmenttowardsamodelofrigor,pragmatismandopenness.ThanksgotoGaël,Olivier,Lars,Mathieu,Andreas,AlexandreandPeter.SpecialthanksgototherowingteamoftheRCAE,fortheirfriend-shipandgoodmoodinallcircumstances.Guys,Ithankyouall.EvenifIneversucceededtofullyexplainmyresearchtopics,IwouldﬁnallyliketowarmlythankmydearfriendJérômeandmyfamilyfortheirhelpinmomentsofdoubt.Lastbutnotleast,Laura,Iamforevergratefulforyouruncondi-tionalsupportandlove.viiCONTENTS1introduction11.1Outlineandcontributions.................31.2Publications.........................4igrowingdecisiontrees72background92.1Learningfromdata.....................92.2Performanceevaluation..................112.2.1EstimatingErr(ϕL).................132.2.2Bayesmodelandresidualerror..........142.3Modelselection.......................162.3.1Selectingthe(approximately)bestmodel....162.3.2Selectingandevaluatingsimultaneously....182.4Classesoflearningalgorithms..............202.4.1Linearmethods...................202.4.2Supportvectormachines.............212.4.3Neuralnetworks..................222.4.4Nearestneighbormethods............243classificationandregressiontrees253.1Introduction.........................253.2Treestructuredmodels...................263.3Inductionofdecisiontrees.................293.4Assignmentrules......................323.4.1Classiﬁcation....................323.4.2Regression......................343.5Stoppingcriteria.......................353.6Splittingrules........................373.6.1FamiliesQofsplittingrules............373.6.2Goodnessofsplit..................403.6.2.1Classiﬁcation...............403.6.2.2Regression................463.6.3Findingthebestbinarysplit...........473.6.3.1Onanorderedvariable.........483.6.3.2Onacategoricalvariable........513.7Multi-outputdecisiontrees................524randomforests554.1Bias-variancedecomposition...............554.1.1Regression......................554.1.2Classiﬁcation....................584.2Ensemblemethodsbasedonrandomization......614.2.1Randomizedmodels................614.2.2Combiningrandomizedmodels.........62ixxcontents4.2.3Bias-variancedecompositionofanensemble..644.2.3.1Regression................644.2.3.2Classiﬁcation...............684.3RandomForests.......................694.3.1Randomizedinductionalgorithms........694.3.2Illustration......................744.4Propertiesandfeatures...................764.4.1Out-of-bagestimates................764.4.2Variableimportances................774.4.3Proximitymeasures................774.4.4Missingdata.....................804.5Consistency.........................815complexityanalysisandimplementation875.1Complexityoftheinductionprocedure.........875.2Complexityofthepredictionprocedure.........965.3Implementation.......................985.3.1Scikit-Learn.....................985.3.1.1Data....................1005.3.1.2Estimators................1015.3.1.3Predictors.................1025.3.1.4APIforrandomforests.........1035.3.2Internaldatastructures..............1035.3.3Builders.......................1065.3.4Splitters.......................1075.3.5Criteria........................1105.3.6Parallelization....................1115.4Benchmarks.........................1125.4.1Complexityonartiﬁcialdata...........1125.4.2Comparisonwithotherimplementations....115iiinterpretingrandomforests1216understandingvariableimportances1236.1Variableimportances....................1246.1.1Importancesinsingledecisiontrees.......1246.1.2Importancesinforests...............1246.2Theoreticalstudy......................1266.2.1Background.....................1266.2.2Asymptoticanalysis................1276.3Relevanceofvariables...................1306.4Variableimportancesinrandomforestvariants....1336.4.1Generalizationtootherimpuritymeasures...1336.4.2Pruningandrandomsubspaces.........1366.4.3Non-totallyrandomizedtrees...........1386.5Illustration..........................1396.6Conclusions.........................1437furtherinsightsfromimportances145contentsxi7.1Redundantvariables....................1457.2Biasinvariableimportances................1527.2.1Biasduetomaskingeffects............1527.2.2Biasduetoempiricalimpurityestimations...1537.2.3Biasduetobinarytreesandthresholdselection1597.3Applications.........................1637.3.1Featureselection..................1637.3.2Biomarkeridentiﬁcation..............1647.3.3Networkinference.................165iiisubsamplingdata1678ensemblesonrandompatches1698.1RandomPatches.......................1708.2OnAccuracy.........................1718.2.1Protocol.......................1728.2.2Smalldatasets....................1728.2.3Largerdatasets...................1768.2.4Conclusions.....................1798.3OnMemory.........................1798.3.1Sensitivitytoαsandαf..............1808.3.2Memoryreduction,withoutsigniﬁcantloss..1828.3.3Memoryreduction,withloss...........1848.3.4Conclusions.....................1868.4Overallconclusions.....................1869conclusions189ivappendix193anotations195breferences1991INTRODUCTIONInvariousﬁeldsofscience,technologyandhumanities,asinbiology,meteorology,medicineorﬁnancetociteafew,expertsaimatpredict-ingaphenomenonbasedonpastobservationsormeasurements.Forinstance,meteorologiststrytoforecasttheweatherforthenextdaysfromtheclimaticconditionsofthepreviousdays.Inmedicine,practi-tionerscollectmeasurementsandinformationsuchasbloodpressure,ageorhistoryfordiagnosingtheconditionofincomingpatients.Sim-ilarly,inchemistry,compoundsareanalyzedusingmassspectrome-trymeasurementsinordertodeterminewhethertheycontainagiventypeofmoleculesoratoms.Inallofthesecases,thegoalisthepre-dictionofaresponsevariablebasedonasetofobservedpredictorvariables.Forcenturies,scientistshaveaddressedsuchproblemsbyderiv-ingtheoreticalframeworksfromﬁrstprinciplesorhaveaccumulatedknowledgeinordertomodel,analyzeandunderstandthepheno-menonunderstudy.Forexample,practitionersknowfrompastex-periencethatelderlyheartattackpatientswithlowbloodpressurearegenerallyhighrisk.Similarly,meteorologistsknowfromelemen-taryclimatemodelsthatonehot,highpollutiondayislikelytobefollowedbyanother.Foranincreasingnumberofproblemshowever,standardapproachesstartshowingtheirlimits.Forexample,identify-ingthegeneticriskfactorsforheartdisease,whereknowledgeisstillverysparse,isnearlyimpracticalforthecognitiveabilitiesofhumansgiventhehighcomplexityandintricacyofinteractionsthatexistbe-tweengenes.Likewise,forveryﬁne-grainedmeteorologicalforecasts,alargenumberofvariablesneedtobetakenintoaccount,whichquicklygoesbeyondthecapabilitiesofexpertstoputthemallintoasystemofequations.Tobreakthiscognitivebarrierandfurtherad-vancescience,machinesofincreasingspeedandcapacityhavebeenbuiltanddesignedsincethemid-twentiethcenturytoassisthumansintheircalculations.Amazinglyhowever,alongsidethisprogressintermsofhardware,developmentsintheoreticalcomputerscience,ar-tiﬁcialintelligenceandstatisticshavemademachinestobecomemorethancalculators.Recentadvanceshavemadethemexpertsoftheirownkind,capabletolearnfromdataandtouncoverbythemselvesthepredictivestructureofproblems.Techniquesandalgorithmsthathavestemmedfromtheﬁeldofmachinelearninghaveindeednowbecomeapowerfultoolfortheanalysisofcomplexandlargedata,successfullyassistingscientistsinnumerousbreakthroughsofvari-ousﬁeldsofscienceandtechnology.Publicandfamousexamples12introductionincludetheuseofboosteddecisiontreesinthestatisticalanalysisthatledtothedetectionoftheHiggsbosonatCERN[Chatrchyanetal.,2012],theuseofrandomforestsforhumanposedetectionintheMicrosoftKinect[CriminisiandShotton,2013]ortheimplemen-tationofvariousmachinelearningtechniquesforbuildingtheIBMWatsonsystem[Ferruccietal.,2010],capabletocompeteatthehu-manchampionlevelontheAmericanTVquizshowJeopardy.Formally,machinelearningcanbedeﬁnedasthestudyofsystemsthatcanlearnfromdatawithoutbeingexplicitlyprogrammed.Ac-cordingtoMitchell[1997],acomputerprogramissaidtolearnfromdata,withrespecttosomeclassoftasksandperformancemeasureifitsperformanceatthosetasksimproveswithdata.Inparticular,machinelearningprovidesalgorithmsthatareabletosolveclassiﬁca-tionorregressiontasks,hencebringingnowautomatedproceduresforthepredictionofaphenomenonbasedonpastobservations.How-ever,thegoalofmachinelearningisnotonlytoproducealgorithmsmakingaccuratepredictions,itisalsotoprovideinsightsonthepre-dictivestructureofthedata[Breimanetal.,1984].Ifweareaimingatthelatter,thenourgoalistounderstandwhatvariablesorinter-actionsofvariablesdrivethephenomenon.Forpractitioners,whicharenotexpertsinmachinelearning,interpretabilityisindeedoftenasimportantaspredictionaccuracy.Itallowsforabetterunderstand-ingofthephenomenonunderstudy,aﬁnerexplorationofthedataandaneasierself-appropriationoftheresults.Bycontrast,whenanalgorithmisusedasablackbox,yieldingresultsseeminglyoutofnowhere,itmayindeedbedifﬁculttotrustoracceptifitcannotbeunderstoodhowandwhytheprocedurecametothem.Unfortu-nately,thecurrentstate-of-the-artinmachinelearningoftenmakesitdifﬁcultfornon-expertstounderstandandinterprettheresultsofanalgorithm.Whileconsiderableeffortshavebeenputtoimprovetheirpredictionaccuracy,itisstillnotclearlyunderstoodwhatmakesma-chinelearningalgorithmstrulywork,andunderwhatassumptions.Likewise,fewofthemactuallyprovideclearandinsightfulexplana-tionsabouttheresultstheygenerate.Inthiscontext,thegoalofthisthesisistoprovideacomprehen-siveandself-containedanalysisofaclassofalgorithmsknownasdecisiontrees[Breimanetal.,1984]andrandomforests[Breiman,2001].Whilethesemethodshaveproventobearobust,accurateandsuccessfultoolforsolvingcountlessofmachinelearningtasks,includ-ingclassiﬁcation,regression,densityestimation,manifoldlearningorsemi-supervisedlearning[CriminisiandShotton,2013],thereremainmanygrayareasintheirunderstanding:(a)First,thetheoreticalpropertiesandstatisticalmechanismsthatdrivethealgorithmarestillnotclearlyandentirelyunderstood.Randomforestsindeedevolvedfromempiricalsuccessesratherthanfromasoundtheory.Assuch,variouspartsofthealgo-1.1outlineandcontributions3rithmremainheuristicratherthantheoreticallymotivated.Forexample,preliminaryresultshaveproventheconsistencyofsimpliﬁedtoveryclosevariantsofrandomforests,butconsis-tencyoftheoriginalalgorithmremainsunproveninageneralsetting.(b)Second,whiletheconstructionprocessofasingledecisiontreecaneasilybedescribedwithinhalfapage,implementingthisalgorithmproperlyandefﬁcientlyremainsachallengingtaskinvolvingissuesthatareeasilyoverlooked.Unfortunately,im-plementationdetailsareoftenomittedinthescientiﬁcliteratureandcanoftenonlybefoundbydivinginto(unequallydocu-mented)existingsoftwareimplementations.Asfarasweknow,thereisindeednocomprehensivesurveycoveringtheimple-mentationdetailsofrandomforests,norwiththeirrespectiveeffectsintermsofruntimeandspacecomplexityorlearningability.(c)Third,interpretingtheresultingmodelremainsadifﬁculttask,forwhichevenmachinelearningexpertsstillfailatﬁnelyana-lyzinganduncoveringtheprecisepredictivestructurelearnedbytheprocedure.Inparticular,despitetheirextensiveuseinawiderangeofapplications,littleisstillknownregardingvari-ableimportancemeasurescomputedbyrandomforests.Empir-icalevidencesuggeststhattheyareappropriateforidentifyingrelevantvariables,buttheirstatisticalmechanismsandproper-tiesarestillfarfrombeingunderstood.Allthroughoutthisdissertation,ourobjectiveisthereforetocallintoquestioneachandeverypartoftherandomforestsmethodology,bothfromatheoreticalandpracticalpointofview.Accordingly,thisworkaimsatrevisitingdecisiontreesandrandomforeststohope-fullyshednewlightontheirlearningcapabilities,innerworkingsandinterpretability.1.1outlineandcontributionsPartiofthismanuscriptisﬁrstdedicatedtoathoroughtreatmentofdecisiontreesandforestsofrandomizedtrees.WebegininChap-ter2byoutliningfundamentalconceptsofmachinelearning,andthenproceedinChapters3and4withacomprehensivereviewofthealgorithmsatthecoreofdecisiontreesandrandomforests.Wediscussthelearningcapabilitiesofthesemodelsandcarefullystudyallpartsofthealgorithmandtheircomplementaryeffects.Inpartic-ular,Chapter4includesoriginalcontributionsonthebias-varianceanalysisofensemblemethods,highlightinghowrandomizationcanhelpimproveperformance.Chapter5concludesthisﬁrstpartwithanoriginalspaceandtimecomplexityanalysisofrandomforests(and4introductiontheirvariants),alongwithanin-depthdiscussionofimplementationdetails,ascontributedwithintheopensourceScikit-Learnlibrary.Overall,Partithereforepresentsacomprehensivereviewofpreviousworkonrandomforests,includingsomeoriginalcontributionsbothfromatheoreticalandpracticalpointofview.Partiianalyzesanddiscussestheinterpretabilityofrandomforests.InChapter6,westudyvariableimportancesascomputedwithaforestofrandomizedtreesandstudyhowthesescorescanbeinter-pretedinordertorevealtheunderlyingpredictivestructurelearnedfromthedata.Inparticular,wederiveatheoreticalframeworkfromwhichweprovetheoreticalandpracticalpropertiesofvariableim-portances.InChapter7,wethenexploitthisframeworktofurtherstudyvariableimportancesasderivedfromactualrandomforestsandpresentsuccessfulapplicationsofvariableimportancemeasures.Partiiconstitutesthemaincontributionsofthisdissertation.Finally,Partiiiaddresseslimitationsofrandomforestsinthecon-textoflargedatasets.Throughextensiveexperiments,weshowinChapter8thatsubsamplingstrategiesprovidesonparperformancewhilesimultaneouslyloweringthememoryrequirements.Thischap-terpresentsoriginalwork.1.2publicationsThisdissertationsummarizesseveralcontributionstorandomforestsalgorithms.Publicationsthathavedirectlystemmedfromthisworkinclude:-[GeurtsandLouppe,2011]Learningtorankwithextremelyran-domizedtrees,GeurtsPierreandLouppeGilles.InJMLR:Work-shopandConferenceProceedings,volume14,2011.-[LouppeandGeurts,2012]Ensemblesonrandompatches,LouppeGillesandGeurtsPierre.InMachineLearningandKnowledgeDiscoveryinDatabases,pages346–361.Springer,2012.-[Louppeetal.,2013]Understandingvariableimportancesinforestsofrandomizedtrees,LouppeGilles,WehenkelLouis,SuteraAnto-nioandGeurtsPierre.InAdvancesinNeuralInformationPro-cessingSystems,pages431–439,2013.-[Buitincketal.,2013]APIdesignformachinelearningsoftware:ex-periencesfromthescikit-learnproject,BuitinckLars,LouppeGilles,BlondelMathieuetal..InECML-PKDD2013Workshop:Lan-guagesforDataMiningandMachineLearning,2013.-[Bottaetal.,2014]ExploitingSNPCorrelationswithinRandomFor-estforGenome-WideAssociationStudies,BottaVincent,LouppeGilles,GeurtsPierreandWehenkelLouis.PloSone,9(4):e93379,2014.1.2publications5Duringthecourseofthisthesis,severalfruitfulcollaborationshavealsoledtothefollowingpublications.Thesearenotdiscussedwithinthisdissertation.-[LouppeandGeurts,2010]Azealousparallelgradientdescental-gorithm,LouppeGillesandGeurtsPierre.InLearningonCores,ClustersandCloudsworkshop,NIPS,2010-[Maréeetal.,2014]Ahybridhuman-computerapproachforlarge-scaleimage-basedmeasurementsusingwebservicesandmachinelearn-ing,MaréeRaphaël,RollusLoic,StevensBenjaminetal.Pro-ceedingsIEEEInternationalSymposiumonBiomedicalImag-ing,2014.-[McGovernetal.,2014]SolarEnergyPrediction:AnInternationalContesttoInitiateInterdisciplinaryResearchonCompellingMeteo-rologicalProblems,AmyMcGovern,DavidJohnGagneII,LucasEustaquioetal.,2014.Submitted.-[Suteraetal.,2014]Simpleconnectomeinferencefrompartialcorre-lationstatisticsincalciumimaging,AntonioSutera,ArnaudJoly,VincentFrancois-Lavetetal.,2014.Submitted.PartIGROWINGDECISIONTREES2BACKGROUNDOutlineInthischapter,weintroducesupervisedlearningandfundamentalconceptsonwhichthisworkbuildsupon.InSection2.1,weﬁrstde-scribeclassiﬁcationandregressionlearningtasksandthenformallydeﬁnethenotionofmodel.InSection2.2,weproceedwithadis-cussiononperformanceevaluationandthendescribe,inSection2.3,proceduresforselectingthebestpossiblemodel.Finally,weconcludeinSection2.4withabriefoverviewofsomeofthemainmethodsinsupervisedlearning.2.1learningfromdataIntheexamplesintroducedinChapter1,theobjectivewhichissoughtistoﬁndasystematicwayofpredictingaphenomenongivenasetofmeasurements.Inmachinelearningterms,thisgoalisformulatedasthesupervisedlearningtaskofinferringfromcollecteddataamodelthatpredictsthevalueofanoutputvariablebasedontheobservedvaluesofinputvariables.Assuch,ﬁndinganappropriatemodelisbasedontheassumptionthattheoutputvariabledoesnottakeitsvalueatrandomandthatthereexistsarelationbetweentheinputsandtheoutput.Inmedicineforinstance,thegoalistoﬁndadecisionrule(i.e.,amodel)fromasetofpastcases(i.e.,thecollecteddata)forpredictingtheconditionofanincomingpatient(i.e.,theoutputvalue)givenasetofmeasurementssuchasage,sex,bloodpressureorhistory(i.e.,theinputvalues).Togiveamorepreciseformulation,letusassumeassetofcasesorobjectstakenfromauniverseΩ.Letusarrangethesetofmeasure-mentsonacaseinapre-assignedorder,i.e.,taketheinputvaluestobex1,x2,...,xp,wherexj∈Xj(forj=1,...,p)correspondstothevalueoftheinputvariableXj.Together,theinputvalues(x1,x2,...,xp)formap-dimensionalinputvectorxtakingitsvaluesinX1×...×Xp=X,whereXisdeﬁnedastheinputspace.Similarly,letusde-ﬁneasy∈YthevalueoftheoutputvariableY,whereYisdeﬁnedastheoutputspace1.Bydeﬁnition,boththeinputandtheoutputspacesareassumedtorespectivelycontainallpossibleinputvectorsandallpossibleoutputvalues.Notethatinputvariablesaresome-1Unlessstatedotherwise,supervisedlearningisreducedtothepredictionofasin-gleoutputvariable.Moregenerallyhowever,thisframeworkcanbedeﬁnedasthepredictionofoneorseveraloutputvariables.910backgroundtimesknownasfeatures,inputvectorsasinstancesorsamplesandtheoutputvariableastarget.Amongvariablesthatdeﬁnetheproblem,wedistinguishbetweentwogeneraltypes.Theformercorrespondtoquantitativevariableswhosevaluesareintegerorrealnumbers,suchasageorbloodpres-sure.Thelattercorrespondtoqualitativevariableswhosevaluesaresymbolic,suchasgenderorcondition.Formally,wedeﬁnethemasfollows:Deﬁnition2.1.AvariableXjisorderedifXjisatotallyorderedset.Inparticular,XjissaidtobenumericalifXj=R.Deﬁnition2.2.AvariableXjiscategoricalifXjisaﬁnitesetofvalues,withoutanynaturalorder.Inatypicalsupervisedlearningtask,pastobservationsaresumma-rizedbyadatasetcalledlearningset.Itconsistsinasetofobservedinputvectorstogetherwiththeiractualoutputvalueandformallydeﬁnedasfollows:Deﬁnition2.3.AlearningsetLisasetofNpairsofinputvectorsandoutputvalues(x1,y1),...,(xN,yN),wherexi∈Xandyi∈Y.Equivalently,asetofp-inputvectorsxi(fori=1,...,N)canbede-notedbyaN×pmatrixX,whoserowsi=1,...,Ncorrespondtoinputvectorsxiandcolumnsj=1,...,ptoinputvariablesXj.Sim-ilarly,thecorrespondingoutputvaluescanbewrittenasavectory=(y1,...,yN).DatarepresentationForoptimalimplementationsofmachinelearningalgorithms,dataneedstoberepresentedusingstructureswhichallowforhigh-performancenumericalcomputation.Inthiswork,codesnippetsaredescribedundertheassumptionthatdataisrepresentedusingadatastructuresimilartoaNumPyarray[VanderWaltetal.,2011].ANumPyarrayisbasicallyamultidimensionaluniformcollectionofvalues,allofthesametypeandorganizedinagivenshape.Forinstance,amatrixXcanberepresentedasa2-dimensionalNumPyarrayofshapeN×pthatcontainsnumbers(e.g.,ﬂoatingpointvaluesorintegers).Thisstructureallowsforrandomaccessinconstanttime,vectorizedhigh-leveloperationsandefﬁcientmemoryusage.Additionally,usingadatarepresentationwhichisclosetothema-trixformulation,likeNumPyarrays,makesitpossibletowriteim-plementationsthatareclosetotheiroriginaltextbookformulation,therebymakingthemeasiertocode,understandandmaintain.Inthisframework,thesupervisedlearningtaskcanbestatedaslearningafunctionϕ:X7→YfromalearningsetL=(X,y).Theob-jectiveistoﬁndamodelsuchthatitspredictionsϕ(x),alsodenoted2.2performanceevaluation11bythevariableˆY,areasgoodaspossible.IfYisacategoricalvariablethenthelearningtaskisaclassiﬁcationproblem.IfYisnumericalvariable,thenlearningtaskisaregressionproblem.Withoutlossofgenerality,theresultingmodelscanbedeﬁnedasfollows:Deﬁnition2.4.Aclassiﬁerorclassiﬁcationruleisafunctionϕ:X7→Y,whereYisaﬁnitesetofclasses(orlabels)denoted{c1,c2,...,cJ}.Deﬁnition2.5.Aregressorisafunctionϕ:X7→Y,whereY=R.EstimatorinterfaceWefollowinthisworktheAPIconventionsproposedbyBuitincketal.[2013].Learningalgorithmsaredescribedasestimatorobjectsimplementingthefollowinginterface:-Hyper-parametersofanalgorithmareallpassedtotheconstruc-toroftheestimator.Theconstructordoesnotseeanyactualdata.Allitdoesistoattachhyper-parametersvaluesaspublicattributestotheestimatorobject.-Learningisperformedinafitmethod.Thismethodiscalledwithalearningset(e.g.,suppliedastwoarraysX_trainandy_train).Itstaskistorunalearningalgorithmandtodeter-minemodel-speciﬁcparametersfromthedata.Thefitmethodalwaysreturnstheestimatorobjectitwascalledon,whichnowservesasamodelandcanbeusedtomakepredictions.-Predictionsareperformedthroughapredictmethod,takingasinputanarrayX_testandproducingasoutputthepredictionsforX_testbasedonthelearnedparameters.Inthecaseofclas-siﬁcation,thismethodreturnslabelsfromY={c1,c2,...,cJ}.Inthecaseofregression,itreturnsnumericalvaluesfromY=R.WiththisAPI,atypicalsupervisedlearningtaskisperformedasfollows:#Instantiateandsethyper-parametersclf=DecisionTreeClassifier(max_depth=5)#Learnamodelfromdataclf.fit(X_train,y_train)#Makepredictionsonnewdatay_pred=clf.predict(X_test)2.2performanceevaluationInthestatisticalsense,inputandoutputvariablesX1,...,XpandYarerandomvariablestakingjointlytheirvaluesfromX×YwithrespecttothejointprobabilitydistributionP(X,Y),whereXdenotestherandom12backgroundvector(X1,...,Xp).Thatis,P(X=x,Y=y)istheprobabilitythatrandomvariablesXandYtakevaluesxandyfromXandYwhendrawinganobjectuniformlyatrandomfromtheuniverseΩ.Accordingly,usinganalgorithmAforlearningamodel2ϕLwhosepredictionsareasgoodaspossiblecanbestatedasﬁndingamodelwhichminimizesitsexpectedpredictionerror,deﬁnedasfollows:Deﬁnition2.6.Theexpectedpredictionerror,alsoknownasgeneral-izationerrorortesterror,ofthemodelϕLis3Err(ϕL)=EX,Y{L(Y,ϕL(X))},(2.1)whereListhelearningsetusedtobuildϕLandLisalossfunctionmea-suringthediscrepancybetweenitstwoarguments[Geurts,2002].Equation2.1basicallymeasuresthepredictionerrorofϕLoverallpossibleobjectsinΩ(eachrepresentedbyacouple(x,y)∈X×Y),includingtheobservedcouplesfromthelearningsetLbutalsoalltheunseenonesfromX×Y\L.Indeed,thegoalisnotinfacttomakethevery-mostaccuratepredictionsoverthesubsetLofknowndata,butrathertolearnamodelwhichiscorrectandreliableonallpossibledata.Forclassiﬁcation,themostcommonlossfunctionisthezero-onelossfunction4L(Y,ϕL(X))=1(Y6=ϕL(X)),whereallmisclassiﬁcationsareequallypenalized.Inthiscase,thegeneralizationerrorofϕLbecomestheprobabilityofmisclassiﬁcationofthemodel:Err(ϕL)=EX,Y{1(Y6=ϕL(X))}=P(Y6=ϕL(X))(2.2)Similarly,forregression,themostusedlossfunctionisthesquarederrorlossL(Y,ϕL(X))=(Y−ϕL(X))2,wherelargedifferencesbe-tweenthetruevaluesandthepredictedvaluesarepenalizedmoreheavilythansmallones.Withthisloss,thegeneralizationerrorofthemodelbecomes:Err(ϕL)=EX,Y{(Y−ϕL(X))2}(2.3)2Unlessitisclearfromthecontext,modelsarenowdenotedϕLtoemphasizethattheyarebuiltfromthelearningsetL.3EX{f(X)}denotestheexpectedvalueoff(x)(forx∈X)withrespecttotheprobabilitydistributionoftherandomvariableX.ItisdeﬁnedasEX{f(X)}=Xx∈XP(X=x)f(x).41(condition)denotestheunitfunction.Itisdeﬁnedas1(condition)=1ifconditionistrue0ifconditionisfalse.2.2performanceevaluation132.2.1EstimatingErr(ϕL)Inpractice,theprobabilitydistributionP(X,Y)isusuallyunknown,makingthedirectevaluationofErr(ϕL)infeasible.Equivalently,itisoftennotpossibletodrawadditionaldata,therebymakinginfeasibletheempiricalestimationofErr(ϕL)ona(virtuallyinﬁnite)setL0drawnindependentlyfromL.Inmostproblems,Lconstitutestheonlydataavailable,onwhichboththemodelneedstobelearnedanditsgeneralizationerrorestimated.Asreviewedanddescribedonmultipleoccasionsbyseveralauthors[Toussaint,1974;Stone,1978;Breimanetal.,1984;Kohavietal.,1995;NadeauandBengio,2003;Hastieetal.,2005;ArlotandCelisse,2010],thegeneralizationerrorinEquation2.1canhoweverbeestimatedinseveralways.Tomakenotationsclearer,letusﬁrstdeﬁneE(ϕL,L0)astheaver-agepredictionerrorofthemodelϕLoverthesetL0(possiblydiffer-entfromthelearningsetLusedtoproduceϕL),thatis:E(ϕL,L0)=1N0X(xi,yi)∈L0L(yi,ϕL(xi))(2.4)whereN0isthesizeofthesetL0.Theﬁrstandsimplestestimateofthegeneralizationerroristheresubstitutionestimateortrainingsampleestimate.Itconsistsinempiri-callyestimatingErr(ϕL)onthesamedataasthelearningsetLusedtobuildϕL,thatis:dErrtrain(ϕL)=E(ϕL,L)(2.5)Ingeneral,theresubstitutionerrorisapoorestimateofErr(ϕL).Inparticular,sincemostmachinelearningalgorithmsaimatpreciselyminimizingEquation2.5(eitherdirectlyorindirectly),ittypicallyresultsinanoverlyoptimisticestimateofthegeneralizationerror,whichaccountsforallcouples(x,y),i.e.,notonlythosefromL.Thesecondapproachisthetestsampleestimate.Itconsistsindi-vidingthelearningsetLintotwodisjointsetsLtrainandLtest,calledtrainingsetandtestset,andthentouseeachpartrespectivelyforlearn-ingamodelandestimatingitsgeneralizationerror.ThetestsampleestimateofthegeneralizationerrorofthemodelϕLthatwouldbeobtainedfromListhengivenastheaveragepredictionerroroverLtestofthemodelϕLtrainbuiltonLtrain:dErrtest(ϕL)=E(ϕLtrain,Ltest)(2.6)Asarule-of-thumb,Ltrainisusuallytakenas70%ofthesamplesinLandLtestastheremaining30%,thoughtheoreticalwork[Guyon,1997]suggeststoprogressivelyreducethesizeoftestsetasthesizeofLincreases.Inanycase,caremustbetakenwhensplittingLintotwosubsets,sothatsamplesfromLtraincanbeconsideredindependent14backgroundfromthoseinLtestanddrawnfromthesamedistribution.ThisishoweverusuallyguaranteedbydrawingLtrainandLtestsimplyatrandomfromL.WhilebeinganunbiasedestimateofErr(ϕL),thetestsampleestimatehasthedrawbackthatitreducestheeffectivesamplesizeonwhichthemodelϕLtrainislearned.IfLislarge,thenthisisusuallynotanissue,butifLonlycontainsafewdozensofsamples,thenthisstrategymightnotcorrectlyapproximatethetruegeneralizationerrorofthemodelthatwouldhavebeenlearnedontheentirelearningset.WhenLissmall,theK-foldcross-validationestimateisusuallypre-ferredoverthetestsampleestimate.ItconsistsinrandomlydividingthelearningsetLintoKdisjointsubsets,L1,...,LK,andthentoesti-matethegeneralizationerrorastheaveragepredictionerroroverthefoldsLkofthemodelsϕL\Lklearnedontheremainingdata:dErrCV(ϕL)=1KKXk=1E(ϕL\Lk,Lk)(2.7)TheassumptionbehindthisapproachisthatsinceeachmodelϕL\LkisbuiltusingalmostallL,theyshouldallbeclosetothemodelϕLlearnedontheentireset.AsaresulttheunbiasedestimatesE(ϕL\Lk,Lk)shouldalsoallbeclosetoErr(ϕL).Whilemorecom-putationallyintensive,theK-foldcross-validationestimatehasthead-vantagethateverycouple(x,y)∈Lisusedforestimatingthegener-alizationerrorofϕL.Inatypicalsetting,Kisusuallyﬁxedto10,avalueoftenyieldingstableandreliableestimates[Kohavietal.,1995].ExpectedgeneralizationerrorAswehaveshown,ourgoalistoestimatethegeneralizationerrorErr(ϕL)conditionalonthelearningsetL.ArelatedquantityistheexpectedgeneralizationerrorEL{Err(ϕL)},(2.8)averagingovereverythingwhichisrandom,includingtherandom-nessinthelearningsetLusedtoproduceϕL.AsdiscussedbyHastieetal.[2005],thisquantityisclose,yetdifferentfromErr(ϕL).Theau-thorspointoutthatmostestimates,includingK-foldcross-validation,effectivelyestimateEquation2.8ratherthanEquation2.1.2.2.2BayesmodelandresidualerrorIntheory,whentheprobabilitydistributionP(X,Y)isknown,thebestpossiblemodel,i.e.,themodelϕBwhichminimizesthegeneraliza-tionerrorofEquation2.1,canbederivedanalyticallyandindepen-2.2performanceevaluation15dentlyofanylearningsetL.ByconditioningonX,thegeneralizationerrorofthismodelcanberewrittenas:EX,Y{L(Y,ϕB(X))}=EX{EY|X{L(Y,ϕB(X))}}(2.9)Inthislatterform,themodelwhichminimizesEquation2.9isamodelwhichminimizestheinnerexpectationpoint-wise,thatis:ϕB(x)=argminy∈YEY|X=x{L(Y,y)}(2.10)Intheliterature,ϕBisknownastheBayesmodelanditsgeneralizationerrorErr(ϕB)astheresidualerror.Itrepresentstheminimalerrorthatanysupervisedlearningalgorithmcanpossiblyattain,thatistheirreducibleerrorpurelyduetorandomdeviationsinthedata.Deﬁnition2.7.AmodelϕBisaBayesmodelif,foranymodelϕbuiltfromanylearningsetL,Err(ϕB)6Err(ϕL).Inclassiﬁcation,whenListhezero-oneloss,theBayesmodelis:ϕB(x)=argminy∈YEY|X=x{1(Y,y)}=argminy∈YP(Y6=y|X=x)=argmaxy∈YP(Y=y|X=x)(2.11)Putotherwise,thebestpossibleclassiﬁerconsistsinsystematicallypredictingthemostlikelyclassy∈{c1,c2,...,cJ}givenX=x.Similarly,forregressionwiththesquarederrorloss,wehave:ϕB(x)=argminy∈YEY|X=x{(Y−y)2}=EY|X=x{Y}(2.12)Inotherwords,thebestpossibleregressorconsistsinsystematicallypredictingtheaveragevalueofYatX=x.Forpracticalproblems,P(X,Y)isunknownandtheBayesmodelcannotbederivedanalytically.Inthiscontext,theeffectivenessofamodelϕLmaybedifﬁculttoevaluatesince(estimatesof)Err(ϕL)maynotbeveryindicativeofthegoodnessofϕLifthelowestattain-ableerrorErr(ϕB)isunknown.Onsimulateddatahowever,wherethedistributionisknown,derivingϕBandErr(ϕB)isfeasible.ThisisbeneﬁcialasErr(ϕB)cannowbeusedforcomparingthetestseterrorofϕLandtherebyevaluatetheactualeffectivenessofϕLwithrespecttothebestmodelonecanpossiblybuild.Fromatheoreticalpointofview,theconceptsofBayesmodelandresidualerrorarealsousefultostudythelearningcapabilitiesofanalgorithm.Inparticular,asLgetsarbitrarilylarge,afundamentalquestionistoknowwhetheritispossibletoproduceamodelϕL16backgroundwhichisconsistent,thatissuchthatitsgeneralizationerrorgetsarbi-trarilyclosetothelowestpossiblegeneralizationerrorErr(ϕB).For-mally,consistencyisdeﬁnedasfollows[Devroyeetal.,1996]:Deﬁnition2.8.AlearningalgorithmAissaidtobeweaklyconsistentforacertaindistributionP(X,Y)ifEL{Err(ϕL)}→Err(ϕB)asthesizeNofthelearningsetLusedtobuildϕLusingAtendstoinﬁnity.Deﬁnition2.9.AlearningalgorithmAissaidtobestronglyconsistentforacertaindistributionP(X,Y)ifErr(ϕL)→Err(ϕB)almostsurelyasthesizeNofthelearningsetLusedtobuildϕLusingAtendstoinﬁnity.NotethatthedeﬁnitionofconsistencydependsonthedistributionP(X,Y).Ingeneral,alearningalgorithmAcanbeproventobeconsis-tentforsomeclassesofdistributions,butnotforothers.IfconsistencycanbeprovenforanydistributionP(X,Y),thenAissaidtobeuniver-sally(strongly)consistent.2.3modelselectionFromthepreviousdiscussioninSection2.2.2,itappearsthattosolvethesupervisedlearningproblemitwouldbesufﬁcienttoestimateP(Y|X)fromthelearningsampleLandthentodeﬁneamodelac-cordinglyusingeitherEquation2.11orEquation2.12.Unfortunately,thisapproachisinfeasibleinpracticebecauseitrequiresLtogrowex-ponentiallywiththenumberpofinputvariablesinordertocomputeaccurateestimatesofP(Y|X)[Geurts,2002].2.3.1Selectingthe(approximately)bestmodelTomakesupervisedlearningworkinhigh-dimensionalinputspaceswithlearningsetsofmoderatesizes,simplifyingassumptionsmustbemadeonthestructureofthebestmodelϕB.Morespeciﬁcally,asupervisedlearningalgorithmassumesthatϕB–oratleastagoodenoughapproximation–livesinafamilyHofcandidatemodels,alsoknownashypothesesinstatisticallearningtheory,ofrestrictedstructure.Inthissetting,themodelselectionproblemisthendeﬁnedasﬁndingthebestmodelamongHonthebasisofthelearningsetL.ApproximationerrorDependingonrestrictionsmadeonthestructureoftheproblem,theBayesmodelusuallydoesnotbelongtoH,buttheremaybemodelsϕ∈Hthataresufﬁcientlyclosetoit.Assuch,theapproximationerror[BottouandBousquet,2011]measureshowcloselythemodelsinHcanapproximatetheoptimalmodelϕB:Err(H)=minϕ∈H{Err(ϕ)}−Err(ϕB)(2.13)2.3modelselection17Tobemorespeciﬁc,letθbethevectorofhyper-parametersvaluescontrollingtheexecutionofalearningalgorithmA.TheapplicationofAwithhyper-parametersθonthelearningsetLisadeterministic5processyieldingamodelA(θ,L)=ϕL∈H.Assuch,ourgoalistoﬁndthevectorofhyper-parametersvaluesyieldingtothebestmodelpossiblylearnableinHfromL:θ∗=argminθErr(A(θ,L))(2.14)Again,thisproblemcannot(usually)besolvedexactlyinpracticesinceitrequiresthetruegeneralizationerrorofamodeltobecom-putable.Howeverapproximationsbθ∗canbeobtainedinseveralways.WhenLislarge,theeasiestwaytoﬁndbθ∗istousetestsamplees-timates(asdeﬁnedbyEquation2.6)toguidethesearchofthehyper-parametervalues,thatis:bθ∗=argminθdErrtest(A(θ,L))(2.15)=argminθE(A(θ,Ltrain),Ltest)(2.16)Inpractice,solvingthislaterequationisalsoadifﬁculttaskbutap-proximationscanbeobtainedinseveralways,e.g.,usingeitherman-ualtuningofθ,exhaustiveexplorationoftheparameterspaceusinggridsearch,ordedicatedoptimizationprocedures(e.g.,usingran-domsearch[BergstraandBengio,2012]).Similarly,whenLisscarce,thesameprocedurecanbecarriedoutintheexactsamewaybutusingK-foldcross-validationestimates(asdeﬁnedbyEquation2.7)insteadoftestsampleestimates.Inanycase,oncebθ∗isidentiﬁed,thelearningalgorithmisrunonceagainontheentirelearningsetL,ﬁnallyyieldingtheapproximatelyoptimalmodelA(bθ∗,L).Whenoptimizingθ,specialcaremustbetakensothattheresultingmodelisneithertoosimplenortoocomplex.Intheformercase,themodelisindeedsaidtounderﬁtthedata,i.e.,tobenotﬂexibleenoughthecapturethestructurebetweenXandY.Inthelatercase,themodelissaidtooverﬁtthedata,i.e.,tobetooﬂexibleandtocaptureisolatedstructures(i.e.,noise)thatarespeciﬁctothelearningset.AsFigure2.1illustrates,thisphenomenoncanbeobservedbyex-aminingtherespectivetrainingandtestestimatesofthemodelwithrespecttoitscomplexity6.Whenthemodelistoosimple,boththetrainingandtestestimatesarelargebecauseofunderﬁtting.Ascom-plexityincreases,themodelgetsmoreaccurateandboththetrainingandtestestimatesdecrease.However,whenthemodelbecomestoocomplex,speciﬁcelementsfromthetrainingsetgetcaptured,reduc-ingthecorrespondingtrainingestimatesdownto0,asifthemodel5IfAmakesuseofapseudo-randomgeneratortomimicastochasticprocess,thenweassumethatthecorrespondingrandomseedispartofθ.6Unlessmentionedotherwise,complexityherereferstothecomplexityofthemodelinfunctionspace.ComputationalcomplexityisstudiedlaterinSection5.118backgroundModelcomplexity051015202530MeansquareerrorTrainingerrorTesterrorFigure2.1:Trainingandtesterrorwithrespecttothecomplexityofamodel.ThelightbluecurvesshowthetrainingerroroverLtrainwhilethelightredcurvesshowthetesterrorestimatedoverLtestfor100pairsoftrainingandtestsetsLtrainandLtestdrawnatrandomfromaknowndistribution.Thethickbluecurveistheaveragetrainingerrorwhilethethickredcurveistheaveragetesterror.(Figureinspiredfrom[Hastieetal.,2005].)wereperfect.Atthesametime,thetestestimatesbecomeworsebe-causethestructurelearnedfromthetrainingsetisactuallytoospe-ciﬁcanddoesnotgeneralize.Themodelisoverﬁtting.Thebesthyper-parametervalueθisthereforetheonemakingtheappropriatetrade-offandproducingamodelwhichisneithertoosimplenortocom-plex,asshownbythegraylineontheﬁgure.AswewillseelaterinChapter4,overﬁttingcanalsobeexplainedbydecomposingthegeneralizationerrorintermsofbiasandvari-ance.Amodelwhichistoosimpleusuallyhashighbiasbutlowvariance,whileamodelwhichistoocomplexusuallyhaslowbiasbuthighvariance.Inthoseterms,ﬁndingthebestmodelamountstomaketheappropriatebias-variancetrade-off.2.3.2SelectingandevaluatingsimultaneouslyOnrealapplications,andinparticularwhenreportingresults,itusu-allyhappensthatonewantstodobothmodelselectionandmodelassessment.Thatis,havingchosenaﬁnalmodelA(bθ∗,L),onewantstoalsoestimateitsgeneralizationerror.AnaiveassessmentofthegeneralizationerroroftheselectedmodelmightbetosimplyusethetestsampleestimatedErrtest(A(bθ∗,L))(i.e.,E(A(bθ∗,Ltrain),Ltest))thatwasminimizedduringmodelselection.The2.3modelselection19issuewiththisestimateisthatthelearnedmodelisnotindependentfromLtestsinceitsrepeatedconstructionwaspreciselyguidedbytheminimizationofthepredictionerroroverLtest.Asaresult,themin-imizedtestsampleerrorisinfactabiased,optimistic,estimateofthetruegeneralizationerror,sometimesleadingtosubstantialunder-estimations.Forthesamereasons,usingtheK-foldcross-validationestimatedoesnotprovideabetterestimatesincemodelselectionwassimilarlyguidedbytheminimizationofthisquantity.Toguaranteeanunbiasedestimate,thetestsetonwhichthegen-eralizationerrorisevaluatedshouldideallybekeptoutoftheentiremodelselectionprocedureandonlybeusedoncetheﬁnalmodelisselected.Algorithm2.1detailssuchaprotocol.Similarly,per-foldes-timatesofthegeneralizationerrorshouldbekeptoutofthemodelselectionprocedure,forexampleusingnestedcross-validationwithineachfold,asexplicitedinAlgorithm2.2.Algorithm2.1.Train-Valid-Testsetprotocolforbothmodelselectionandevaluation.(a)DividethelearningsetLintothreepartsLtrain,LvalidandLtest;(b)PerformmodelselectiononLtrain∪Lvalidusingtestsampleestimates,i.e.,ﬁnd:bθ∗=argminθdErrtest(A(θ,Ltrain∪Lvalid))(2.17)=argminθE(A(θ,Ltrain),Lvalid);(2.18)(c)Evaluatethe(unbiased)generalizationerroroftheﬁnalmodelasE(A(bθ∗,Ltrain∪Lvalid),Ltest);(2.19)(d)LearntheﬁnalmodelA(bθ∗,L)ontheentirelearningset.Algorithm2.2.NestedK-foldcross-validationprotocolforbothmodelse-lectionandevaluation.(a)DividethelearningsetLintoKfoldsL1,...,LK;(b)Foreachfoldk=1,...,K:i.DivideL\Lk=L−kintoKfoldsL−k1,...,L−kK;ii.PerformmodelselectiononthesubsetL−kusingnestedK-foldestimates,i.e.,ﬁnd:bθ∗k=argminθdErrCV(A(θ,L−k))(2.20)=argminθ1KKXl=1E(A(θ,L−k\L−kl),L−kl);(2.21)20backgroundiii.Evaluatethegeneralizationerroroftheselectedsub-modelasE(A(bθ∗k,L\Lk),Lk);(2.22)(c)Evaluatethe(unbiased)generalizationerroroftheselectedmodelastheaveragegeneralizationestimateofthesub-modelsselectedoverthefolds:1KKXk=1E(A(bθ∗k,L\Lk),Lk);(2.23)(d)PerformmodelselectionontheentirelearningsetLusingK-foldcross-validationestimates,i.e.,ﬁnd:bθ∗=argminθdErrCV(A(θ,L))(2.24)=argminθ1KKXk=1E(A(θ,L\Lk),Lk);(2.25)(e)LearntheﬁnalmodelA(bθ∗,L)ontheentirelearningset.2.4classesoflearningalgorithmsBeforeproceedinginthenextchapters,andfortherestofthiswork,toanin-depthanalysisoftheclassoftree-basedmethods,webrieﬂyreviewinthissectionsomeoftheotherlearningalgorithmsthathavematuredintheﬁeld,includinglinearmethods,supportvectorma-chines,neuralnetworksandnearestneighbormethods.2.4.1LinearmethodsOneoftheoldestclassofsupervisedlearningalgorithmsistheclassoflinearmethodsfromtheﬁeldofstatistics.Inthesemethods,thecentralassumptionmadeonHisthattheoutputvariableYcanbedescribedasalinearcombinationoftheinputvariablesX1,...,Xp(i.e.,asanhyperplane),oratleastthatthelinearmodelisareasonableapproximation.Forregression,Hincludesallmodelsϕoftheform:ϕ(x)=b+pXj=1xjwj(2.26)Forbinaryclassiﬁcation(i.e.,whenY={c1,c2}),Hincludesallmod-elsϕoftheform:ϕ(x)=c1ifb+Ppj=1xjwj>0c2otherwise(2.27)2.4classesoflearningalgorithms21Figure2.2:Agoodseparatinghyperplaneisanhyperplanethatmaximizesthedistancetothenearesttrainingdatapoints.Linearmethodscomeinmanyﬂavorsbutmostlydifferfromeachotherinthewaytheyestimatethecoefﬁcientsbandwj(forj=1,...,p),usuallyusingsomespeciﬁcoptimizationproceduretomin-imizeaspeciﬁccriterion.Amongallofthem,themostfamousisthemethodofleastsquares.Itconsistsinﬁndingthebandwjcoefﬁcientsthatminimizetheresubstitutionestimate(Equation2.5)usingthesquarederrorloss.Despiteanapparentsimplicity,linearmethodsoftenprovidereli-ablepredictionsandaninterpretabledescriptionofhowtheinputvariablesaffecttheoutput.Contrarytotheirname,linearmethodscanalsobeusedtomodelnon-linearrelationsbetweenXandY,forexamplebyapplyingthesemethodson(non-linear)transformationsoftheinputvariables.Formoredetailson(generalized)linearmeth-ods,seethereviewsofMacCullaghandNelder[1989],Hastieetal.[2005],BishopandNasrabadi[2006]orDudaetal.[2012].2.4.2SupportvectormachinesWhendatapointsfromthelearningsetarelinearlyseparable,thereexistseveralhyperplanes(i.e.,severallinearmodels)thatareinfactequallyasgoodwhenevaluatedinresubstitution.Ingeneralizationhowever,thesehyperplanesareusuallynotequivalent.AsillustratedinFigure2.2,agoodseparationisintuitivelyachievedwhenthedis-tance(alsoknownasthemargin)tothenearesttrainingdatapointsisaslargeaspossible,sinceingeneralthelargerthemarginthelowerthegeneralizationerrorofthemodel.22backgroundMathematically,supportvectormachines[Boseretal.,1992;CortesandVapnik,1995]aremaximum-marginlinearmodelsoftheformofEquation2.27.AssumingwithoutlossofgeneralitythatY={−1,1}andthatb=0,supportvectormachinesarelearnedbysolvingthefollowingprimaloptimizationproblem:minw,ξ(cid:14)12kwk2+CNXi=1ξi(cid:15)(2.28)subjecttoyi(w·xi)>1−ξi,ξi>0.(2.29)Initsdualtheform,theoptimizationproblemismaxαNXi=1αi−12Xi,jαiαjyiyjxi·xj(2.30)subjectto06αi6C,(2.31)whereCisanhyper-parameterthatcontrolsthedegreeofmisclassi-ﬁcationofthemodel,incaseclassesarenotlinearlyseparable.Fromthesolutionofdualproblem,wehavew=NXi=1αiyixi,(2.32)fromwhichtheﬁnallinearmodelcanﬁnallybeexpressed.Supportvectormachinesextendtonon-linearclassiﬁcationbypro-jectingtheoriginalinputspaceintoahigh-dimensionalspace(theso-calledkerneltrick),whereaseparatinghyperplanecanhopefullybefound.Interestingly,thedualoptimizationproblemisexactlythesame,exceptthatthedotproductxi·xjisreplacedbyakernelK(xi,xj),whichcorrespondsthedotproductofxiandxjinthenewspace.2.4.3NeuralnetworksThefamilyofneuralnetworksmethodsﬁndsitsoriginsinattemptstoidentifymathematicalrepresentationsofinformationprocessinginbiologicalsystems.Whilethisobjectiveisstillfarfrombeingreached,(artiﬁcial)neuralnetworkshavenonethelessprovenalltheirworthfromastatisticalpointofview,andhaveactuallygrownintooneofthemosteffectivemethodsinmachinelearning.Aneuralnetworkisusuallymadeofseveralunits,alsoknownasneurons,oftheformhj(x)=σ(wj+nXi=1wijxi),(2.33)2.4classesoflearningalgorithms23wijx1x2x3h1h2h3h4h5ˆyFigure2.3:Anartiﬁcialneuralnetwork.whereσisanon-linearactivationfunction,suchasthesignfunc-tion,thesigmoidfunctionorthesoftmaxactivation.Inmostcases,theseunitsarestructuredintosuccessivelayers,wheretheoutputsofalayeraredirectedthroughweightedconnections,alsoknownassynapses,totheinputsofthenextlayer.Asanexample,Figure2.3illustratesathreelayeredneuralnetwork.Theﬁrstlayeristheinputlayer,whichtransmitstheinputvaluesx=(x1,...,xp)tothesecondlayer.Thesecondlayerismadeofactivationunitshj,takingasin-putstheweightedvaluesoftheinputlayerandproducingnon-lineartransformationsasoutputs.Thethirdlayerismadeofasingleactiva-tionunit,takingasinputstheweightedoutputsofthesecondlayerandproducingthepredictedvalueˆy.Assumingthatthisstructureisﬁxedandthatallunitsfromthenetworkmakeuseofthesameactiva-tionfunctionσ,thehypothesisspaceHthereforeincludesallmodelsϕoftheformϕ(x)=σ(w5+4Xj=1wj5σ(wj+pXi=1wijxi)).(2.34)Asforlinearmethods,learninganeuralnetworkamountstoesti-matetheweightswijthatminimizesomespeciﬁclossfunction,usingsomespeciﬁcoptimizationprocedure.Amongallofthem,themostfamousisthebackpropagationalgorithm[Bryson,1975].Recentadvancesonneuralnetworks,nowthemedasdeeplearning,haverecentlyshownthecapabilityofthesemodelstoautonomouslylearnhigh-levelandveryeffectiverepresentationsofdata.Onvari-ousdifﬁculttasks,suchasimageclassiﬁcationorspeechrecognition,neuralnetworkshaveindeedachievedoutstandingperformance,out-performingbothhumanoperatorsandstate-of-the-artmethods.Fromatheoreticalpointofviewhowever,littleisstillknownaboutwhatmakesthemtrulywork.Inparticular,pickingtheappropriatecom-binationofnumberofunits,layersandtypesofactivationfunctionsremainsadelicatetask,whichunfortunatelymakes(deep)neuralnet-worksstilldifﬁculttousefornon-experts.Reviewsonrecentdevelop-mentsincludetheworksofHinton[2007],Areletal.[2010]orBengioetal.[2013].24background2.4.4NearestneighbormethodsNearestneighbormethodsbelongtoaclassofnon-parametricalgo-rithmsknownasprototypemethods[Hastieetal.,2005].Theydis-tinguishfromotherlearningalgorithmsinthesensethattheyarememory-basedandrequirenomodeltobeﬁt.Theprinciplebehindnearestneighbormethodsistoﬁndanumberoftrainingsamplesclosestindistancetothenewsample,andtheninferfromthesethevalueoftheoutputvariable.Forregression,thek-nearestneighboralgorithm[FixandHodges,1951]averagestheoutputvaluesfromthekclosesttrainingsamples,thatis:ϕ(x)=1kX(xi,yi)∈NN(x,L,k)yi,(2.35)whereNN(x,L,k)denotestheknearestneighborsofxinL.Forclas-siﬁcation,theprocedureisthesameexceptthatthepredictedoutputvalueiscomputedasthemajorityclassamongtheknearestneigh-bors:ϕ(x)=argmaxc∈YX(xi,yi)∈NN(x,L,k)1(yi=c).(2.36)Ingeneral,thedistancefunctionusedtoidentifytheknearestneigh-borscanbeanymetric,butthestandardEuclideandistanceisthemostcommonchoice.Anotablevariantistheradius-basedneighboralgorithm,inwhichthepredictedoutputvalueiscomputedfromthetrainingsampleswithinaradiusrofthenewsample.Incaseswheredataisnotuniformlysampled,thislatteralgorithmcanbeabetterchoicethanthek-nearestneighbormethod.Despitetheirsimplicity,nearestneighbormethodsusuallyyieldde-centresultsinpractice.Theyareareoftensuccessfulinclassiﬁcationsituationswherethedecisionboundaryisveryirregular.Fromatheo-reticalpointofview,animportantresultduetoCoverandHart[1967]istheproofofconsistencyofthemethod.WhenthesizeofLtendstoinﬁnityandkisappropriatelyadjustedtoL,thegeneralizationerrorofthemodelproducedbythek-nearestneighbormethodisshowntoconvergetowardsthegeneralizationerroroftheBayesmodel.3CLASSIFICATIONANDREGRESSIONTREESOutlineInthischapter,wepresentauniﬁedframeworkinwhichwede-tail(single)decisiontreesmethods.InSection3.1,weﬁrstgiveanoverviewofthecontextinwhichthesealgorithmshavebeendevel-oped.InSection3.2,weproceedwithamathematicalpresentation,introducingallnecessaryconceptsandnotations.Thegenerallearn-ingalgorithmisthenpresentedinSection3.3whilespeciﬁcpartsofthealgorithmarediscussedinﬁnerdetailsinSections3.4,3.5,3.6.Assuch,speciﬁcdecisiontreealgorithms(e.g.,CART,ID3orC4.5)aredescribedasspecializationsofthegeneralframeworkpresentedhere.3.1introductionSincealways,artiﬁcialintelligencehasbeendrivenbytheambitiontounderstandanduncovercomplexrelationsindata.Thatis,toﬁndmodelsthatcannotonlyproduceaccuratepredictions,butalsobeusedtoextractknowledgeinanintelligibleway.Guidedwiththistwofoldobjective,researchinmachinelearninghasgivenrisetoex-tensivebodiesofworksinamyriadofdirections.Amongallofthemhowever,tree-basedmethodsstandasoneofthemosteffectiveandusefulmethod,capabletoproducebothreliableandunderstandableresults,onmostlyanykindofdata.Historically,theappearanceofdecisiontreesisduetoMorganandSonquist[1963],whoﬁrstproposedatree-basedmethodcalledauto-maticinteractiondetector(AID)forhandlingmulti-variatenon-additiveeffectsinthecontextofsurveydata.BuildinguponAID,methodolog-icalimprovementsandcomputerprogramsforexploratoryanalysiswerethenproposedinthefollowingyearsbyseveralauthors[Son-quist,1970;MessengerandMandell,1972;Gillo,1972;Sonquistetal.,1974].Withoutcontesthowever,theprincipalinvestigatorsthathavedrivenresearchonthemodernmethodologicalprinciplesareBreiman[1978a,b],Friedman[1977,1979]andQuinlan[1979,1986]whosimul-taneouslyandindependentlyproposedveryclosealgorithmsfortheinductionoftree-basedmodels.Mostnotably,theunifyingworkofBreimanetal.[1984],latercomplementedwiththeworkofQuinlan[1993],havesetdecisiontreesintoasimpleandconsistentmethod-ologicalframework,whichlargelycontributedinmakingthemeasytounderstandandeasytousebyalargeaudience.2526classificationandregressiontreesAswewillexploreinfurtherdetailsallthroughoutthiswork,thesuccessofdecisiontrees(andbyextension,ofalltree-basedmeth-ods)isexplainedbyseveralfactorsthatmakethemquiteattractiveinpractice:-Decisiontreesarenon-parametric.Theycanmodelarbitrarilycomplexrelationsbetweeninputsandoutputs,withoutanyaprioriassumption;-Decisiontreeshandleheterogeneousdata(orderedorcategori-calvariables,oramixofboth);-Decisiontreesintrinsicallyimplementfeatureselection,makingthemrobusttoirrelevantornoisyvariables(atleasttosomeextent);-Decisiontreesarerobusttooutliersorerrorsinlabels;-Decisiontreesareeasilyinterpretable,evenfornon-statisticallyorientedusers.Mostimportantly,decisiontreesareatthefoundationofmanymodernandstate-of-the-artalgorithms,includingforestsofrandom-izedtrees(onwhichthisworkisabout,seeChapter4)orboostingmethods[FreundandSchapire,1995;Friedman,2001],wheretheyareusedasbuildingblocksforcomposinglargermodels.Understandingallalgorithmicdetailsofsingledecisiontreesisthereforeamanda-toryprerequisiteforanin-depthanalysisofthesemethods.3.2treestructuredmodelsWhentheoutputspaceisaﬁnitesetofvalues,likeinclassiﬁcationwhereY={c1,c2,...,cJ},anotherwayoflookingatasupervisedlearn-ingproblemistonoticethatYdeﬁnesapartitionovertheuniverseΩ,thatisΩ=Ωc1∪Ωc2∪···∪ΩcJ,(3.1)whereΩckistheofsetobjectsforwhichYhasvalueck.Similarly,aclassiﬁerϕcanalsoberegardedasapartitionoftheuniverseΩsinceitdeﬁnesanapproximationbYofY.ThispartitionhoweverisdeﬁnedontheinputspaceXratherthatdirectlyonΩ,thatisX=Xϕc1∪Xϕc2∪...∪XϕcJ,(3.2)whereXϕckisthesetofdescriptionvectorsx∈Xsuchthatϕ(x)=ck.Accordingly,learningaclassiﬁercanberestatedaslearningaparti-tionofXmatchingascloselyaspossiblethebestpossiblepartition,i.e.,theoneengenderedbytheBayesmodelϕBoverX:X=XϕBc1∪XϕBc2∪...∪XϕBcJ.(3.3)3.2treestructuredmodels27PartitioningwithnoiseNoticethatwhenYcannotbeunivocallydeterminedgivenX=x,e.g.,whenthereisnoiseonY,thentheremayexisttwodistinctobjectsfromtheuniverseΩsuchthattheirrepresentationsx1andx2intheinputspaceareequal,yetsuchthatthecorrespondingoutputvaluesy1andy2aredifferent.Inotherwords,thesubsetsXΩck={xi|i∈Ω,Y=ck}(3.4)maynotbedisjoint.Bycontrast,sinceϕdeﬁnesafunctionfromXtoY,anyinputx∈Xismappedtoexactlyoneoutputvaluey∈YandthesubsetsXϕckarethereforenecessarilydisjoint,whichmeansthatnomodelwilleverperfectlypredictthetrueoutputvalueinallcases.AsdiscussedinSection2.2.2,thislimitationisunavoidableandcaninfactbeviewedasthecauseoftheresidualerror.Fromageometricalpointofview,theprincipleoftreestructuredmodelsisbeautifullysimple.Itconsistsinapproximatingtheparti-tionoftheBayesmodelbyrecursivelypartitioningtheinputspaceXintosubspacesandthenassignconstantpredictionvaluesby∈Ytoallobjectsxwithineachterminalsubspace.Tomakethingsclearer,letusﬁrstdeﬁnethefollowingconcepts:Deﬁnition3.1.AtreeisagraphG=(V,E)inwhichanytwovertices(ornodes)areconnectedbyexactlyonepath.Deﬁnition3.2.Arootedtreeisatreeinwhichoneofthenodeshasbeendesignatedastheroot.Inourcase,weadditionallyassumethatarootedtreeisadirectedgraph,wherealledgesaredirectedawayfromtheroot.Deﬁnition3.3.Ifthereexistsanedgefromt1tot2(i.e.,if(t1,t2)∈E)thennodet1issaidtobetheparentofnodet2whilenodet2issaidtobeachildofnodet1.Deﬁnition3.4.Inarootedtree,anodeissaidtobeinternalifithasoneormorechildrenandterminalifithasnochildren.Terminalnodesarealsoknownasleaves.Deﬁnition3.5.Abinarytreeisarootedtreewhereallinternalnodeshaveexactlytwochildren.Inthoseterms,atree-structuredmodel(ordecisiontree)canbedeﬁnedasamodelϕ:X7→Yrepresentedbyarootedtree(oftenbinary,butnotnecessarily),whereanynodetrepresentsasubspaceXt⊆Xoftheinputspace,withtherootnodet0correspondingtoXitself.Inter-nalnodestarelabeledwithasplitsttakenfromasetofquestionsQ.ItdividesthespaceXtthatnodetrepresentsintodisjointsubspacesrespectivelycorrespondingtoeachofitschildren.Forinstance,thesetofallbinarysplitsisthesetQofquestionssoftheform“Does28classificationandregressiontreest0t1t2t3t4X1≤0.7X2≤0.5c2c2c1Figure3.1:AdecisiontreeϕbuiltforabinaryclassiﬁcationproblemfromaninputspaceX=[0,1]×[0,1].(FigureinspiredfromBreimanetal.[1984].)x∈XA?”,whereXA⊂Xissomesubsetoftheinputspace.AnysplitsofthisformdividesXtintotwosubspacesrespectivelycorrespond-ingtoXt∩XAfortheleftchildoftandtoXt∩(X\XA)fortherightchildoft.Terminalnodesarelabeledwithabestguessvaluebyt∈Yoftheoutputvariable.Ifϕisaclassiﬁcationtree,thenbyt∈{c1,...,cJ}whileifϕisaregressiontree,thenbyt∈R.Assuch,thepredictedoutputvalueϕ(x)isthelabeloftheleafreachedbytheinstancexwhenitispropagatedthroughthetreebyfollowingthesplitsst(seeAlgorithm3.1).Algorithm3.1.Predictionoftheoutputvalueby=ϕ(x)inadecisiontree.1:functionPredict(ϕ,x)2:t=t03:whiletisnotaterminalnodedo4:t=thechildnodet0oftsuchthatx∈Xt05:endwhile6:returnbyt7:endfunctionAsanexample,Figure3.1illustratesadecisiontreeϕmadeofﬁvenodesandpartitioningtheinputspaceX=X1×X2=[0;1]×[0;1]forabinaryclassiﬁcationproblem(whereY={c1,c2}).Nodet0istherootnodeandcorrespondstothewholeinputspaceXt0=X.ItislabeledwiththebinarysplitX160.7(i.e.,thequestion“IsX160.7?”)whichdividesXt0intotwodisjointsubsetsXt1∪Xt2.Theﬁrstsetcorrespondstoitsleftchildt1andrepresentsthesetofallinputvectorsx∈X0suchthatx160.7.Similarly,thesecondsetcorrespondstoitsrightchildt2andrepresentsthesetofallinputvectorsx∈Xt0suchthatx1>0.7.Likewise,t1islabeledwiththesplitX260.5whichfurtherdividesXt1intotwodisjointsubsetsXt3∪Xt4respectivelycorrespondingtothesetsofallinputvectorsx∈Xt1suchthatx260.5andx2>0.5.Terminalnodest2,t3andt4arerepresentedbysquareslabeledwithanoutputvaluebyt.Theyformtogetherapartition(asdeﬁnedbyEquation3.2)ofX,whereeachsetXϕckisobtainedfromtheunionofthesubspacesXtofall3.3inductionofdecisiontrees29t2t3t40.70.5X1X2Figure3.2:PartitionofXinducedbythedecisiontreeϕintohomogeneoussubspaces.Bluedotscorrespondtoobjectsofclassc1whilereddotscorrespondtoobjectsofclassc2.(FigureinspiredfromBreimanetal.[1984].)terminalnodestsuchthatbyt=ck.Inthiscase,Xϕc1=Xt4whileXϕc2=Xt2∪Xt3.AsshowninFigure3.2,thepartitioninducedbyϕonXdividestheinputspaceintosubspacesthataremoreandmoreclasshomogeneous,startingfromXattherootnode,thenXt1∪Xt2atthesecondleveloftreeandﬁnally(Xt3∪Xt4)∪Xt2attheleaves.AswewillexploreinSection3.6,thepartitionisinthiscasemadeofrectanglesbecauseofthenatureofthesplitsst∈Qdividingthenodes.Predictionsaremadebypropagatinginstancesthroughthetreeandusingasoutputvaluethevaluelabelingtheterminalnodesinwhichtheyfallinto.Forexample,asshowninblueinFigure3.1,anobjectx=(x1=0.2,x2=0.7)fallsintot4andthereforeϕ(x)=byt4=c1.Finally,letusnotethatfromagraphtheorypointofview,deci-siontreesbelongtoalargerfamilyofmethodsknownasinductiongraphs[ZighedandRakotomalala,2000].Inthismoregeneralframe-work,thestructureisadirectedacyclicgraph,whichallowsfornodestobebothdividedandrecombined.3.3inductionofdecisiontreesLearningadecisiontreeideallyamountstodeterminethetreestruc-tureproducingthepartitionwhichisclosesttothepartitionengen-deredbyYoverX.Sinceitisunknown,theconstructionofadecisiontreeisusuallydriveninsteadwiththeobjectiveofﬁndingamodel30classificationandregressiontreeswhichpartitionsthelearningsetLaswellaspossible.Amongalldecisiontreesϕ∈Hhowever,theremayexistseveralofthemthatexplainLequallybest.FollowingOccam’sRazorprinciples[Blumeretal.,1987]ofpreferringtheexplanationwhichmakesasfewassump-tionsaspossible,thatistofavorthesimplestsolutionthatﬁtsthedata,learningadecisiontreefromListhereforeusuallyrestatedasﬁnd-ingthesmallesttreeϕ∗(intermsofinternalnodes)minimizingitsresubstitutionestimateE(ϕ∗,L).Whilethisassumptionmakessensefromageneralizationpointofview,italsomakessenseregardingin-terpretability.Adecisiontreewhichissmalliseasiertounderstandthanalargeandcomplextree.AsshownbyHyaﬁlandRivest[1976],ﬁndingthesmallesttreeϕ∗thatminimizesitsresubstitutionestimateisanNP-completeproblem.Asaconsequence,undertheassumptionthatP6=NP,thereexistsnoefﬁcientalgorithmforﬁndingϕ∗,therebysuggestingthatﬁnd-ingefﬁcientheuristicsforconstructingnear-optimaldecisiontreesisthebestsolutiontokeepcomputationrequirementswithinrealisticboundaries.FollowingtheframeworkofBreimanetal.[1984],letusbroadlydeﬁneanimpuritymeasurei(t)asafunctionthatevaluatesthegood-nessofanynodet(wedelaytoSection3.6foramoreprecisedeﬁ-nition).Letassumethatthesmalleri(t),thepurerthenodeandthebetterthepredictionsbyt(x)forallx∈Lt,whereLtisthesubsetoflearningsamplesfallingintot,thatisall(x,y)∈Lsuchthatx∈Xt.StartingfromasinglenoderepresentingthewholelearningsetL,near-optimaldecisiontreescanthenbegrowngreedilybyiterativelydividingnodesintopurernodes.Thatis,byiterativelydividingintosmallersubsetsthesubsetsofLrepresentedbythenodes,untilallter-minalnodescannotbemadepurer,henceguaranteeingnear-optimalpredictionsoverL.Thegreedyassumptiontomaketheresultingtreeassmallaspossible,therebyseekingforgoodgeneralization,isthentodivideeachnodetusingthesplits∗thatlocallymaximizesthedecreaseofimpurityoftheresultingchildnodes.Formally,thedecreaseofimpurityofabinarysplitsisdeﬁnedasfollows:Deﬁnition3.6.Theimpuritydecreaseofabinarysplits∈QdividingnodetintoaleftnodetLandarightnodetRis∆i(s,t)=i(t)−pLi(tL)−pRi(tR)(3.5)wherepL(resp.,pR)istheproportionNtLNt(resp.,NtRNt)oflearningsamplesfromLtgoingtotL(resp.,totR)andwhereNtisthesizeofthesubsetLt.Onthebasisofthisconcept,ageneralgreedyprocedurefortheinductionofdecisiontreescannowbedescribedformallyasoutlinedinAlgorithm3.2.Notethatforthesakeofclarity,Algorithm3.2isformulatedintermsofbinarysplits.However,aswewillexplorelaterinSection3.6,itgeneralizesnaturallyton-arymultiwaysplits.3.3inductionofdecisiontrees31Algorithm3.2.Greedyinductionofabinarydecisiontree.1:functionBuildDecisionTree(L)2:Createadecisiontreeϕwithrootnodet03:CreateanemptystackSofopennodes(t,Lt)4:S.push((t0,L))5:whileSisnotemptydo6:t,Lt=S.pop()7:ifthestoppingcriterionismetfortthen8:byt=someconstantvalue9:else10:FindthesplitonLtthatmaximizesimpuritydecreases∗=argmaxs∈Q∆i(s,t)11:PartitionLtintoLtL∪LtRaccordingtos∗12:CreatetheleftchildnodetLoft13:CreatetherightchildnodetRoft14:S.push((tR,LtR))15:S.push((tL,LtL))16:endif17:endwhile18:returnϕ19:endfunctionTherestofthischapterisnowdedicatedtoadetaileddiscussionofspeciﬁcpartsofAlgorithm3.2.Section3.4discussesassignmentrulesforterminalnodes(Line8ofAlgorithm3.2)whileSection3.5outlinesstoppingcriteriafordecidingwhenanodebecomesterminal(Line7ofAlgorithm3.2).Section3.6thenpresentsfamiliesQofsplittingrules,impuritycriteriai(t)toevaluatethegoodnessofsplitsandstrategiesforﬁndingthebestsplits∗∈Q(Line10ofAlgorithm3.2).Aswewillsee,thecruxoftheproblemisinﬁndinggoodsplitsandinknowingwhentostopsplitting.LookaheadsearchObviously,thegreedyassumptiononwhichAlgorithm3.2reliesmayproducetreesthataresuboptimal.Anaturalimprovementofthegreedystrategyislookaheadsearch,whichconsistsinevaluatingthegoodnessofasplit,butalsoofthosedeeperinthetree,assumingthisformersplitwaseffectivelyperformed.Asempiricallyinvestigatedin[MurthyandSalzberg,1995],suchanapproachishowevernotonlymorecomputationallyintensive,itisalsonotsigniﬁcantlybetterthangreedilyinduceddecisiontrees.Forthisreason,moreelaboratevari-antsofAlgorithm3.2arenotconsideredwithinthiswork.Letusnotehoweverthattreesgrownwithlookaheadsearchareusuallyshorter,whichmaybeastrongadvantagewheninterpretabilitymatters.32classificationandregressiontrees3.4assignmentrulesLetusassumethatnodethasbeendeclaredterminalgivensomestoppingcriterion(SeenextSection3.5).Thenextstep(Line8ofAlgorithm3.2)intheinductionprocedureistolabeltwithaconstantvaluebyttobeusedasapredictionoftheoutputvariableY.Assuch,nodetcanberegardedasasimplisticmodeldeﬁnedlocallyonXt×Yandproducingthesameoutputvaluebytforallpossibleinputvectorsfallingintot.Letusﬁrstnoticethat,foratreeϕofﬁxedstructure,minimizingtheglobalgeneralizationerrorisstrictlyequivalenttominimizingthelocalgeneralizationerrorofeachsimplisticmodelintheterminalnodes.Indeed,Err(ϕ)=EX,Y{L(Y,ϕ(X))}=Xt∈eϕP(X∈Xt)EX,Y|t{L(Y,byt)}(3.6)whereeϕdenotesthesetofterminalnodesinϕandwheretheinnerexpectation1isthelocalgeneralizationerrorofthemodelatnodet.Inthislaterform,amodelwhichminimizesErr(ϕ)isamodelwhichminimizestheinnerexpectationleaf-wise.Learningthebestpossibledecisiontree(ofﬁxedstructure)thereforesimplyamountstoﬁndthebestconstantsbytateachterminalnode.3.4.1ClassiﬁcationWhenListhezero-oneloss,theinnerexpectationinEquation3.6isminimizedbythepluralityrule:by∗t=argminc∈YEX,Y|t{1(Y,c)}=argminc∈YP(Y6=c|X∈Xt)=argmaxc∈YP(Y=c|X∈Xt)(3.7)Putotherwise,thegeneralizationerroroftisminimizedbypredict-ingtheclasswhichisthemostlikelyforthesamplesinthesubspaceoft.Notethatifthemaximumisachievedbytwoormoredifferentclasses,thenby∗tisassignedarbitrarilyasanyoneofthemaximizingclasses.Equation3.7cannotbesolvedwithouttheprobabilitydistributionP(X,Y).However,itssolutioncanbeapproximatedbyusingestimatesofthelocalgeneralizationerror.LetNtdenotesthenumberofobjectsinLtandletNctdenotesthenumberofobjectsofclasscinLt.Then,theproportionNctNtcanbeinterpretedastheestimatedprobability21ThejointexpectationofXandYistakenoverallobjectsi∈Ωsuchthatxi∈Xt.2LowercasepdenotesanestimatedprobabilitywhileuppercasePdenotesatheoret-icalprobability.3.4assignmentrules33p(Y=c|X∈Xt)(shortlydenotedp(c|t))ofclasscintandthereforebeusedtosolveEquation3.7:byt=argminc∈Y1−p(c|t)=argmaxc∈Yp(c|t)(3.8)Similarly,letusalsodeﬁnetheproportionNtNastheestimatedprob-abilityp(X∈Xt)(shortlydenotedp(t)).PluggingthisestimateintoEquation3.6andapproximatingthelocalgeneralizationerrorwith1−p(byt|t)asdoneabove,itfollows:dErr(ϕ)=Xt∈eϕp(t)(1−p(byt|t))=Xt∈eϕNtN(1−NbyttNt)=1NXt∈eϕNt−Nbytt=1NXt∈eϕXx,y∈Lt1(y6=byt)=1NXx,y∈L1(y6=ϕ(x))=dErrtrain(ϕ)(3.9)Accordingly,approximatingEquation3.6throughlocalprobabilityestimatescomputedfromclassproportionsinLtreducestothere-substitutionestimateofϕ(Equation2.5).Inotherwords,assignmentrule3.8infactminimizestheresubstitutionestimateratherthanthetruegeneralizationerror.Animportantpropertyofassignmentrule3.8isthatthemoreonesplitsaterminalnodeinanyway,thesmallertheresubstitutionesti-matedErrtrain(ϕ)becomes.Proposition3.1.Foranynon-emptysplitofaterminalnodet∈eϕintotLandtR,resultinginanewtreeϕ0wherebytLandbytRareassignedwithrule3.8,dErrtrain(ϕ)>dErrtrain(ϕ0)withequalityifbyt=bytL=bytR.Proof.dErrtrain(ϕ)>dErrtrain(ϕ0)Xt∈eϕp(t)(1−p(byt|t))>Xt∈fϕ0p(t)(1−p(byt|t))p(t)(1−p(byt|t))>p(tL)(1−p(bytL|tL))+p(tR)(1−p(bytR|tR))34classificationandregressiontreesNtN(1−maxc∈YNctNt)>NtLN(1−maxc∈YNctLNtL)+NtRN(1−maxc∈YNctRNtR)Nt−maxc∈YNct>NtL−maxc∈YNctL+NtR−maxc∈YNctRmaxc∈YNct6maxc∈YNctL+maxc∈YNctRmaxc∈Y(NctL+NctR)6maxc∈YNctL+maxc∈YNctRwhichistruesincemaxc∈YNctL(resp.,tR)isnecessarilygreaterorequaltothelefttermNctL(resp.,torighttermNctR)intheleft-handsideoftheequation.Equalityholdsifthemajorityclassesarethesameint,tLandtR.AsacorollaryofProposition3.1,theresubstitutionestimateismin-imalwhenterminalnodescannolongerbedivided.Inparticular,itisequaltozeroifthetreecanbefullydeveloped,thatisifterminalnodescanbedivideduntiltheyallcontainexactlyoneobjectfromL.Basedonthisresult,wewillshowhoweverinSection3.6.2whyusingtheresubstitutionestimatetoevaluatethegoodnessofasplitshasseriousdefectsforclassiﬁcation.3.4.2RegressionWhenListhesquarederrorloss,theinnerexpectationinEquation3.6isminimizedbytheexpectationofYint:by∗t=argminby∈YEX,Y|t{(Y−by)2}=EX,Y|t{Y}(3.10)Again,Equation3.10cannotbesolvedwithouttheprobabilitydis-tributionP(X,Y).However,itssolutioncanapproximatedusingesti-matesofthelocalgeneralizationerror:byt=argminby∈L1NtXx,y∈Lt(y−by)2=1NtXx,y∈Lty(3.11)Asinclassiﬁcation,usingp(t)asestimateofP(X∈Xt)andap-proximatingthelocalgeneralizationerrorwith1NtPx,y∈Lt(y−byt)2asdoneabove,onecanshowthatEquation3.6reducestotheresub-stitutionestimateofϕ,therebyindicatingthatassignmentrule3.11alsominimizesthetrainingerrorratherthetruegeneralizationerror.Mostimportantly,onecanalsoshowthatassignmentrule3.11be-havesinthesamewayas3.8.Themoreonesplitsaterminalnodeinanyway,thesmallertheresubstitutionestimatedErrtrain(ϕ)becomes.3.5stoppingcriteria35Proposition3.2.Foranynon-emptysplitofaterminalnodet∈eϕintotLandtR,resultinginanewtreeϕ0wherebytLandbytRareassignedwithrule3.11,dErrtrain(ϕ)>dErrtrain(ϕ0)withequalityifbytL=bytR=byt.Proof.dErrtrain(ϕ)>dErrtrain(ϕ0)Xt∈eϕp(t)(1NtXx,y∈Lt(y−byt)2)>Xt∈fϕ0p(t)(1NtXx,y∈Lt(y−byt)2)Xx,y∈Lt(y−byt)2>Xx,y∈LtL(y−bytL)2+Xx,y∈LtR(y−bytR)2Ntby2t6NtLby2tL+NtRby2tR1Nt(Xx,y∈Lty)261NtL(Xx,y∈LtLy)2+1NtR(Xx,y∈LtRy)2Forsimplifying,letusdenotes(t)=Px,y∈Lty=Ntbytthesumoftheoutputvaluesint.Remarkthats(t)=s(tL)+s(tR).Itcomes:s(t)2Nt6s(tL)2NtL+s(tR)2NtR(s(tL)+s(tR))2NtL+NtR6s(tL)2NtL+s(tR)2NtR(s(tL)NtR−s(tR)NtL)2NtLNtR(NtL+NtR)>0Whichisnecessarytruesincethenumeratorisnon-negativeandthedenominatorisstrictlypositive.Equalityholdsifs(tL)NtR=s(tR)NtL,thatisifbytL=bytR.AsforProposition3.1,acorollaryofProposition3.2isthattheresubstitutionestimateisminimalwhenterminalnodescannolongerbedivided.3.5stoppingcriteriaAswehaveshownthroughPropositions3.1and3.2,thedeeperade-cisiontree,thesmalleritstrainingestimate,andthebetterwethinkitis.AsdiscussedinSection2.3however,increasingmodelcomplex-ity,inthiscasebyenlargingthesetofterminalnodes,islikelytoeventuallycapturenoiseinthelearningsetandtocauseoverﬁtting.Inotherwords,itisnotbecausethetrainingestimatecanbeprovedtogodowntozerothatthetestestimateconvergesaccordingly.Onthecontrary,itisverylikelytodivergeascomplexityincreases.Topreventthisphenomenonitisthereforenecessarytoﬁndtheright36classificationandregressiontreestrade-offbetweenatreewhichisnottooshallownortoodeep.Theproblemisinknowingwhentostopsplitting,i.e.,inhowtocarefullyformulateLine7ofAlgorithm3.2.Letusﬁrstconsiderthestoppingcriteriathatareinherenttotheiterativepartitionprocedure,regardlessofoverﬁtting.Nodetisin-evitablysetasaterminalnodewhenLtcannolongerbesplit,whichhappensinthefollowingcases:(a)WhentheoutputvaluesofthesamplesinLtarehomogeneous.Thatis,ify=y0forall(x,y),(x0,y0)∈Lt.Inparticular,thisisnecessarilythecasewhenNt=1.(b)WhentheinputvariablesXjareeachlocallyconstantinLt.Thatis,ifxj=x0jforall(x,y),(x0,y0)∈Lt,foreachinputvariableXj.Inthissituation,itisindeednotpossibletodivideLtintotwo(ormore)non-emptysubsets.Topreventoverﬁtting,thestoppingcriterionisthenusuallycom-plementedwithheuristicshaltingtherecursivepartitionifLthasbecometoosmallorifnosufﬁcientlygoodsplitcanbefound.Themostcommonapproachesareformulatedasfollows:(c)SettasaterminalnodeifitcontainslessthanNminsamples.(Nminisalsoknownasmin_samples_split.)(d)Settasaterminalnodeifitsdepthdtisgreaterorequaltoathresholddmax.(dmaxisalsoknownasmax_depth.)(e)Settasaterminalnodeifthetotaldecreaseinimpurityislessthanaﬁxedthresholdβ.Thatis,ifp(t)∆i(s∗,t)<β.(f)SettasaterminalnodeifthereisnosplitsuchthattLandtRbothcountaleastNleafsamples.(Nleafisalsoknownasmin_samples_leaf.)Inalloftheabove,stoppingcriteriaaredeﬁnedintermsofuser-deﬁnedhyper-parameters(Nmin,dmax,βorNleaf)thathavetobetunedinordertoﬁndtherighttrade-off.Ideally,theyneedtobesuchthattheyareneithertoostrictnortoolooseforthetreetobeneithertooshallownortoodeep.Toolargeatreewillhaveahighergeneralizationerrorthantherightsizedtree.Likewise,toosmallatreewillnotusesomeoftheinformationinL,againresultinginahighergeneralizationerrorthantherightsizedtree.AsdescribedinSection2.3,choosingtheappropriateparametervaluesisusuallyper-formedusingadedicatedmodelselectionprocedure,whichcanbecomputationallyexpensive,yetusuallyimperativeforreachinggoodgeneralizationperformance.3.6splittingrules37Pre-pruningandpost-pruningWhilethestoppingcriteriapresentedabovemaygivegoodresultsinpractice,thestrategyofstoppingearlytheinductionofthetreeisingeneralunsatisfactory.TheremaybenodestforwhichthestoppingcriterionismetbutwhosedescendantstLandtRmayhavesplitsthatwouldhaveinfactreducedthegeneralizationerrorofthetree.Bydeclaringtasaterminalnode,thegoodsplitsontLandtRareneverexploited.Anotherwayoflookingattheproblemofﬁndingtherightsizedtreeconsistsinfullydevelopingallnodesandthentopruneinsteadofstopping.Thatis,tosequentiallyremovethenodesthatdegradethegeneralizationerror(estimatedonanindependentvalidationset)untiltheoptimaltreeisfound.Sincenodesareprunedafterthein-ductionofthetree,thisframeworkisalsoknownaspost-pruning.Byopposition,earlystoppingasdescribedearlierisalsoreferredtoaspre-pruning.Inthecontextofsingledecisiontrees,post-pruningusuallyyieldsbetterresultsthanpre-pruning.Fromaninterpretabilitypointofview,itisalsoaveryeffectiveframeworkforsimplifyingdecisiontreesandbetterunderstandthestructureinthedata.However,inthecontextofensembleofdecisiontrees,wewillseeinChapter4that(pre-orpost-)pruningisnolongerrequiredtoachievegoodgen-eralizationperformance.Forthisreason,werefertotheliteratureformoredetaileddiscussiononthetopic(e.g.,[Breimanetal.,1984;Mingers,1989a;ZighedandRakotomalala,2000]).3.6splittingrulesAssumingthatthestoppingcriterionisnotmet,wenowfocusontheproblemofﬁndingthesplits∗∈Qoftthatmaximizestheimpuritydecrease∆i(s∗,t)(Line10ofAlgorithm3.2).3.6.1FamiliesQofsplittingrulesAsintroducedinSection3.2,asplitsofnodetisaquestionthatdi-videsthespaceXtintodisjointsubspacesrespectivelycorrespondingtoeachofthechildrenoft.Formally,asplitisdeﬁnedasapartition:Deﬁnition3.7.AsplitsofnodetisapartitionofXt,thatisasetofnon-emptysubsetsofXtsuchthateveryelementx∈Xtisinexactlyoneofthesesubsets(i.e.,Xtisadisjointunionofthesubsets).IfsdividesXtintotwosubsets,thensissaidtobeabinarysplitanditsleftandrightchildrenaredenotedtLandtR.Inthegeneralcasehowever,smaydivideXtintomorethantwosubsets,resultinginasmanychildnodesti1,...,tiNassubsets(SeeFigure3.3).38classificationandregressiontreesttLtRtti1ti2...tiNFigure3.3:Binarysplitoft(left)andN-arymultiwaysplitoft(right).ThesetSofallpossiblesplitssisthesetofallpartitionsofXt.Itisinﬁnitelylargeassoonasonetheinputvariablescantakeinﬁnitelymanyvalues.Forinstance,ifXt=R,thenthereexistsinﬁnitelymanywaysofpartitioningXtintotwo(ormore)subsets.Amongallofthemhowever,onlythosethatyieldapartitionofLtintonon-emptysub-setsareworthconsidering.Forexample,inthebinarycase,splitsre-sultinginoneofthechildrenbeingemptyarenotconsideredbecausetheirgoodnesscannotbeevaluatedonthelearningset.Assuch,theoptimizationproblemofﬁndingthebestsplits∗ofXtcanberoughlyrestatedasﬁndingthebestpartitionofthenodesamplesLt.AssumingdistinctinputvaluesforallNtnodesamples,thenum-berofpartitionsofLtintoknon-emptysubsetsisgivenbytheStir-lingnumberofthesecondkind[Knuth,1992]S(Nt,k)=1k!kXj=0(−1)k−j(cid:18)kj(cid:19)jNt,(3.12)whichreducesto2Nt−1−1forbinarypartitions.Giventheexponen-tialgrowthinthenumberofpartitions,thenaivestrategyofenumer-atingallpartitionsandpickingthebestofthemisoftencomputa-tionallyintractable.Forthisreason,simplifyingassumptionsmustbemadeonthebestsplits∗.Morespeciﬁcally,theinductionalgorithmusuallyassumesthats∗–oratleastagoodenoughapproximation–livesinafamilyQ⊆Sofcandidatesplitsofrestrictedstructure.TheusualfamilyQofsplitsisthesetofbinarysplitsdeﬁnedonasinglevariableandresultinginnon-emptysubsetsofLt:Q={s|s∈p[j=1Q(Xj),LtL6=φ,LtR6=φ}(3.13)-IfXjisanorderedvariabletakingvaluesinXj,thenthesetofbinarysplitsonXjisthesetofallbinarynon-crossingpartitionssvjofXj:Q(Xj)={({x|xj6v},{x|xj>v})|v∈Xj}(3.14)Fromageometricalpointofview,splitsofthisformpartitiontheinputspaceXwithaxis-parallelhyperplanes,aspreviouslyillustratedonFigure3.2.Accordingly,thedecisionthresholdv3.6splittingrules39thuscorrespondstothedistanceoftheseparatinghyperplanefromtheorigin.-IfXjisacategoricalvariabletakingvaluesinXj={b1,...,bL},thenthesetofbinarysplitsonXjisthesetofallbinarynon-emptypartitionsofXj:Q(Xj)={({x|xj∈B},{x|xj∈B})|B⊂{b1,...,bL}}(3.15)whereB={b1,...,bL}\BisthecomplementarysetofB.Givendecomposition3.13intosubsetsQ(Xj),thesplits∗∈Qisthebestofthebestsplitsdeﬁnedoneachinputvariable.Thatis,s∗=argmaxs∗jj=1,...,p∆i(s∗j,t)(3.16)s∗j=argmaxs∈Q(Xj)LtL,LtR6=φ∆i(s,t)(3.17)Inthisframework,thecruxoftheproblemthereforesimplyreducestotheimplementationofEquation3.17.Whilepartitionsofform3.14and3.15certainlyconstitutethemostcommontypesofsplits,alternativesproposedovertheyearsintheliteratureareworthmentioning.InID3andC4.5,Quinlan[1986,1993]replacesbinarysplitsoncategoricalvariableswithmultiwaysplits.Thatis,ifXjcountsLdifferentvaluesb1,...,bL,thensplittingonXjdividesXtintoLchildnodes–oneforeachvalueofthevariable.Inourframework,Q(Xj)thereforereducestothesingletonQ(Xj)={({x|xj=bl}|bl∈Xj)}.(3.18)Inobliquedecisiontrees,Heathetal.[1993]proposetoreplaceaxis-parallelcuttinghyperplaneswithhyperplanesofanyorientation,re-sultingintosmaller,yetasaccurate,decisiontrees.Inthissettinghow-ever,decomposition3.16nolongerholds,hencemakingthesearchofthebestsplitoftenmorecomputationallyintensive.Morerecently,severalauthors(e.g.,[Gama,2004;CriminisiandShotton,2013;Botta,2013])outlinedmoregeneralframeworksinwhichsplitsaredeﬁnedasmulti-variatefunctions,therebyrevisitingseparatinghyperplaneslikeinobliquetreesorinvestigatingmoreadvancedmodelslikequa-draticsurfacesordecisiontreesinsidedecisiontrees.Finally,inanan-otherdirection,severalauthors[Adamo,1980;YuanandShaw,1995;OlaruandWehenkel,2003]proposeinfuzzydecisiontreestorede-ﬁnethenotionofsplitasoverlappingfuzzysets(insteadofdisjointsubsets),henceallowingsamplesclosetothedecisionthresholdvtopropagateintobothchildnodes.40classificationandregressiontreesiX1X2X3Y0000c11001c12010c23011c24011c25100c26100c27100c28100c29111c2Table3.1:Toybinaryclassiﬁcationproblem3.6.2GoodnessofsplitInthissection,wedescribeimpuritymeasuresi(t)forevaluatingthegoodnessofsplittingrules.Astheyaretheheartofourcontributionsregardinginterpretabilityoftree-basedmethods(SeeChapter6),thenecessarymathematicalfoundationsthathavedriventheirmethod-ologicaldevelopmentarestudiedhereindetails.Section3.6.2.1re-viewsimpurityfunctionsforclassiﬁcationwhileSection3.6.2.2dis-cussescriteriaforregression.3.6.2.1ClassiﬁcationLetusconsiderabinaryclassiﬁcationproblemdeﬁnedonthreebi-narycategoricalinputvariablesX1,X2andX3.Letusassumethatwehavea10-samplelearningsetLaslistedinTable3.1.Attherootnodet0,Lt0containsalllearningsamplesandwearelookingforthebestbinarysplitdeﬁnedononeoftheinputvariables.Sinceeachofthemisbinaryandcategorical,Q(Xj)(forj=1,2,3)countsexactlyonesinglesplitperinputvariable,eachpartitioningLt0intotwosub-setsLtL={(x,y)|(x,y)∈Lt0,xj=0},LtR={(x,y)|(x,y)∈Lt0,xj=1}.AsintroducedinSection3.3,ourobjectiveistopartitiont0usingthesplits∗thatmaximizestheimpuritydecrease∆i(s,t)=i(t)−pLi(tL)−pRi(tR),wheretheimpurityfunctioni(t)evaluatesthegoodnessofnodet.Sinceourgoalistobuildthedecisiontreethatminimizesgeneraliza-tionerror,itseemsnaturaltotakeasproxyi(t)thelocalresubstitu-tionestimateatnodet:3.6splittingrules41t0t1t2X1p(y=c1|t1)=25p(y=c2|t1)=35p(y=c1|t2)=05p(y=c2|t2)=55t0t1t2X2p(y=c1|t1)=26p(y=c2|t1)=46p(y=c1|t2)=04p(y=c2|t2)=44t0t1t2X3p(y=c1|t1)=16p(y=c2|t1)=56p(y=c1|t2)=14p(y=c2|t2)=34Figure3.4:SplittingonX1versussplittingoneitherX2orX3.Deﬁnition3.8.Inclassiﬁcation,theimpurityfunctioniR(t)basedonthelocalresubstitutionestimatedeﬁnedonthezero-onelossis:iR(t)=1−p(byt|t)=1−maxc∈Yp(c|t)(3.19)Withthiscriterion,selectingthebestsplitwouldamounttopickthesplitthatmostdecreasestrainingerror.Inspiteofitsnaturalat-tractivenesshowever,iR(t)hastwoseriousdefects:(a)AsacorollaryofProposition3.1,∆i(s,t)iszeroforallsplitsifthemajorityclassremainsthesameinbothchildnodes,thatisifbyt=bytL=bytR.Inourtoyproblem,splittingeitheronX1,X2orX3produceschildnodesinwhichc2remainsthemajorityclass.Asaresult,∆i(s,t0)=0forallthreepossiblesplits,asiftheywereequallybad,orasifnofurtherimprovementcouldbeachieved.(b)Itdoesnotsensitivelyaccountforchangesintheaposterioriclassdistributionsp(y|tL)andp(y|tR).Inourexample,noneofthethreesplitsimprovestraininger-ror.However,splittingonX1islikelytoyieldatreewhichissimplerthaniftherootnodehadbeensplitoneitherX2orX3.AsshowninFigure3.4,splittingonX1indeedproducesarightchildnodethatisalreadyterminalandforwhichnofur-therworkisrequired.SplittingonX2alsoresultsintherightchildnodetobepure.However,theleftchildnodeisinthis42classificationandregressiontreescaselarger,suggestingthatmoreworkisfurtherrequired.Fi-nally,splittingonX3resultsinchildnodesthathavetobebothdividedfurther.SplittingonX1shouldthereforebepreferred,evenifitdoesnotreduceimmediatelythetrainingerror.Infact,theseissuesarelargelyduetothefactthatthetreegrowingalgorithm3.2isbasedonaone-stepoptimizationprocedure.Agoodimpuritycriterionshouldideallyalsotakeintoaccountthepossibilityoffurtherimprovementdeeperinthetree.ToavoidtheundesirablepropertiesofiR(t),thechoiceofi(t)shouldthereforebeguidedbyensuringthati(t)getsprogressivelysmallerwhentgetsmoreho-mogeneoustowardsone(orsome)oftheclasses(whilenotbeingnecessarilybetterintermsofmisclassiﬁcationerror)andlargerwhentismoreheterogeneous.InCART,Breimanetal.[1984]identifyaclassofimpurityfunctioni(t)meetingtheserequirements:Theorem3.3.LetΦ(p1,...,pJ)beastrictlyconcaveJ-aryfunctionde-ﬁnedon06pk61,fork=1,...,J,PJk=1pk=1andsuchthat-Φ(1,...,0)=Φ(0,1,...,0)=···=Φ(0,...,1)isminimal;-Φ(1J,...,1J)ismaximal.Then,fori(t)=Φ(p(c1|t),...,p(cJ|t))andanysplits,∆i(s,t)>0,withequalityifandonlyifp(ck|tL)=p(ck|tR)=p(ck|t)fork=1,...,J.Proof.Letusﬁrstremarkthatp(ck|t)=NcktNt=NcktL+NcktRNt=NtLNtNcktLNtL+NtRNtNcktRNtR=pLp(ck|tL)+pRp(ck|tR)Bystrictconcavity,itcomesi(t)=Φ(p(c1|t),...,p(cJ|t))=Φ(pLp(c1|tL)+pRp(c1|tR),...,pLp(cJ|tL)+pRp(cJ|tR))>pLΦ(p(c1|tL),...,p(cJ|tL))+pRΦ(p(c1|tR),...,p(cJ|tR))=pLi(tL)+pRi(tR)withequalityifandonlyifp(ck|tL)=p(ck|tR)fork=1,...,J.TobetterunderstandTheorem3.3,letusconsiderastrictlyconcavefunctionΦthatsatisﬁestherequirementsandletusevaluateonour3.6splittingrules430.00.20.40.60.81.00.10.20.30.40.5i(t)p(c1|t)i(tL)p(c1|tL)i(tR)p(c1|tR)∆i(s,t)=0.0800.00.10.20.30.40.250.300.350.40i(t)i(tL)i(tR)∆i(s,t)=0.003Figure3.5:Splittingt0onX1(above)versussplittingt0onX3(below),asevaluatedbyastrictlyconcaveimpurityfunction.Theﬁguresshowiwithrespecttothelocalprobabilityp(c1)oftheﬁrstclass.44classificationandregressiontrees0.00.20.40.60.81.00.10.20.30.40.5i(t)p(c1|t)i(tL)p(c1|tL)i(tR)p(c1|tR)∆i(s,t)=0.000Figure3.6:Splittingt0onX1,asevaluatedbytheresubstitutionestimateiR(t).TheﬁgureshowsiRwithrespecttothelocalprobabilityp(c1)oftheﬁrstclass.0.00.20.40.60.81.00.00.20.40.60.81.0iR(t)iH(t)iG(t)Figure3.7:ComparisonofiR(t),iH(t)andiG(t)withrespecttop(c1|t).3.6splittingrules45toyproblemthegoodnessofthesplitdeﬁnedonX1.AsillustratedintheﬁrstplotofFigure3.5,i(t)ismaximumwhentheuncertaintyontheoutputvalueisthelargest(i.e.,atp(c1|t)=p(c2|t)=12)andthengetsprogressivelysmallerwhencertaintygrowstowardsoneoftheclasses(i.e.,asp(c1|t)getscloseto0or1).AsshownbyTheorem3.3,i(t)isalsonecessarilylargerthantheweightedsum(illustratedbythegraydot)ofimpuritiesofthechildnodes.Visually,thefurtherawayp(c1|tL)andp(c1|tR)fromp(c1|t),thelarger∆i(s,t)(illustratedbytheredline)andthebetterthesplits.Inparticular,evenifi(tL)islargerthani(t)ontheﬁrstplotofFigure3.5,impurityisinfactglob-allysmaller.Bycontrast,whensdoesnotsigniﬁcantlychangetheaposterioriclassdistributions,asillustratedinthesecondplotofFig-ure3.5whensplittingt0onX3,thenthecloserp(c1|tL)andp(c1|tR)fromp(c1|t)andthesmaller∆i(s,t).Yet,aslongastheaposteri-oriclassdistributionsdonotexactlycoincidewiththeaprioriclassdistribution,theneventheslightestchangesgetcapturedby∆i(s,t)becauseofstrictconcavity.Itisonlywhentheyexactlycoincide(i.e.,whenp(c1|tL)=p(c1|tR)=p(c1|t))thatthethreeredpointsoverlapandthat∆i(s,t)=0.Graphically,italsobecomesobviouswhencomparingFigure3.5withFigure3.6whytheresubstitutionestimateiR(t)isnotanap-propriateimpurityfunction.AslongasthemajorityclasswithinthechildnodestLandtRisthesameasint,thethreereddotsremainalignedinaperfectlineandthegraydotoverlapwithi(t).Asaresult,∆i(s,t)isnecessarilynullnomattertheaposterioriclassdistributionsinducedbythesplit,bethemcloseorfarfromp(c1|t).ThemostcommonimpuritycriteriausedforclassiﬁcationtreesaretheShannonentropyandtheGiniindex:Deﬁnition3.9.TheimpurityfunctioniH(t)basedontheShannonen-tropy[ShannonandWeaver,1949]is:iH(t)=−JXk=1p(ck|t)log2(p(ck|t))(3.20)Deﬁnition3.10.TheimpurityfunctioniG(t)basedontheGiniindex[Gini,1912]is:iG(t)=JXk=1p(ck|t)(1−p(ck|t))(3.21)AsillustratedonFigure3.7,bothiH(t)andiG(t)satisfytherequire-mentsofTheorem3.3andexhibitthepropertiesthatwearelookingfor.Theentropy-basedimpurityiH(t)quantiﬁestheuncertaintyofYwithinnodet.Withthiscriterion,theimpuritydecrease∆iH(s,t),alsoknownastheinformationgain,representstheinformationlearnedaboutYbysplittingtintotLandtR.TheGini-basedimpurityiG(t)46classificationandregressiontreesmeasureshowoftenarandomlychosenobjectx∈Ltwouldbeincor-rectlyclassiﬁedifitwererandomlylabeledbyaclassc∈Yaccordingtothedistributionp(y|t).WhiletheShannonentropy3.20andtheGiniindex3.21arerobustandreliableimpurityfunctionsusuallyproducingaccuratedecisiontrees,theyarenotexemptofdefects.Oneofthemostwell-knownissuesisend-cutpreference[MorganandMessenger,1973;Breimanetal.,1984],thatisthetendencytofavorunbalancedsplitsinwhichpLisclosetozeroorone,oftenresultingindeepanduninterpretabledecisiontrees.Anotherdefectisthepropensityofpreferringsplitsbasedoninputvariableswithmanyoutcomesratherthanselectinginputvariableswithoutbiaswithrespecttotheircardinality[Quin-lan,1986;Strobletal.,2007a].Intuitively,if|X1|>|X2|andthatbothX1andX2areindependentofY,thenX1isindeedmorelikelytobeselectedthanX2becauseofchance.Toovercometheseissues,numer-ousvariantsofimpuritymeasureshavebeenproposedintheliter-ature,includingnormalizationtechniques,distance-basedmeasuresorcausality-basedimpurityfunctions(see[Wehenkel,1996;ZighedandRakotomalala,2000;MaimonandRokach,2005]forreviewsonthetopic).Fromanempiricalpointofviewhowever,severalstud-ies[Mingers,1989b;Miyakawa,1989;DeMántaras,1991]haveshownthat,whiletheimpurityfunctionmayhaveasigniﬁcantimpactonthestructureofthedecisiontree,improvementsintermsofclassiﬁcationaccuracyareusuallynotthatsigniﬁcant.3.6.2.2RegressionWhentheoutputvariableYisquantitative,Proposition3.2showsthatsplittingtinanywayreducesthesquarederrorlossonthetrainingset.Inparticular,thereductionispositiveaslongasthevaluesas-signedtothechildnodesaredifferentfromthevalueatt.Contrarytoclassiﬁcation,thisonlyhappensinrarecircumstances(i.e.,whenthemeanoutputvaluesatthechildnodescoincidewiththemeanoutputvalueint),hencemakingtheregressionresubstitutionesti-matesensitivetochangesin(themeansof)theaposterioridistribu-tions,eveniftheseareonlyslight.Asaresult,thelocalresubstitutionestimatedoesnotexhibittheundesirablepropertiesthatwehadinclassiﬁcationandinfactconstitutesagoodcriterionforregression.Deﬁnition3.11.Inregression,theimpurityfunctioniR(t)basedonthelocalresubstitutionestimatedeﬁnedonthesquarederrorlossis:iR(t)=1NtXx,y∈Lt(y−byt)2(3.22)Anotherwayoflookingatcriterion3.22istonoticethatitcorre-spondstothewithinnodevarianceoftheoutputvalueint.Accord-ingly,s∗isthesplitthatmaximizesthereductionofvariance∆i(s,t)inthechildnodes.3.6splittingrules47EquivalencebetweenclassificationandregressiontreesWhenY={0,1},thelearningproblemcaneitherbestatedasabinaryclassiﬁcationtaskwherec1=0andc2=1orasaregressiontaskwherethegoalistopredictthemostaccuratepredictionsby∈Y⊆R.Interestingly,regressiontreesbuiltinthissettingareinfactstrictlyequivalenttoclassiﬁcationtreesbuiltusingtheGiniindexiG(t).In-deedsincebyt=1NtPx,y∈Lty=p(c2|t)=1−p(c1|t),itcomes:iR(t)=1NtXx,y∈Lt(y−byt)2=1NtXx,y∈Lty−2ybyt+by2t=byt−2by2t+by2t=byt(1−byt)=p(c2|t)(1−p(c2|t))=12iG(t)(3.23)Fromapracticalpointofview,thismeansthatbothclassiﬁcationandregressiontreescouldbeimplementedusingthesinglecriterion3.22.3.6.3FindingthebestbinarysplitNowthatwehavedescribedfamiliesQofsplittingrulesandim-puritycriteriatoevaluatetheirrespectivegoodness,thelastthingwhichismissingtohaveacompletespeciﬁcationoftheinductional-gorithm3.2isanefﬁcientoptimizationprocedureforﬁndingthebestsplits∗∈Q.AssumingthatQisthesetofbinaryunivariatesplits,weshowedinSection3.6.1thats∗isthebestofthebestbinarysplitss∗jdeﬁnedoneachinputvariable.Thisleadstothefollowingprocedure:Algorithm3.3.Findthebestsplits∗thatpartitionsLt.1:functionFindBestSplit(Lt)2:∆=−∞3:forj=1,...,pdo4:Findthebestbinarysplits∗jdeﬁnedonXj5:if∆i(s∗j,t)>∆then6:∆=∆i(s∗j,t)7:s∗=s∗j8:endif9:endfor10:returns∗11:endfunctionLetusnowdiscussline4fororderedandcategoricalvariables.48classificationandregressiontreesvkvk+1v'kLv'ktLLv'ktRXjFigure3.8:BinarypartitionsofLtontheorderedvariableXj.Settingthedecisionthresholdvtoanyvaluein[vk;vk+1[yieldsidenticalpartitionsofLt,butnotofXt.3.6.3.1OnanorderedvariableLetXjbeanorderedvariableandletQ(Xj)bethesetofallbinarynon-crossingpartitionsofXj,asdeﬁnedinEquation3.14.LetalsoXj|Lt={xj|x,y∈Lt}denotesthesetofuniquevaluesofXjwithinthenodesamplesint.Thebestsplitsvj∈Q(Xj)onXjisthebestbinarypartitionofLtintotwonon-emptysubsets:LvtL={(x,y)|(x,y)∈Lt,xj6v}LvtR={(x,y)|(x,y)∈Lt,xj>v}wherevisthedecisionthresholdofthesplit.AsillustratedinFig-ure3.8,thereexist|Xj|Lt|−1partitionsofLtintotwosuchnon-emptysubsets,i.e.,oneforeachvaluevk∈Xj|Lt,exceptforthelastonewhichleadstoaninvalidpartition.Inparticular,ifXjislocallycon-stantint(i.e.,ifalldotsoverlapinFigure3.8),then|Xj|Lt|=1andXjcannotbeusedtopartitiont.Moreimportantly,thereusuallyexistseveralthresholdsvproducingthesamepartitionofthenodesam-ples.Ifvkandvk+1aretwoimmediatelyconsecutivevaluesinXj|Lt,thenallsplitssvjforv∈[vk,vk+1[indeedproducethesameparti-tionofLtassvkjdoes.Intermsofimpuritydecrease∆i,allofthemarethusequivalentwhenevaluatedonLt.Ingeneralizationhowever,thesesplitsmaynotbestrictlythesamesincetheydonotproducethesamepartitionofXt.Asacompromise,thedecisionthresholdsthatarethususuallychosenarethemid-cut-pointsv0k=vk+vk+12be-tweenconsecutivevaluesofthevariable,asshownbythedottedlineinFigure3.8.Inpractice,thisisindeedagood-enoughheuristiconmostproblems.Inthisframework,thebestsplits∗jisthesplitsv0kjthatmaximizesimpuritydecrease.Computationally,theexhaustiveevaluationofallthesesplitscanbecarriedoutefﬁcientlywhenconsideringdecisionthresholdsv0kinsortedorder,byremarkingthat∆i(sv0k+1j,t)canbe3.6splittingrules49computedfrom∆i(sv0kj,t)inanumberofoperationslinearlypropor-tionalthenumberofsamplesgoingfromtherightchildtoleftchild.Assuch,theexhaustiveevaluationofallintermediatesplitscanbeperformedinlineartimewithrespecttoNt,henceguaranteeinggoodperformanceasfurthershowninChapter5.-Inclassiﬁcation,evaluatingeither∆iH(s,t)or∆iG(s,t)boilsdowntothecomputationofp(c|t),p(c|tL)andp(c|tR)forallclassesc∈Y.Thenecessarystatisticsforcomputingtheseprob-abilitiesarethenumbersNct,NctLandNctRofsamplesofclasscint,tLandtR,alongwiththetotalnumbersNt,NtLandNtRofsamplesint,tLandtR.NctandNtcanbecomputedonceforallsplits.Thefourotherstatisticscanbecomputediteratively,fromsv0kjtosv0k+1j:Nv0k+1tL=Nv0ktL+|{(x,y)|(x,y)∈Lv0k+1tL∩Lv0ktR}|(3.24)Nv0k+1ctL=Nv0kctL+|{(x,y)|(x,y)∈Lv0k+1tL∩Lv0ktR,y=c}|(3.25)Nv0k+1tR=Nv0ktR−|{(x,y)|(x,y)∈Lv0k+1tL∩Lv0ktR}|(3.26)Nv0k+1ctR=Nv0kctR−|{(x,y)|(x,y)∈Lv0k+1tL∩Lv0ktR,y=c}|(3.27)whereLv0k+1tL∩Lv0ktRarethenodesamplesgoingfromtherightchildnodetotheleftchildnodewhenswitchingfromsv0kjtosv0k+1j.-Inregression,iR(t)canbere-expressedasthedifferencebe-tweenthemeanofthesquaredoutputvaluesandthesquareofthemeanoutputvalue,thatisiR(t)=Σt2Nt−(ΣtNt)2(3.28)whereΣt=Px,y∈LtyandΣt2=Px,y∈Lty2.Inthisform,thenecessarystatisticsforcomputing∆iR(s,t)areΣt,Σt2,ΣtL,Σt2L,ΣtRandΣt2R,alongwiththetotalnumbersNt,NtLandNtRofsamplesint,tLandtR.Asinclassiﬁcation,Σt,Σt2andNtcanbecomputedonceforallsplits,whileNtLandNtRcanbecomputedfromonesplittoanotherusingEquations3.24and3.26.Thefourotherstatisticscanbecomputediteratively,fromsv0kjtosv0k+1j:Σv0k+1tL=Σv0ktL+X(x,y)∈Lv0k+1tL∩Lv0ktRy(3.29)Σv0k+1t2L=Σv0kt2L+X(x,y)∈Lv0k+1tL∩Lv0ktRy2(3.30)Σv0k+1tR=Σv0ktR−X(x,y)∈Lv0k+1tL∩Lv0ktRy(3.31)50classificationandregressiontreesΣv0k+1t2R=Σv0kt2R−X(x,y)∈Lv0k+1tL∩Lv0ktRy2(3.32)Startingfromtheinitialpartitionv00=−∞,thatiswheretLisemptyandtRcorrespondstot,andusingtheaboveupdateequationstoswitchfromv0ktov0k+1,thesearchofbestsplits∗jonXjcanﬁnallybeimplementedasdescribedinAlgorithm3.4andfurtherillustratedinFigure3.9.Algorithm3.4.Findthebestsplits∗jonXjthatpartitionsLt.1:functionFindBestSplit(Lt,Xj)2:∆=03:k=04:v0k=−∞5:Computethenecessarystatisticsfori(t)6:InitializethestatisticsfortLto07:InitializethestatisticsfortRtothoseofi(t)8:SortthenodesamplesLtsuchthatx1,j6x2,j6···6xNt,j9:i=110:whilei6Ntdo11:whilei+16Ntandxi+1,j=xi,jdo12:i=i+113:endwhile14:i=i+115:ifi6Ntthen16:v0k+1=xi,j+xi−1,j217:Updatethenecessarystatisticsfromv0ktov0k+118:if∆i(sv0k+1j,t)>∆then19:∆=∆i(sv0k+1j,t)20:s∗j=sv0k+1j21:endif22:k=k+123:endif24:endwhile25:returns∗j26:endfunctionAswewillseelaterinChapter5,thealgorithmcomplexityisupperboundedbythecomplexityofthesortingoperation.Inthecontextofrandomizeddecisiontreeshowever,whereﬁndingtheverybestsplits∗jisnotascrucial,wewillshowthatapproximationtechniquesbasedonsub-samplingofthenodesamplesoronthediscretizationofthevariableXjcanhelpreducethecomputationalcomplexityofprocedurewithoutsigniﬁcantimpactonaccuracy.3.6splittingrules51∆i(svj,t)xi−1,jxi,jv'kLv'ktLLv'ktR∆XjFigure3.9:LoopinvariantofAlgorithm3.4.Attheendofeachiteration,∆i(sv0kj,t)hasbeencomputedfromthestatisticsoftheprevioussplitatv0k−1andcomparedtothebestreductioninimpurity∆foundsofarwithinthesplitsatv00=−∞tov0k−1.3.6.3.2OnacategoricalvariableLetXjbeacategoricalvariableandletQ(Xj)bethesetofallbinarypartitionsofXj={b1,...,bL},asdeﬁnedinEquation3.15.Thenum-berofnon-emptybinarypartitionsinthissetis2L−1−1,whichmayquicklybecomehighlyprohibitivetoexploreexhaustivelywhenXjcountsahighnumberLofcategories.Fortunately,inbinaryclassiﬁcation,thisexponentialcomplexitycanbereducedfromlookingat2L−1−1partitionstoL−1parti-tions,thanksatheoreticalresultduetoFisher[1958]andBreimanetal.[1984]:Theorem3.4.LetreorderthecategoriesofXjsuchthatp(c1|t,Xj=bl1)6p(c1|t,Xj=bl2)6···6p(c1|t,Xj=blL).Iftheimpurityfunctioni(t)satisﬁestherequirementsofTheorem3.3,thenoneoftheL−1subsetsB={bl1,...,blh},h=1,...,L−1deﬁnesabinarypartitionofthenodesamplesintoLBtL={(x,y)|(x,y)∈Lt,xj∈B}LBtR={(x,y)|(x,y)∈Lt,xj∈B}whichmaximizes∆i(s,t),fors∈Q(Xj).Intuitively,thisresultindicatesthatallthosecategoriesblleadingtohighprobabilitiesofbeingofclassc1shouldbeputtogetherinto52classificationandregressiontreesonenodeandthecategoriesleadingtolowerprobabilitiesintotheother.Inpractice,thisalsomeansthatthesearchofthebestbinarysplitcanbeperformedasifXjwasanorderedvariable,byvirtuallyreplacingcategoricalvaluesblwithp(c1|t,Xj=bl)andusingAlgo-rithm3.4toﬁndthebestbinarysplitontheseorderedvalues.Unfortunately,Theorem3.4doesnotextendtomulti-classclassi-ﬁcation(i.e.,whenJ>2).Inthiscase,anexhaustiveexplorationofall2L−1−1splitsmustbeperformedinordertoﬁndthebestsplit.WhenthenumberLofcategoriesissmall,thiscanusuallybedonewithinreasonabletime.However,asLgetslarger,thisquicklybecomesinfeasibleinpractice.Asanapproximation,theusualstrat-egy[LiawandWiener,2002]consistsinexhaustivelyevaluatingallsplitswhenL610andthenswitchtorandomsamplingofthesub-setsB⊂{b1,...,bL}whenL>10.Inthatcase,28randomsubsetsBaretypicallydrawnandevaluated.Inregression,giventheequivalenceofiR(t)withtheGiniindex,conditionsofTheorem3.4aremetandthesamealgorithmictrickcanbeappliedasinbinaryclassiﬁcationtocomputetheoptimalsplit.Inthiscase,Xjistransformedintoanorderedvariablebyvirtuallyreplacingcategoricalvaluesblwiththemeanoutputvalueatbl,i.e.,1NltPx,y∈Lt,xj=bly,onwhichAlgorithm3.4isthenappliedtoﬁndthebestbinarysplitontheseorderedvalues.3.7multi-outputdecisiontreesUptonow,wehaveassumedthattheresponsewasmodeledasasingletargetvariableY.Insomecontextshowever,thegoalmaybetopredictseveraloutputvaluesy=(y1,...,yq)∈Y1×···×Yqforthesameinputx.Afamousexampleofsuchmulti-objectivetaskismulti-labelclassiﬁcation(see[TsoumakasandKatakis,2007]),inwhichasamplexcanbeassignedtomultiplebinarylabelsYk(fork=1,...,q).Anotherexampleisimageannotation,inwhichthegoalistoannotate(i.e.,classify)everypixelofanimageinordertoidentifyregionsorobjects(see[Zhangetal.,2012]).Themoststraightforwardstrategytosolveamulti-objectivetaskistobuildanindependentandseparatemodelforeachoftheqoutputvariablesYk.Distinctively,decisiontreesofferanalternativestrategywhichconsistsinlearningasinglemulti-outputmodel,capableofpre-dictingalloutputvariablesatonce.Algorithmically,multi-outputde-cisiontreescloselyrelatetopredictiveclusteringtrees[Blockeeletal.,2000],outputkerneltrees[Geurtsetal.,2006b]ormulti-objectivede-cisiontrees[Kocevetal.,2007],andcaneasilybeimplementedonthebasisoftheinductionproceduredevelopedinthischapter,providedthefollowingtwochanges:-Leavesarelabeledwithoutputvectorsyt=(yt,1,...,yt,q),whereeachyt,k(fork=1,...,q)iscomputedusingassign-3.7multi-outputdecisiontrees53mentrule3.7inclassiﬁcation(resp.assignmentrule3.10inre-gression),aspreviouslydoneinsingleoutputdecisiontrees.-Theimpuritydecreaseofasplitiscomputedastheaverageim-puritydecreaseovertheqoutputvariables.Accordingly,splitsareoptimizedwithrespecttoalloutputvariables,therebyex-ploitingcorrelationsbetweenY1,...,Yqwheneverpossible.Themainadvantageofmulti-outputdecisiontreesisthatdepen-denciesbetweenoutputvariablescanbetakenintoaccount,whereasbuildingqindividualmodelscannotexploitsuchcorrelations,whichmayaffecttheoverallaccuracyofthemodel.Asecondadvantageisthatbuildingasinglemodelisoftenlesscomputationallyexpensivethanbuildingqdifferentmodels,bothfromatimeandspacecom-plexitypointofview.4RANDOMFORESTSOutlineInthischapter,wepresentthewell-knownfamilyofrandomforestsmethods.InSection4.1,weﬁrstdescribethebias-variancedecompo-sitionofthepredictionerrorandthenpresent,inSection4.2,howaggregatingrandomizedmodelsthroughensemblesreducesthepre-dictionerrorbydecreasingthevarianceterminthisdecomposition.InSection4.3,werevisitrandomforestsanditsvariantsandstudyhowrandomnessintroducedintothedecisiontreesreducespredic-tionerrorsbydecorrelatingthedecisiontreesintheensemble.Prop-ertiesandfeaturesofrandomforestsarethenoutlinedinSection4.4whiletheirconsistencyisﬁnallyexploredinSection4.5.4.1bias-variancedecompositionInsection2.2,wedeﬁnedthegeneralizationerrorofamodelϕLasitsexpectedpredictionerroraccordingtosomelossfunctionLErr(ϕL)=EX,Y{L(Y,ϕL(X))}.(4.1)Similarly,theexpectedpredictionerrorofϕLatX=xcanbeex-pressedasErr(ϕL(x))=EY|X=x{L(Y,ϕL(x))}.(4.2)Inregression,forthesquarederrorloss,thislatterformoftheex-pectedpredictionerroradditivelydecomposesintobiasandvariancetermswhichtogetherconstituteaveryusefulframeworkfordiagnos-ingthepredictionerrorofamodel.Inclassiﬁcation,forthezero-oneloss,asimilardecompositionismoredifﬁculttoobtain.Yet,thecon-ceptsofbiasandvariancecanbetransposedinseveralwaystoclassi-ﬁcation,therebyprovidingcomparableframeworksforstudyingthepredictionerrorofclassiﬁers.4.1.1RegressionInregression,assumingthatListhesquarederrorloss,theexpectedpredictionerrorofamodelϕLatagivenpointX=xcanberewrittenwithrespecttotheBayesmodelϕB:Err(ϕL(x))5556randomforests=EY|X=x{(Y−ϕL(x))2}=EY|X=x{(Y−ϕB(x)+ϕB(x)−ϕL(x))2}=EY|X=x{(Y−ϕB(x))2}+EY|X=x{(ϕB(x)−ϕL(x))2},→+EY|X=x{2(Y−ϕB(x))(ϕB(x)−ϕL(x))}=EY|X=x{(Y−ϕB(x))2}+EY|X=x{(ϕB(x)−ϕL(x))2}=Err(ϕB(x))+(ϕB(x)−ϕL(x))2(4.3)sinceEY|X=x{Y−ϕB(x)}=EY|X=x{Y}−ϕB(x)=0bydeﬁnitionoftheBayesmodelinregression.Inthisform,theﬁrstterminthelastexpressionofEquation4.3correspondstothe(irreducible)residualerroratX=xwhilethesecondtermrepresentsthediscrepancyofϕLfromtheBayesmodel.ThefartherfromtheBayesmodel,themoresub-optimalthemodelandthelargertheerror.IfwefurtherassumethatthelearningsetLisitselfarandomvari-able(sampledfromthepopulationΩ)andthatthelearningalgorithmisdeterministic,thentheexpecteddiscrepancyoverLwiththeBayesmodelcanfurtherbere-expressedintermsoftheaveragepredictionEL{ϕL(x)}overthemodelslearnedfromallpossiblelearningsetsofsizeN:EL{(ϕB(x)−ϕL(x))2}=EL{(ϕB(x)−EL{ϕL(x)}+EL{ϕL(x)}−ϕL(x))2}=EL{(ϕB(x)−EL{ϕL(x)})2}+EL{(EL{ϕL(x)}−ϕL(x))2}},→+EL{2(ϕB(x)−EL{ϕL(x)})(EL{ϕL(x)}−ϕL(x))}=EL{(ϕB(x)−EL{ϕL(x)})2}+EL{(EL{ϕL(x)}−ϕL(x))2}}=(ϕB(x)−EL{ϕL(x)})2+EL{(EL{ϕL(x)}−ϕL(x))2}(4.4)sinceEL{EL{ϕL(x)}−ϕL(x)}=EL{ϕL(x)}−EL{ϕL(x)}=0.Insum-mary,theexpectedgeneralizationerroradditivelydecomposesasfor-mulatedinTheorem4.1.Theorem4.1.Forthesquarederrorloss,thebias-variancedecompositionoftheexpectedgeneralizationerrorEL{Err(ϕL(x))}atX=xisEL{Err(ϕL(x))}=noise(x)+bias2(x)+var(x),(4.5)wherenoise(x)=Err(ϕB(x)),bias2(x)=(ϕB(x)−EL{ϕL(x)})2,var(x)=EL{(EL{ϕL(x)}−ϕL(x))2}.Thisbias-variancedecompositionofthegeneralizationerrorisduetoGemanetal.[1992]andwasﬁrstproposedinthecontextofneuralnetworks.Theﬁrstterm,noise(x),istheresidualerror.Itisentirelyindependentofboththelearningalgorithmandthelearningsetand4.1bias-variancedecomposition57yP'B(x)L'L(x)bias2(x)noise(x)var(x){}Figure4.1:Residualerror,biasandvarianceatX=x.(Figureinspiredfrom[Geurts,2002].)providesforanymodelatheoreticallowerboundonitsgeneraliza-tionerror.Thesecondterm,bias2(x),measuresthediscrepancybe-tweentheaveragepredictionandthepredictionoftheBayesmodel.Finally,thethirdterm,var(x),measuresthevariabilityofthepredic-tionsatX=xoverthemodelslearnedfromallpossiblelearningsets.AllthreetermsareillustratedinFigure4.1foratoyandartiﬁcialre-gressionproblem.Bothnoise(x)andvar(x)measuresthespreadofthetwodensitieswhilebias2(x)isthedistancebetweentheirmeans.Asatypicalexample,thebias-variancedecompositionframeworkcanbeusedasatoolfordiagnosingunderﬁttingandoverﬁtting(aspreviouslyintroducedinSection2.3).TheupperplotsinFigure4.2illustrateinlightredpredictionsϕL(x)forpolynomialsofdegree1,5and15learnedoverrandomlearningsetsLsampledfromanoisycosinefunction.PredictionsEL{ϕL(x)}oftheaveragemodelarerep-resentedbythethickredlines.Predictionsforthemodellearnedoverthelearningset,representedbythebluedots,arerepresentedingray.PredictionsoftheBayesmodelareshownbybluelinesandcoincidewiththeunnoisedcosinefunctionthatdeﬁnestheregressionproblem.Thelowerplotsintheﬁgureillustratethebias-variancedecomposi-tionoftheexpectedgeneralizationerrorofthepolynomials.Clearly,polynomialsofdegree1(left)sufferfromunderﬁtting.Intermsofbiasandvariance,thistranslatesintolowvariancebuthighbiasasshowninthelowerleftplotofFigure4.2.Indeed,duetothelowdegreeofthepolynomials(i.e.,duetothelowmodelcomplex-ity),theresultingmodelsarealmostallidenticalandthevariabilityofthepredictionsfromonemodeltoanotheristhereforequitelow.58randomforestsxyDegree=1xerror(x)bias2(x)var(x)noise(x)xyDegree=5xxyDegree=15xFigure4.2:Bias-variancedecompositionoftheexpectedgeneralizationerrorforpolynomialsofdegree1,5and15.Also,becauseoflowcomplexity,noneofthemreallyﬁtsthetrendofthetrainingpoints,evenapproximately,whichimpliesthattheaver-agemodelisfarfromapproximatingtheBayesmodel.Thisresultsinhighbias.Ontheotherhand,polynomialsofdegree15(right)sufferfromoverﬁtting.Intermsofbiasandvariance,thesituationistheopposite.Predictionshavelowbiasbuthighvariance,asshowninthelowerrightplotofFigure4.2.Thevariabilityofthepredictionsislargebecausethehighdegreeofthepolynomials(i.e.,thehighmodelcomplexity)capturesnoiseinthelearningset.Indeed,comparethegraylinewiththebluedots–theyalmostallintersect.Putother-wise,smallchangesinthelearningsetresultinlargechangesintheobtainedmodelandthereforeinitspredictions.Bycontrast,theav-eragemodelisnowquiteclosefromtheBayesmodel,whichresultsinlowbias1.Finally,polynomialsofdegree5(middle)areneithertoosimplenortoocomplex.Intermsofbiasandvariance,thetrade-offiswell-balancedbetweenthetwoextremesituations.Biasandvarianceareneithertoolownortoolarge.4.1.2ClassiﬁcationIndirectanalogywiththebias-variancedecompositionforthesquarederrorloss,similardecompositionshavebeenproposedinthelitera-turefortheexpectedgeneralizationerrorbasedonthezero-oneloss,i.e.,forEL{EY|X=x{1(ϕL(x)6=Y)}}=PL,Y|X=x(ϕL(x)6=Y).Mostno-1NotehowevertheGibbs-likephenomenonresultinginbothhighvarianceandhighbiasattheboundariesofX.4.1bias-variancedecomposition59tably,DietterichandKong[1995],Breiman[1996],Kohavietal.[1996],Tibshirani[1996]andDomingos[2000]havealldevelopedadditivedecompositionssimilartoTheorem4.1byredeﬁningtheconceptsofbiasandvarianceinthecaseofclassiﬁcation.Whiletheseeffortshaveallprovidedusefulinsightintothenatureofclassiﬁcationerror,noneofthemreallyhaveprovidedaseductivelyassimpleandsatisfactoryframeworkasinregression(forreviews,see[Friedman,1997;James,2003;Geurts,2005]).AninterestingconnectionwithTheorem4.1howeveristoremarkthatclassiﬁcationalgorithmsusuallyworkbycomputingestimatesbpL(Y=c|X=x)(4.6)oftheconditionalclassprobability(e.g.,bpL(Y=c|X=x)=p(c|t)indecisiontrees,asdeﬁnedinSection3.4)andthenderivingaclassiﬁ-cationrulebypredictingtheclassthatmaximizesthisestimate,thatis:ϕL(x)=argmaxc∈YbpL(Y=c|X=x)(4.7)Assuch,adirectionforstudyingclassiﬁcationmodelsistorelatethebias-variancedecompositionofthesenumericalestimatestotheexpectedmisclassiﬁcationerrorofclassiﬁcationrule4.7.WenowreproducetheresultsofFriedman[1997]whomadethisconnectionexplicitforthecaseofbinaryclassiﬁcation.LetusﬁrstdecomposetheexpectedclassiﬁcationerrorintoanirreduciblepartassociatedwiththerandomnatureoftheoutputYandareduciblepartthatdependsonϕL(x),inanalogywithEquation4.3forthesquarederrorloss.(Notethat,tosimplifynotations,weassumethatallprobabilitiesbasedontherandomvariableYiswithrespecttothedistributionofYatX=x.)EL{EY|X=x{1(ϕL(x)6=Y)}}(4.8)=PL(ϕL(x)6=Y)=1−PL(ϕL(x)=Y)=1−PL(ϕL(x)=ϕB(x))P(ϕB(x)=Y)−PL(ϕL(x)6=ϕB(x))P(ϕB(x)6=Y)=P(ϕB(x)6=Y)+PL(ϕL(x)6=ϕB(x))−2PL(ϕL(x)6=ϕB(x))P(ϕB(x)6=Y)=P(ϕB(x)6=Y)+PL(ϕL(x)6=ϕB(x))(2P(ϕB(x)=Y)−1)Inthisform,theﬁrsttermistheirreducibleerroroftheBayesmodel.Thesecondtermistheincreasederrorduetothemisestima-tionoftheoptimaldecisionboundary.TheprobabilityPL(ϕL(x)6=ϕB(x))istheprobabilityforthemodelofmakingadecisionwhich60randomforests0.00.51.0PLpL(Y='B(x))VarLpL(Y='B(x))PL('L(x)'B(x)){                   }{                   }Figure4.3:ProbabilitydistributionoftheestimatebpL(Y=ϕB(x)).isdifferentfromthedecisionoftheBayesmodel.ThishappenswhentheestimatebpL(Y=ϕB(x))islowerthan0.5,thatis:PL(ϕL(x)6=ϕB(x))=PL(bpL(Y=ϕB(x))<0.5)(4.9)AsFigure4.3illustrates,probability4.9infactcorrespondstothetailareaontheleftsideofthedecisionthreshold(at0.5)ofthedistribu-tionoftheestimate.Ifwenowfurtherassume2thattheestimatebpL(Y=ϕB(x))isnormallydistributed,thenprobability4.9canbecomputedexplicitlyfromitsmeanandvariance:PL(bpL(Y=ϕB(x))<0.5)=Φ(0.5−EL{bpL(Y=ϕB(x))}pVL{bpL(Y=ϕB(x))})(4.10)whereΦ(x)=1√2πRx−∞exp(−t22)dtisthecumulativedistributionfunctionofthestandardnormaldistribution.Insummary,theex-pectedgeneralizationerroradditivelydecomposesasformulatedinTheorem4.2.Theorem4.2.Forthezero-onelossandbinaryclassiﬁcation,theexpectedgeneralizationerrorEL{Err(ϕL(x))}atX=xdecomposesasfollows:EL{Err(ϕL(x))}=P(ϕB(x)6=Y)(4.11)+Φ(0.5−EL{bpL(Y=ϕB(x))}pVL{bpL(Y=ϕB(x))})(2P(ϕB(x)=Y)−1)2Forsingledecisiontrees,thenormalassumptioniscertainlynotsatisﬁedinallcases,butthequalitativeconclusionsarestillgenerallyvalid.Whenthecomputationsoftheestimatesinvolvesomeaveragingprocess,e.g.,asfurtherdevelopedinthecaseofensembleofrandomizedtrees,thisapproximationishoweverfairlyreasonable.4.2ensemblemethodsbasedonrandomization61Asaresult,Theorem4.2establishesadirectconnectionbetweentheregressionvarianceoftheestimatesandtheclassiﬁcationerroroftheresultingmodel.Inpractice,thisdecompositionhasimportantconsequences:-WhentheexpectedprobabilityestimateEL{bpL(Y=ϕB(x)}forthetruemajorityclassisgreaterthan0.5,areductionofvarianceoftheestimateresultsinadecreaseofthetotalmisclassiﬁcationerror.IfVL{bpL(Y=ϕB(x))}→0,thenΦ→0andtheexpectedgeneralizationerrortendstotheerroroftheBayesmodel.Inparticular,thegeneralizationerrorcanbedriventoitsminimumvaluewhatevertheregressionbiasoftheestimate(atleastaslongasEL{bpL(Y=ϕB(x)}>0.5).-Conversely,whenEL{bpL(Y=ϕB(x)}<0.5,adecreaseofvari-ancemightactuallyincreasethetotalmisclassiﬁcationerror.IfVL{bpL(Y=ϕB(x))}→0,thenΦ→1andtheerrorismaximal.4.2ensemblemethodsbasedonrandomizationBoththeorems4.1and4.2revealtheroleofvarianceintheexpectedgeneralizationerrorofamodel.Inlightoftheseresults,asensibleapproachforreducinggeneralizationerrorwouldthereforeconsistindrivingdownthepredictionvariance,providedtherespectivebiascanbekeptthesameornotbeincreasedtoomuch.Asithappens,ensemblemethodsconstituteabeautifullysimplewaytodojustthat.Speciﬁcally,thecoreprincipleofensemblemethodsbasedonrandomizationistointroducerandomperturbationsintothelearningprocedureinordertoproduceseveraldifferentmodelsfromasinglelearningsetLandthentocombinethepredictionsofthosemodelstoformthepredictionoftheensemble.Howpredictionsarecombinedandwhydoesithelpisformallystudiedinthenextsections.4.2.1RandomizedmodelsGivenalearningsetL,alearningalgorithmAdeterministicallypro-ducesamodelA(θ,L),denotedϕL,θ,whereθarehyper-parameterscontrollingtheexecutionofA.Letusassumethatθincludesaran-domseedparameterformimickingsomestochasticbehaviorinA,henceproducing(pseudo-)randomizedmodelsthataremoreorlessdifferentfromonerandomseedtoanother.(WedeferthediscussiononspeciﬁcrandomperturbationsinthecaseofdecisiontreestoSec-tion4.3.)Inthiscontext,thebias-variancedecompositioncanbeextendedtoaccountforeverythingthatisrandom,henceconsideringbothL62randomforestsandθasrandomvariables3.Accordingly,theorems4.1and4.2natu-rallyextendtotheexpectedgeneralizationerrorEL,θ{Err(ϕL,θ(x))}oftherandomizedmodelϕL,θbyreplacingexpectationsEL{.}andvariancesVL{.}withtheirrespectivecounterpartsEL,θ{.}andVL,θ{.}computedoverthejointdistributionofLandθ.Inregression,thebias-variancedecompositionofthesquarederrorlossthusbecomes:EL,θ{Err(ϕL,θ(x))}=noise(x)+bias2(x)+var(x),(4.12)wherenoise(x)=Err(ϕB(x)),(4.13)bias2(x)=(ϕB(x)−EL,θ{ϕL,θ(x)})2,(4.14)var(x)=EL,θ{(EL,θ{ϕL,θ(x)}−ϕL,θ(x))2}.(4.15)Inthisform,variancenowaccountsforboththepredictionvari-abilityduetotherandomnessofthelearningsetLandthevariabil-ityduetotherandomnessofthelearningalgorithmitself.Assuch,thevarianceofarandomizedalgorithmistypicallylargerthanthevarianceofitsdeterministiccounterpart.Dependingonthestrengthofrandomization,biasalsousuallyincreases,butoftentoasmallerextentthanvariance.Whilerandomizinganalgorithmmightseemcounter-intuitive,sinceitincreasesbothvarianceandbias,wewillshowinSection4.2.3thatcombiningseveralsuchrandomizedmodelsmightactuallyachievebetterperformancethanasinglenon-randomizedmodel.4.2.2CombiningrandomizedmodelsLetusassumeasetofMrandomizedmodels{ϕL,θm|m=1,...,M},alllearnedonthesamedataLbuteachbuiltfromanindependentrandomseedθm.Ensemblemethodsworkbycombiningthepredic-tionsofthesemodelsintoanewensemblemodel,denotedψL,θ1,...,θM,suchthattheexpectedgeneralizationerroroftheensembleis(hope-fully)smallerthantheexpectedgeneralizationerroroftheindividualrandomizedmodels.Inregression,forthesquarederrorloss,themostcommonwaytocombinetherandomizedmodelsintoanensembleistoaveragetheirpredictionstoformtheﬁnalprediction:ψL,θ1,...,θM(x)=1MMXm=1ϕL,θm(x)(4.16)Therationaleisthattheaveragepredictionisthepredictionthatmini-mizestheaveragesquarederrorwithrespecttotheindividualpredic-tionsofthemodels.Inthatsense,theaveragepredictionistheclosestpredictionwithrespecttoallindividualpredictions.3Fromnowon,andwithoutlossofgenerality,weassumethattherandomvariableθonlycontrolstherandomnessofthelearningalgorithm.4.2ensemblemethodsbasedonrandomization63AmbiguitydecompositionForpredictionaveraging,asdeﬁnedinEquation4.16,theambiguitydecomposition[Kroghetal.,1995]guaranteesthegeneralizationerroroftheensembletobelowerthantheaveragegeneralizationerrorofitsconstituents.Formally,theambiguitydecompositionstatesthatErr(ψL,θ1,...,θM)=E−A(4.17)whereE=1MMXm=1Err(ϕL,θm),(4.18)A=EX{1MMXm=1(ϕL,θm(X)−ψL,θ1,...,θM(X))2}.(4.19)Theﬁrsttermistheaveragegeneralizationerroroftheindividualmodels.Thesecondtermistheensembleambiguityandcorrespondstothevarianceoftheindividualpredictionsaroundthepredictionoftheensemble.SinceAisnon-negative,thegeneralizationerroroftheensembleisthereforesmallerthantheaveragegeneralizationerrorofitsconstituents.Inclassiﬁcation,forthezero-oneloss,predictionsareusuallyag-gregatedbyconsideringthemodelsintheensembleasacommitteeandthenresortingtomajorityvotingtoformtheﬁnalprediction:ψL,θ1,...,θM(x)=argmaxc∈YMXm=11(ϕL,θm(x)=c)(4.20)Similarly,therationaleisthatthemajoritypredictionisthepredictionthatminimizestheaveragezero-oneerrorwithrespecttotheindivid-ualpredictions.Alternatively,whenindividualmodelsprovideclassprobabilityestimatesbpL,θm(Y=c|X=x),softvoting[Zhou,2012]consistsinaveragingtheclassprobabilityestimatesandthenpredicttheclasswhichisthemostlikely:ψL,θ1,...,θM(x)=argmaxc∈Y1MMXm=1bpL,θm(Y=c|X=x)(4.21)AsempiricallyinvestigatedbyBreiman[1994],bothapproachesyieldresultsthatarenearlyidentical4.Fromapracticalpointofviewhow-ever,Equation4.21hastheadvantageofprovidingsmootherclassprobabilityestimatesfortheensemble,whichmayprovetobeusefulincriticalapplications,e.g.,when(estimatesof)thecertaintyabout4InthecaseofensemblesoffullydevelopeddecisiontreesthatperfectlyclassifyallsamplesfromL,majorityvotingandsoftvotingareexactlyequivalent.64randomforestspredictionsisasimportantasthepredictionsthemselves.Addition-ally,combiningpredictionsinthiswaymakesiteasytostudytheexpectedgeneralizationerroroftheensemble–itsufﬁcestoplugtheaveragedestimatesintoTheorem4.2.Forthesereasons,andfortherestofthiswork,predictionsinclassiﬁcationarenowassumedtobecombinedwithsoftvoting(seeEquation4.21)unlessmentionedotherwise.Condorcet’sjurytheoremMajorityvoting,asdeﬁnedinEquation4.20,ﬁndsitsoriginsintheCondorcet’sjurytheoremfromtheﬁeldofpoliticalscience.LetconsideragroupofMvotersthatwishestoreachadecisionbymajorityvote.Thetheoremstatesthatifeachvoterhasanindependentprobabilityp>12ofvotingforthecorrectdecision,thenaddingmorevotersin-creasestheprobabilityofthemajoritydecisiontobecorrect.WhenM→∞,theprobabilitythatthedecisiontakenbythegroupiscor-rectapproaches1.Conversely,ifp<12,theneachvoterismorelikelytovoteincorrectlyandincreasingMmakesthingsworse.4.2.3Bias-variancedecompositionofanensembleLetusnowstudythebias-variancedecompositionoftheexpectedgeneralizationerrorofanensembleψL,θ1,...,θM,ﬁrstinthecaseincaseofregressionandthenforclassiﬁcation.Tosimplifynotationsintheanalysisbelow,letusdenotethemeanpredictionatX=xofasinglerandomizedmodelϕL,θmanditsrespectivepredictionvarianceas:µL,θm(x)=EL,θm{ϕL,θm(x)}(4.22)σ2L,θm(x)=VL,θm{ϕL,θm(x)}(4.23)4.2.3.1RegressionFromTheorem4.1,theexpectedgeneralizationerrorofanensembleψL,θ1,...,θMmadeofMrandomizedmodelsdecomposesintoasumofnoise(x),bias2(x)andvar(x)terms.ThenoisetermonlydependsontheintrinsicrandomnessofY.Itsvaluestaysthereforethesame,nomatterthelearningalgorithm:noise(x)=EY|X=x{(Y−ϕB(x))2}(4.24)The(squared)biastermisthe(squared)differencebetweenthepre-dictionoftheBayesmodelandtheaveragepredictionofthemodel.Foranensemble,theaveragepredictionisinfactthesameastheav-4.2ensemblemethodsbasedonrandomization65eragepredictionofthecorrespondingrandomizedindividualmodel.Indeed,EL,θ1,...,θM{ψL,θ1,...,θM(x)}=EL,θ1,...,θM{1MMXm=1ϕL,θm(x)}=1MMXm=1EL,θm{ϕL,θm(x)}=µL,θ(x)(4.25)sincerandomvariablesθmareindependentandallfollowthesamedistribution.Asaresult,bias2(x)=(ϕB(x)−µL,θ(x))2,(4.26)whichindicatesthatthebiasofanensembleofrandomizedmodelsisthesameasthebiasofanyoftherandomizedmodels.Putotherwise,combiningrandomizedmodelshasnoeffectonthebias.Onvarianceontheotherhand,ensemblemethodsshowalltheirraisond’etre,virtuallyreducingthevariabilityofpredictionstoal-mostnothingandtherebyimprovingtheaccuracyoftheensemble.BeforeconsideringthevarianceofψL,θ1,...,θM(x)however,letusﬁrstderivethecorrelationcoefﬁcientρ(x)betweenthepredictionsoftworandomizedmodelsbuiltonthesamelearningset,butgrownfromtwoindependentrandomseedsθ0andθ00.FromthedeﬁnitionofthePearson’scorrelationcoefﬁcient,itcomes:ρ(x)=EL,θ0,θ00{(ϕL,θ0(x)−µL,θ0(x))(ϕL,θ00(x)−µL,θ00(x))}σL,θ0(x)σL,θ00(x)=EL,θ0,θ00{ϕL,θ0(x)ϕL,θ00(x)−ϕL,θ0(x)µL,θ00(x)−ϕL,θ00(x)µL,θ0(x)+µL,θ0(x)µL,θ00(x)}σ2L,θ(x)=EL,θ0,θ00{ϕL,θ0(x)ϕL,θ00(x)}−µ2L,θ(x)σ2L,θ(x)(4.27)bylinearityoftheexpectationandexploitingthefactthatrandomvariablesθ0andθ00followthesamedistribution.Intuitively,ρ(x)rep-resentsthestrengthoftherandomperturbationsintroducedinthelearningalgorithm.Whenitiscloseto1,predictionsoftworandom-izedmodelsarehighlycorrelated,suggestingthatrandomizationhasnosensibleeffectonthepredictions.Bycontrast,whenitiscloseto0,predictionsoftherandomizedmodelsaredecorrelated,hencein-dicatingthatrandomizationhasastrongeffectonthepredictions.Atthelimit,whenρ(x)=0,predictionsoftwomodelsbuiltonthesamelearningsetLareindependent,whichhappenswhentheyareper-fectlyrandom.AsprovedlaterwithEquation4.31,letusﬁnallyalsoremarkthatthecorrelationtermρ(x)isnon-negative,whichconﬁrmsthatrandomizationhasadecorrelationeffectonly.66randomforestsFromEquation4.27,thevarianceofψL,θ1,...,θM(x)cannowbede-rivedasfollows:var(x)=VL,θ1,...,θM{1MMXm=1ϕL,θm(x)}=1M2"EL,θ1,...,θM{(MXm=1ϕL,θm(x))2}−EL,θ1,...,θM{MXm=1ϕL,θm(x)}2#byexploitingthefactsthatV{aX}=a2V{X},V{X}=E{X2}−E{X}2andthelinearityofexpectation.ByrewritingthesquareofthesumoftheϕL,θm(x)termsasasumoverallpairwiseproductsϕL,θi(x)ϕL,θj(x),thevariancecanfurtherberewrittenas:=1M2"EL,θ1,...,θM{Xi,jϕL,θi(x)ϕL,θj(x)}−(MµL,θ(x))2#=1M2"Xi,jEL,θi,θj{ϕL,θi(x)ϕL,θj(x)}−M2µ2L,θ(x)#=1M2"MEL,θ{ϕL,θ(x)2},→+(M2−M)EL,θ0,θ00{ϕL,θ0(x)ϕL,θ00(x)}−M2µ2L,θ(x)#=1M2"M(σ2L,θ(x)+µ2L,θ(x)),→+(M2−M)(ρ(x)σ2L,θ(x)+µ2L,θ(x))−M2µ2L,θ(x)#=σ2L,θ(x)M+ρ(x)σ2L,θ(x)−ρ(x)σ2L,θ(x)M=ρ(x)σ2L,θ(x)+1−ρ(x)Mσ2L,θ(x)(4.28)Asthesizeoftheensemblegetsarbitrarilylarge,i.e.,asM→∞,thevarianceoftheensemblereducestoρ(x)σ2L,θ(x).Undertheas-sumptionthatrandomizationhassomeeffectonthepredictionsofrandomizedmodels,i.e.,assumingρ(x)<1,thevarianceofanen-sembleisthereforestrictlysmallerthanthevarianceofanindividualmodel.Asaresult,theexpectedgeneralizationerrorofanensembleisstrictlysmallerthantheexpectederrorofarandomizedmodel.Assuch,improvementsinpredictionsaresolelytheresultofvariancereduction,sincebothnoise(x)andbias2(x)remainunchanged.Addi-tionally,whenrandomeffectsarestrong,i.e.,whenρ(x)→0,variancereducestoσ2L,θ(x)M,whichcanfurtherbedrivento0byincreasingthesizeoftheensemble.Ontheotherhand,whenrandomeffectsareweak,i.e.,whenρ(x)→1,thenvariancereducestoσ2L,θ(x)andbuild-inganensemblebringsnobeneﬁt.Putotherwise,thestrongerthe4.2ensemblemethodsbasedonrandomization67randomeffects,thelargerthereductionofvarianceduetoensem-bling,andvice-versa.Insummary,theexpectedgeneralizationerrorofanensemblead-ditivelydecomposesasstatedinTheorem4.3.Theorem4.3.Forthesquarederrorloss,thebias-variancedecompositionoftheexpectedgeneralizationerrorEL{Err(ψL,θ1,...,θM(x))}atX=xofanensembleofMrandomizedmodelsϕL,θmisEL{Err(ψL,θ1,...,θM(x))}=noise(x)+bias2(x)+var(x),(4.29)wherenoise(x)=Err(ϕB(x)),bias2(x)=(ϕB(x)−EL,θ{ϕL,θ(x)})2,var(x)=ρ(x)σ2L,θ(x)+1−ρ(x)Mσ2L,θ(x).InlightofTheorem4.3,thecoreprincipleofensemblemethodsisthustointroducerandomperturbationsinordertodecorrelateasmuchaspossiblethepredictionsoftheindividualmodels,therebymaximizingvariancereduction.However,randomperturbationsneedtobecarefullychosensoastoincreasebiasaslittleaspossible.Thecruxoftheproblemistoﬁndtherighttrade-offbetweenrandomnessandbias.AlternativevariancedecompositionGeurts[2002](Chapter4,Equation4.31)alternativelydecomposestheensemblevarianceasvar(x)=VL{Eθ|L{ϕL,θ(x)}}+1MEL{Vθ|L{ϕL,θ(x)}}.(4.30)Theﬁrsttermofthisdecompositionisthevarianceduetotherandom-nessofthelearningsetL,averagedovertherandomperturbationsduetoθ.Itmeasuresthedependenceofthemodelonthelearningset,independentlyofθ.Thesecondtermistheexpectationoveralllearn-ingsetsofthevariancewithrespecttoθ.Itmeasuresthestrengthoftherandomeffects.Asthedecompositionshows,onlythislastpartofthevariancecanbereducedasaresultofaveraging,whichisconsistentwithourpreviousconclusions.Thestrongertherandomeffects,thelargerthevariancewithrespecttoθ,andhencethelargerofreductionofvarianceduetoensembling.Proposition4.4.Decompositions4.28and4.30ofthepredictionvarianceforanensembleareequivalent.Proof.FromEquations4.28and4.30,equivalenceholdsifEqua-tion4.27isequivalenttoρ(x)=VL{Eθ|L{ϕL,θ(x)}}VL{Eθ|L{ϕL,θ(x)}}+EL{Vθ|L{ϕL,θ(x)}}.(4.31)68randomforestsFromthelawoftotalvariance,thedenominatorofEquation4.27ex-pandstothedenominatorofEquation4.31:σ2L,θ(x)=VL{Eθ|L{ϕL,θ(x)}}+EL{Vθ|L{ϕL,θ(x)}}(4.32)Similarly,thenumeratorofEquation4.31canbereexpressedasthenumeratorofEquation4.27,therebyprovingtheequivalence:VL{Eθ|L{ϕL,θ(x)}}=EL{(Eθ|L{ϕL,θ(x)}−EL{Eθ|L{ϕL,θ(x)}})2}=EL{(Eθ|L{ϕL,θ(x)}−µL,θ(x))2}=EL{Eθ|L{ϕL,θ(x)}2}−µ2L,θ(x)=EL{Eθ0|L{ϕL,θ0(x)}Eθ00|L{ϕL,θ00(x)}}−µ2L,θ(x)=EL,θ0,θ00{ϕL,θ0(x)ϕL,θ00(x)}−µ2L,θ(x).(4.33)Inthisform,ρ(x)isinterpretedastheratiobetweenthevarianceduetothelearningsetandthetotalvariance,accountingforrandomeffectsduetoboththelearningsetandtherandomperturbations.Itiscloseto1whenvarianceismostlyduetothelearningset,henceyieldingcorrelatedpredictions.Conversely,itiscloseto0whenvari-anceismostlyduetotherandomperturbationsinducedbyθ,hencedecorrelatingthepredictions.4.2.3.2ClassiﬁcationThedecompositionoftheexpectedgeneralizationerrorofanensem-bleinclassiﬁcationdirectlyfollowsfromtheorems4.2and4.3.Build-inganensemblealwaysreducesthevarianceoftheclassprobabilityestimateEL,θ{bpL,θ(Y=ϕB(x)}(asshowninEquation4.28),whichresultsinadecreaseofthemisclassiﬁcationerroriftheexpectedesti-materemainsstrictlygreaterthan0.5inarandomizedmodel.ShortcomingsaddressedbyensemblesIncomplementwiththeformalbias-varianceanalysiscarriedoutintheprevioussection,Dietterich[2000b]identiﬁesthreefundamentalreasonsintuitivelyexplainingwhyensemblesoftenworkbetterthansinglemodels.Theﬁrstreasonisstatistical.Whenthelearningsetistoosmall,alearningalgorithmcantypicallyﬁndseveralmodelsinthehypothe-sisspaceHthatallgivethesameperformanceonthetrainingdata.Providedtheirpredictionsareuncorrelated,averagingseveralmodelsreducestheriskofchoosingthewronghypothesis.4.3randomforests69Thesecondreasoniscomputational.Manylearningalgorithmsrelyonsomegreedyassumptionorlocalsearchthatmaygetstuckinlocaloptima.Assuch,anensemblemadeofindividualmodelsbuiltfrommanydifferentstartingpointsmayprovideabetterapproximationofthetrueunknownfunctionthatanyofthesinglemodels.Finally,thethirdreasonisrepresentational.Inmostcases,foralearningsetofﬁnitesize,thetruefunctioncannotberepresentedbyanyofthecandidatemodelsinH.Bycombiningseveralmodelsinanensemble,itmaybepossibletoexpandthespaceofrepresentablefunctionsandtobettermodelthetruefunction.4.3randomforestsRandomforests5formafamilyofmethodsthatconsistinbuildinganensemble(orforest)ofdecisiontreesgrownfromarandomizedvari-antofthetreeinductionalgorithm(asdescribedinChapter3).Deci-siontreesareindeedidealcandidatesforensemblemethodssincetheyusuallyhavelowbiasandhighvariance,makingthemverylikelytobeneﬁtfromtheaveragingprocess.Aswewillreviewinthissection,randomforestsmethodsmostlydifferfromeachotherinthewaytheyintroducerandomperturbationsintotheinductionproce-dure.Ashighlightedintheprevioussection,thedifﬁcultyistoinjectrandomnesswhileminimizingρ(x)andsimultaneouslymaintainingalowbiasintherandomizeddecisiontrees.4.3.1RandomizedinductionalgorithmsKwokandCarter[1990]:Historically,theearliestmentionofensembleofdecisiontreesisduetoKwokandCarter[1990].Inthiswork,theauthorsempiricallyobservethataveragingmultipledecisiontreeswithdifferentstructureconsistentlyproducesbetterresultsthananyoftheconstituentsoftheensemble.Thisapproachhoweverwasnotbasedonrandomizationnorwasfullyautomatic:decisiontreesweregeneratedbyﬁrstmanuallyselectingatthetopofthetreesplitsthatwerealmostasgoodastheoptimalsplits,andthenexpandedusingtheclassicalID3inductionprocedure.Breiman[1994]:Inanowfamoustechnicalreport,Breiman[1994]wasoneoftheearliesttoshow,boththeoreticallyandempirically,thatag-5Thetermrandomforests,withoutcapitals,isusedtodenoteanyensembleofdecisiontrees.Speciﬁcvariantsarereferredtousingtheiroriginaldesignation,denotedwithcapitals.Inparticular,theensemblemethodduetoBreiman[2001]isdenotedasRandomForests,withcapitals.70randomforestsgregatingmultipleversionsofanestimatorintoanensemblecangivesubstantialgainsinaccuracy.HenotesandshowsthattheaveragemodelEL{ϕL}hasalowerexpectedgener-alizationerrorthanϕL.Assuch,Baggingconsistsinapproxi-matingEL{ϕL}bycombiningmodelsbuiltfrombootstrapsam-ples[Efron,1979]Lm(form=1,...,M)ofthelearningsetL.The{Lm}formreplicatesofL,eachconsistingofNcases(x,y),drawnatrandombutwithreplacementfromL.Notethateventhough|L|=|Lm|=N,37%ofthecouples(x,y)fromLareonaveragemissinginthebootstrapreplicates.In-deed,afterNdrawswithreplacement,theprobabilityofneverhavebeenselectedis(1−1N)N≈1e≈0.368.(4.34)Whenthelearningalgorithmisunstable(i.e.,whensmallchangesinthelearningsetcancauselargechangesinthelearnedmod-els),Bagginggeneratesindividualmodelsthataredifferentfromonebootstrapsampletoanother,hencemakingthemlikelytobeneﬁtfromtheaveragingprocess.Insomecaseshowever,whenthelearningsetLissmall,subsampling67%oftheobjectsmightleadtoanincreaseofbias(e.g.,becauseofadecreaseinmodelcomplexity)whichistoolargetobecompensatedbyadecreaseofvariance,henceresultinginoverallpoorerper-formance.Despitethisdefect,Bagginghasproventobeanef-fectivemethodinnumerousapplications,oneofitsstrengthsbeingthatitcanbeusedtocombineanykindofmodels–i.e.,notonlydecisiontrees.DietterichandKong[1995]:Buildingupon[KwokandCarter,1990],DietterichandKong[1995]proposetorandomizethechoiceofthebestsplitatagivennodebyselectinguniformlyatrandomoneofthe20bestsplitsofnodet.Theauthorsempiricallyshowin[DietterichandKong,1995;Dietterich,2000a]thatrandomizinginthiswaygivesresultsthatareslightlybetterthanBagginginlownoisesettings.Experimentsshowhoweverthatwhennoiseisimpor-tant,Baggingusuallyyieldbetterresults.Fromabias-variancepointofview,thismethodvirtuallydoesnotchangebiasbutincreasesvarianceduetorandomization.Amitetal.[1997]:Inthecontextofhandwrittencharacterrecognition,wherethenumberpofinputvariablesistypicallyverylarge,Amitetal.[1997]proposearandomizedvariantofthetreeinductionalgo-rithmthatconsistsinsearchingforthebestsplitateachnodeoverarandomsubsampleofthevariables.4.3randomforests71DenotingK6p(alsoknownasmtryormax_features)thenum-berofvariableseffectivelyconsideredateachnode,thisvariantreplacesAlgorithm3.3withthefollowingrandomizedalterna-tive:Algorithm4.1.Findthebestsplits∗thatpartitionsLt,amongarandomsubsetofK6pinputvariables.1:functionFindBestSplitRandom(Lt,K)2:∆=−∞3:DrawKrandomindicesjkfrom1,...,p4:fork=1,...,Kdo5:Findthebestbinarysplits∗jkdeﬁnedonXjk6:if∆i(s∗jk,t)>∆then7:∆=∆i(s∗jk,t)8:s∗=s∗jk9:endif10:endfor11:returns∗12:endfunctionWhentheoutputYcanbeexplainedinseveralways,thisran-domizedalgorithmgeneratestreesthatareeachstructurallydif-ferent,yetindividuallygood.Asaresult,biasusuallyincreasesonlyslightly,whiletheincreasedvarianceduetorandomizationcanbecancelledoutthroughaveraging.Theoptimaltrade-offbetweenthesequantitiescanotherwisebeadjustedbytuningthevalueofK.AsK→1,thelargerthebiasbutthelargerthevarianceoftheindividualmodelsandhencethemoreeffectivetheaveragingprocess.Conversely,asK→p,thesmallerthebiasbutalsothesmallerthevarianceoftheindividualmodelsandthereforethelessbeneﬁcialtheensemble.Ho[1998]:InspiredfromtheprinciplesofBagging[Breiman,1994]andrandomsubsetsofvariables[Amitetal.,1997],Ho[1998]pro-poseswiththeRandomSubspace(RS)methodtobuildadecisionforestwhosetreesaregrownonrandomsubsetsoftheinputvariables–drawnonce,priortotheconstructionofeachtree–ratherthanonallpvariables.Asempiricallyevaluatedatseveraloccasions[Ho,1998;PanovandDžeroski,2007;LouppeandGeurts,2012],theRandomSubspacemethodisapowerfulgenericensemblemethodthatcanachievenearstate-of-the-artperformanceonmanyproblems.Again,theoptimaltrade-offbetweenthevarianceduetorandomizationandtheincreaseofbiascanbecontrolledbytuningthesizeoftherandomsubset.Breiman[2001]:InhisseminalRandomForests(RF)paper,Breiman[2001]com-72randomforestsbinesBagging[Breiman,1994]withrandomvariableselectionateachnode[Amitetal.,1997].Injectingrandomnesssimulta-neouslywithbothstrategiesyieldsonethemosteffectiveoff-the-shelfmethodsinmachinelearning,workingsurprisinglywellforalmostanykindofproblems.TheauthorempiricallyshowsthatRandomForestsgiveresultsthatarecompetitivewithboosting[FreundandSchapire,1995]andarcingalgorithms[Breiman,1996],whichbotharedesignedtoreducebiaswhileforestsfocusonvariancereduction.Whiletheoriginalprinciplesareduetoseveralauthors(asdis-cussedabove),Breimanisoftencitedasthefatherofforestsofrandomizedtrees.Partsofthisrecognitionarecertainlyduetothepioneertheoreticalanalysisthathasalwayscomplementedhisempiricalanalysisofalgorithms.Incontrastwithotherau-thors,anotherreasonmightalsobehisefﬁcientsoftwareim-plementation[Breiman,2002]thatwasmadefreelyavailable,allowingusersoutsideofthemachinelearningcommunitytoquicklyandeasilyapplyRandomForeststotheirproblems.CutlerandZhao[2001]:WithPerfectRandomTreeEnsembles(PERT),CutlerandZhao[2001]proposetogrowaforestofperfectlyﬁtdecisiontreesinwhichboththe(ordered)variabletosplitonandthedis-cretizationthresholdarechosenatrandom.Morespeciﬁcally,givenanodet,thesplitvariableXjisdrawnatrandomusingAlgorithm4.1withK=1whilethecut-pointvissetmidwaybetweentworandomlydrawnsamplesusingthefollowingpro-cedure(insteadofAlgorithm3.4):Algorithm4.2.DrawarandomsplitonXjthatpartitionsLt.1:functionFindRandomSplit-PERT(Lt,Xj)2:Draw(x1,y1),(x2,y2)∈Ltsuchthaty16=y23:Drawαuniformlyatrandomfrom[0,1]4:v=αx1,j+(1−α)x2,j5:returnsvj6:endfunctionTheinductionofthetreeproceedsusingsuchrandomsplitsuntilallnodesbecomepureoruntilitisnolongerpossibletodrawsamplesofdifferentoutputvalues.Fromapracticalpointofview,PERTisaneasilycodedandaveryefﬁcientensemblemethodsincethereisnoimpuritycrite-riontoevaluatewhensplittingthenodesofatree.Regardingaccuracy,experimentalcomparisonsin[CutlerandZhao,2001]showthatPERTisoftennearlyasgoodasRandomForests[Breiman,2001],whileresultinghoweverinrandomtreesthat4.3randomforests73aretypicallylargerthandecisiontreesgrownwithlessran-domization.Thesimplicityofthemethodalsoallowsforanamenabletheoreticalanalysisofforestsofrandomizedtrees,ascarriedoutin[Zhao,2000].Geurtsetal.[2006a]:Asinvestigatedin[Wehenkel,1997;GeurtsandWehenkel,2000],thenotoriouslyhighvarianceofdecisiontreespartlyﬁndsitsoriginsfromthehighdependenceofthesplitswiththerandomnatureofthelearningset.Theauthorsempiricallyshowthatthevarianceoftheoptimalcut-pointv(inthecaseoforderedinputvariables)mayindeedbeveryhigh,evenforlargesamplesizes.Inparticular,Geurts[2002]showsthatcut-pointvarianceappearstoberesponsibleforasigniﬁcantpartofthegeneraliza-tionerrorofdecisiontrees.Asawaytosmoothenthedecisionboundary,Geurtsetal.[2006a]henceproposeinExtremelyRan-domizedTrees(ETs)tocombinerandomvariableselection[Amitetal.,1997]withrandomdiscretizationthresholds.Asadrop-inreplacementofAlgorithm3.4,theauthorsproposethefol-lowingsimplisticbuteffectiveprocedurefordrawingsplitsatrandom:Algorithm4.3.DrawarandomsplitonXjthatpartitionsLt.1:functionFindRandomSplit-ETs(Lt,Xj)2:minj=min({xi,j|(xi,yi)∈Lt})3:maxj=max({xi,j|(xi,yi)∈Lt})4:Drawvuniformlyatrandomfrom[minj,maxj[5:returnsvj6:endfunctionWithrespecttodecomposition4.30ofvariance,extremelyran-domizedtreescanthereforebeseenasawaytotransfercut-pointvariancefromthevariancetermduetothelearningsettothe(reducible)variancetermthatisduetorandomeffects.InthespecialcasewhereK=1,ExtremelyRandomizedTreesreducetoTotallyRandomizedTrees,inwhichbothasinglevari-ableXjandadiscretizationthresholdvaredrawnatrandomateachnode.Asaresult,thestructureofsuchtreescanbelearnedinanunsupervisedway,independentlyoftheoutputvariableY.Inthissetting,TotallyRandomizedTreesareveryclosetoPerfectRandomTreeEnsembles[CutlerandZhao,2001]sincebothdrawXjandvatrandom.Thesemethodsarehowevernotstrictlyequivalentsincetheydonotdrawtherandomdiscretiza-tionthresholdsvwithrespecttothesameprobabilitydistribu-tion.Rodriguezetal.[2006]:Inadifferentdirection,Rodriguezetal.[2006]proposeinRo-74randomforeststationForeststogeneraterandomizeddecisiontreesbasedonfeatureextraction.AsinBagging[Breiman,1994],individualde-cisiontreesarebuiltonbootstrapreplicatesLmofthelearningsetL.Tofurtherenhancediversity(i.e.,tofurtherdecorrelatethepredictionsoftheconstituentsoftheensemble),foreachoftheMbootstrapreplicates,inputvariablesarerandomlyparti-tionedintoqsubsetsofpqvariables,principalcomponentanal-ysis(PCA)isrunseparatelyoneachsubset,andanewsetgLmofpextractedinputvariablesisconstructedbypoolingallprin-cipalcomponentsfromtheqprojections.Inthisway,bootstrapreplicatesLmareeachindependentlytransformedlinearlyintoanewinputspaceusingqaxisrotations.Inthisframework,de-cisiontreesareparticularlysuitedbecausetheyaresensitivetochangesintheinputspaceandstillcanbeveryaccurate.Asreportedin[Rodriguezetal.,2006;KunchevaandRodríguez,2007],RotationForestsfavorablycomparewithothertree-basedensemblemethods,yieldingresultsthatareoftenasgood,some-timesbetter,thanRandomForests[Breiman,2001].Intermsofcomplexityhowever,thecomputationaloverheadduetotheqaxisrotationsshouldnotbeoverlookedwhenresourcesarelim-ited.4.3.2IllustrationAsasummaryandillustrativeexample,letusconsiderasimulatedtoyregressionproblemsuchthatY=5Xj=1Xj,(4.35)whereallinputvariablesX1,...,X5areindependentrandomGaus-sianvariablesofzeromeanandunitvariance.Tosimulatenoiseinthedata,5additionalrandomGaussianinputvariablesX6,...,X10,allindependentfromY,arefurtherappendedtothelearningset.Letuscompareforthisproblemthebias-variancedecompositionoftheexpectedgeneralizationerrorofaRandomForest[Breiman,2001](RF)andofExtremelyRandomizedTrees[Geurtsetal.,2006a](ETs).Forbothmethods,theerrorisestimatedasderivedfromTheorem4.3,using100randomlydrawnlearningsetsLof50samples,onwhichensemblesof10treesarebuilt.Theirgeneralizationerrorisestimatedonanindependenttestsetof1000samples.AstheleftplotinFigure4.4shows,theexpectedgeneralizationerroradditivelydecomposesinto(squared)biasandvarianceterms.ForsmallvaluesofK,randomeffectsarestrong,leadingtohighbiasandlowvariance.Bycontrast,forlargervaluesofK,randomeffectsarelessimportant,reducingbiasbutincreasingvariance.Forbothmethods,toosmallavalueofKappearshowevertoleadtoatoo4.3randomforests7512345678910K0.51.01.52.02.53.03.54.0RandomForestExtremelyRandomizedTrees12345678910K0.040.060.080.100.120.140.160.18ρFigure4.4:(Left)Bias-variancedecompositionofthegeneralizationerrorwithrespecttothehyper-parameterK.Thetotalerrorisshownbytheplainlines.Biasandvariancetermsarerespectivelyshownbythedashedanddottedlines.(Right)Averagecorrelationcoef-ﬁcientρ(x)overthepredictionsoftworandomizedtreesgrownfromthesamelearningsetbutwithdifferentrandomseeds.5101520M012345var(x)ρ(x)σ2L,θ1−ρ(x)Mσ2L,θFigure4.5:Decompositionofthevariancetermvar(x)withrespecttothenumberMoftreesintheensemble.76randomforestslargeincreaseofbias,forwhichaveragingisnotabletocompensate.ForRF,theoptimaltrade-offisatK=8,whichindicatesthatbaggingandrandomvariableselectionareherecomplementarywithregardtothelevelofrandomnessinjectedintothetrees.Indeed,usingbag-gingonly(atK=10)forrandomizingtheconstructionofthetreesyieldresultsthatareslightlyworsethanwhenbothtechniquesarecombined.ForETs,theoptimaltrade-offisatK=10,suggestingthatrandomthresholdsvprovidebythemselvesenoughrandomizationonthisproblem.TherightplotofFigure4.4illustratesthe(averaged)correlationco-efﬁcientρ(x)betweenthepredictionsoftworandomizedtreesgrownonthesamelearningset.Asexpected,thesmallerK,thestrongertherandomeffects,thereforethelesscorrelatedthepredictionsandthemorevariancecanbereducedfromaveraging.TheplotalsoconﬁrmsthatETsareinherentlylesscorrelatedthantreesbuiltinRF,whichisnotsurprisinggiventhefactthattheformermethodrandomizesthechoiceofthediscretizationthresholdwhilethelatterdoesnot.Incaseswheresucharandomizationdoesnotinducetoolargeanincreaseofbias,asinthisproblem,ETsarethereforeexpectedtoyieldbetterresultsthanRF.(Thechoiceoftheoptimalrandomizationstrategyishoweverhighlydependentontheproblemandnogeneralconclusionshouldbedrawnfromthistoyregressionproblem.)AsconﬁrmedbyFigure4.5forRF,variancealsoadditivelydecom-posesintovar(x)=ρ(x)σ2L,θ(x)+1−ρ(x)Mσ2L,θ(x).(4.36)TheﬁrsttermisthevarianceduetothelearningsetLandremainsconstantasthenumberMoftreesincreases.ThesecondtermisthevarianceduetorandomeffectsanddecreasesasMincreases.OfparticularinterestisvarianceatM=1,whichcorrespondstothevarianceofasingledecisiontree.Astheﬁgureclearlyshows,aver-agingseveraldecisiontreesintoanensembleallowstosigniﬁcantlyreducethisquantity.Atthelimit,whenM→∞,variancetendstoρ(x)σ2L,θ(x),asshownbythedottedlineandasexpectedfromTheo-rem4.3.4.4propertiesandfeatures4.4.1Out-of-bagestimatesAninterestingfeatureofensemblemethodsthatconstructmodelsonbootstrapsamples,likeBaggingorRandomForests,isthebuilt-inpossibilityofusingtheleft-outsamplesL\Lmtoformestimatesofimportantstatistics.Inthecaseofgeneralizationerror,theout-of-bagestimateat(xi,yi)consistsinevaluatingthepredictionofthe4.4propertiesandfeatures77ensembleusingonlytheindividualmodelsϕLmwhosebootstrapsamplesLmdidnotinclude(xi,yi).Thatis,inregression,dErrOOB(ψL)=1NX(xi,yi)∈LL(1M−iM−iXl=1ϕLmkl(xi),yi),(4.37)wheremk1,...,mkM−idenotetheindicesofM−ithetreesthathavebeenbuiltfrombootstrapreplicatesthatdonotinclude(xi,yi).Forclassiﬁcation,theout-of-bagestimateofthegeneralizationerrorissimilartoEquation4.37,exceptthattheout-of-bagaveragepredictionisreplacedwiththeclasswhichisthemostlikely,ascomputedfromtheout-of-bagclassprobabilityestimates.Out-of-bagestimatesprovideaccurateestimatesofthegeneraliza-tionerroroftheensemble,oftenyieldingstatisticsthatareasgoodorevenmoreprecisethanK-foldcross-validationestimates[WolpertandMacready,1999].Inpractice,out-of-bagestimatesalsoconstituteacomputationallyefﬁcientalternativetoK-foldcross-validation,re-ducingtoMthenumberofinvocationsofthelearningalgorithm,insteadofotherwisehavingtobuildK×Mbasemodels.Whileout-of-bagestimatesconstituteanhelpfultool,theirbene-ﬁtsshouldhoweverbeputinbalancewiththepotentialdecreaseofaccuracythattheuseofbootstrapreplicatesmayinduce.Asshownexperimentallyin[LouppeandGeurts,2012],bootstrappingisinfactrarelycrucialforrandomforeststoobtaingoodaccuracy.Onthecon-trary,notusingbootstrapsamplesusuallyyieldbetterresults.4.4.2VariableimportancesInmostmachinelearningtasks,thegoalisnotonlytoﬁndthemostaccuratemodeloftheresponsebutalsotoidentifywhichofthein-putvariablesarethemostimportanttomakethepredictions,e.g.,inordertoleadtoadeeperunderstandingoftheproblemunderstudy.Inthiscontext,randomforestsofferseveralmechanismsforassess-ingtheimportanceofaninputvariable,andthereforeenhancetheinterpretabilityofthemodel.ThesearetheobjectofChapter6,inwhichwestudyvariableimportancemeasuresanddeveloporiginalcontributionstofurtherimprovetheirunderstanding.4.4.3ProximitymeasuresAnotherhelpfulbuilt-infeatureoftree-basedensemblemethodsistheproximitymeasure[Breiman,2002]betweentwosamplepoints.For-mally,theproximitybetween(x1,y1)and(x2,y2)isdeﬁnedasthenumberoftimesbothsamplesreachthesameleaftwithineachde-78randomforests0123456789Figure4.6:Proximityplotfora10-classhandwrittendigitclassiﬁcationtask.cisiontree,normalizedbythenumberoftreesintheforest.Thatis,proximity(x1,x2)=1MMXm=1Xt∈eϕL,θm1(x1,x2∈Xt)(4.38)whereeϕL,θmdenotesthesetofterminalnodesinϕL,θm.Theideaisthattheproximitymeasuregivesanindicationofhowclosethesamplesareintheeyesoftherandomforest[Hastieetal.,2005],evenifthedataishigh-dimensionalorinvolvesmixedinputvari-ables.Whenproximityiscloseto1,samplespropagateintothesameleavesandarethereforesimilaraccordingtotheforest.Ontheotherhand,whenitiscloseto0,samplesreachdifferentleaves,suggest-ingthattheyarestructurallydifferentfromeachother.Theproximitymeasuredependsonboththedepthandthenumberoftreesintheforest.Whentreesareshallow,samplesaremorelikelytoendupinthesameleavesthanwhentreesaregrownmoredeeply,therebyim-pactingonthespreadofthemeasure.Likewise,themoretreesintheforest,thesmootherthemeasuresincethelargerthenumberM+1ofvaluestheproximitymeasurecantake.Forexploratorypurposes,theN×NproximitymatrixPsuchthatPij=proximity(xi,xj),(4.39)canbeusedtovisuallyrepresenthowsamplesareclosetogetherwithrespecttotherandomforest.Using1−Pasadissimilaritymatrix,the4.4propertiesandfeatures79levelofsimilaritybetweenindividualsamplescanbevisualizede.g.,byprojectingthemonad-dimensionalspace(e.g.,onaplane)suchthatthedistancesbetweenanypairofsamplesinthatspacecorre-spondasbestaspossibletothedissimilaritiesin1−P.Asanillustra-tiveexample,Figure4.6representstheproximitymatrixlearnedfora10-classhandwrittendigitclassiﬁcationtask,asprojectedonaplaneusingMultidimensionalScaling[Kruskal,1964].Samplesfromasameclassformidentiﬁableclusters,whichsuggeststhattheysharesimilarstructure(sincetheyendupinthesameleaves).Theﬁgurealsohigh-lightsclassesforwhichtherandomforestmakeserrors.Inthiscase,digits1and8arethemoredispersed,suggestinghighwithin-classvariance,butalsooverlapthemostwithsamplesofotherclasses,in-dicatingthattherandomforestfailstoidentifythetrueclassforthesesamples.Additionally,proximitymeasurescanbeusedforidentifyingout-lierswithinalearningsetL.Asamplexcanbeconsideredasanoutlierifitsaverageproximitywithrespecttoallothersamplesissmall,whichindeedindicatesthatxisstructurallydifferentfromtheothersamples(sincetheydonotendupinthesameleaves).Inthesameway,inclassiﬁcation,within-classoutlierscanbeidentiﬁedbycomputingtheaverageproximityofasamplewithrespecttoallothersamplesofthesameclass.Conversely,proximitymeasurescanbeusedforidentifyingclassprototypes,byconsideringsampleswhoseproximitywithallothersamplesofthesameclassisthelargest.Analternativeformulationofproximitymeasuresistoconsiderarandomforestasamappingφ:X7→X0whichtransformsasamplexintothe(one-hot-encoded)indicesoftheleavesitendsupin.Thatis,x0tis1forallleavestoftheforestinwhichxfallsin,and0foralltheothers:φ(x)=(cid:16)1(x∈Xt1),...,1(x∈XtL)(cid:17)(4.40)wheret1,...,tL∈eψdenotetheleafsofallMtreesintheforestψ.Inthisformalism,theproximitybetweenx1andx2correspondstoakernel[ScholkopfandSmola,2001],thatcanbedeﬁnedasthenormalizeddotproductofthesamples,asrepresentedinX0:proximity(x1,x2)=1Mφ(x1)·φ(x2)(4.41)Interestingly,φprovidesanon-lineartransformationtoasparseveryhigh-dimensionalspace,takingsomehowintoaccountthestructureoftheproblem.Iftwosamplesarestructurallysimilar,thentheywillendupinthesameleafsandtheirrepresentationsintheprojectedspacewillbeclose,eveniftheymayinfactappearquitedissimilarintheoriginalspace.Incloseconnection,[Geurtsetal.,2006a]showthataregressiontreeϕcanbeexpressedasakernel-basedmodelbyformulatingthe80randomforestspredictionϕ(x)asascalarproductovertheinputspacedeﬁnedbythenormalizedcharacteristicfunctionφ0oftheleafnodes.Thatis,ϕ(x)=X(xi,yi)∈LyiKϕ(xi,x)(4.42)whereKϕ(xi,x)=φ0(xi)·φ0(x),(4.43)φ0(x)=(cid:16)1(x∈X1)√N1,...,1(x∈XtL)pNtL(cid:17),(4.44)andwheret1,...,tL∈eϕdenotetheleafsofϕ.Likewise,thefor-mulationcanbeextendedtoanensembleψofMdecisiontreesbydeﬁningKψastheaveragekerneloverKϕm(form=1,...,M).Fromamorepracticalpointofview,suchforest-basedtransformsφandφ0haveproventobehelpfulandefﬁcientembeddings,e.g.,whencombinedwithlinearmethodsorsupportvectormachines[Moos-mannetal.,2006;Maréeetal.,2013].Inparticular,theyﬁndusefulapplicationsincomputervisionfortransformingtherawpixelinputspaceintoanewfeaturespacehopefullycapturingstructuresandpatternsinimages.4.4.4MissingdataBecauseofpracticallimitations,physicalconstraintsorforprivacyreasons,real-worlddataareoftenimperfect,erroneousorincomplete.Inparticular,mostmachinelearningalgorithmsareoftennotappli-cableondatacontainingmissingvaluesbecausetheyimplicitlyas-sumeanidealscenarioinwhichallvaluesareknownforallinputvariables.Fortunately,randomforestsofferseveralmechanismsfordealingwiththisissue.Ternarydecisiontrees.Thesimpleststrategyistoexplicitlymodelmissingvaluesinthestructureofdecisiontreesbyconsideringternarysplitsinsteadofbinarysplits.Thatis,partitiontintotL,tRandtM,suchthattLandtRaredeﬁnedfromabinarysplitsvj:Xj6v,forallnodesampleswherethevalueofXjisknown,andsuchthattMcontainallnodesamplesforwhichthevalueofXjismissing.PropagateinbothchildnodesAnalternativestrategyistopropagatesamplesforwhichthevalueofthesplitvariableismissingintoboththeleftandrightchildnodes.Accordingly,samplesgoingintobothchildnodesshouldbere-weightedbyhalftheirsampleweight(seeChap-ter5),sothattheyarenotunfairlytakenintoaccountmorethantheothersamples.4.5consistency81Imputation.Finally,randomforestsalsoofferseveralmechanismsforimput-ingmissingvalues.Asimpleapproach,dueto[Breiman,2002],consistsﬁrstinﬁllingmissingvalueswitharoughandinac-curateapproximation(e.g.,themedian).Thenbuildarandomforestonthecompleteddataandupdatethemissingvaluesofeachsamplebytheweightedmeanvalueoverthesamplesthataretheclosest(asdeﬁnedbytheproximitymeasure).Thepro-cedureisthenrepeateduntilconvergence,typicallyafter4to6iterations.Alternatively,missingdataimputationcanbeconsideredasasupervisedlearningprobleminitself,wheretheresponsevari-ableistheinputvariableforwhichvaluesaremissing.Assuch,theMissForestalgorithm[StekhovenandBühlmann,2012]con-sistsiniterativelybuildingarandomforestontheobservedpartsofthedatainordertopredictthemissingvaluesforagivenvariable.4.5consistencyDespitetheirextensiveuseinpractice,excellentperformanceandrel-ativealgorithmicsimplicity,themathematicalmechanismsthatdriverandomforestsarestillnotwellunderstood.Morespeciﬁcally,thefundamentaltheoreticalquestionoftheconsistency(seedeﬁnitions2.8and2.9)ofrandomforests,i.e.,whetherconvergencetowardsanoptimalmodelisguaranteedprovidedaninﬁnitelylargelearningset,remainsanopenanddifﬁcultproblem.Inthissection,wereviewtheoreticalworksthathaveinvestigatedsimpliﬁedversionsoftheal-gorithm,forwhichtheconstructionprocedureisoftenmadedata-independent,hencemakingthetheoreticalanalysistypicallymoretractable.Withthehopethatresultsobtainedforthesesimpliﬁedmodelswillprovideinsightsonthemathematicalpropertiesoftheactualalgorithm,thelong-termobjectiveofthislineofresearchisusuallytoprovetheconsistencyoftheoriginalRandomForestalgo-rithm[Breiman,2001],hencebridgingthegapbetweentheoryandpractice.Breimanetal.[1984]:Singledecisiontreesareprovedtobeconsistent,bothinregres-sionandclassiﬁcation.NotethattheseresultsdonotextendtotheRandomForestal-gorithmforthefollowingreasons:-Insingledecisiontrees,thenumberofsamplesinterminalnodesislettobecomelarge,whiletreesinrandomforestsareusuallyfullydeveloped;82randomforests-Singledecisiontreesdonotmakeuseofbootstrapsam-pling;-Thesplittingstrategyinsingledecisiontreesconsistsinse-lectingthesplitthatmaximizestheGinicriterion.Bycon-trast,inrandomforests,thesplittingstrategyisrandom-ized.Zhao[2000]:Oneoftheearliestworksstudyingtheconsistencyofensem-blesofrandomizedtreesisduetoZhao[2000].Inclassiﬁcation,theauthorconjecturesthatPERTis(weakly)consistent,butes-tablishesitsstrongconsistency(Theorem4.4.2)providedtheconstructionofthetreesstopsearly.Morespeciﬁcally,strongconsistencyisguaranteedprovided:(a)Treesaregrowninﬁnitelydeeplywhileformingleaveswithinﬁnitelymanynodesamples,hencemakingempiricalclassproportionsinterminalnodesconvergetowardstheirthe-oreticalcounterparts.Thisisguaranteed,e.g.,bystoppingtheconstructionwhenNt<N(N)min,suchthatN(N)min→0andN×N(N)min→∞asN→∞(whereN(N)ministhevalueoftheNminparameterforaforestgrownonalearningsetofsizeN);(b)TheposteriorclassprobabilitiesinducedbytheensembleareallcontinuousintheinputspaceX.Giventhecloseformulationsofthemethods,resultsfrom[Zhao,2000]regardingPERTextendtoExtremelyRandomizedTreesprovidedtheposteriorclassprobabilitiesarecontinuous.InAp-pendixFof[Geurtsetal.,2006a],ExtremelyRandomizesTrees(forK=1andM→∞)areshowntobeacontinuouspiecewisemultilinearfunctionofitsarguments,whichshouldthereforesufﬁcetoestablishthestrongconsistencyofthemethodwhentreesarebuilttotallyatrandom.Breiman[2004]:Inthiswork,consistencyisstudiedforasimpliﬁedvariantoftheRandomForestalgorithm,assuming(i)nobootstrapsam-pling,(ii)thatvariablesareselectedassplitvariableswithprob-abilityp(m)(form=1,...,p),(iii)thatsplitsonrelevantvari-ablesaresetatthemidpointofthevaluesoftheselectedvari-able,(iv)thatsplitsonirrelevantvariablesaresetatrandompointsalongthevaluesoftheselectedvariableand(v)thattreesarebalanced.Undertheseassumptions,itcanbeshownthatthisvariantreducestoan(adaptive)nearestneighboralgo-rithm[LinandJeon,2002],forwhich(weak)consistencycondi-tionsaremet(bothinregressionandclassiﬁcation).Addition-ally,thisworkstudiesthebias-variancedecompositionofthis4.5consistency83simpliﬁedmethodandshowsthattherateofconvergenceto-wardstheBayeserroronlydependsonthenumberrofrelevantvariables,henceexplainingwhyrandomforestsworkwellevenwithmanynoisevariables.Biauetal.[2008]:Inbinaryclassiﬁcation,Biauetal.[2008]provesthatiftheran-domizedbasemodelsinanensembleareconsistent,thenthecorrespondingmajorityorsoftvotingensemblesarealsoconsis-tent.(Thisresultwaslaterexpandedbothformulti-classclassi-ﬁcation[Deniletal.,2013b]andregression[Deniletal.,2013a].)Fromthisproposition,theconsistencyofPurelyRandomForests[Breiman,2000]isestablished.LetusassumethattheinputspaceXissupportedon[0,1]pandthatterminalnodesrep-resenthyperrectanglesof[0,1]p,calledcells,andformingto-getherapartitionof[0,1]p.Ateachstep,oneofthecurrentterminalnodestandonethepinputvariablesarechosenuni-formlyatrandom.Theselectednodetisthensplitalongthechosenvariableatarandomlocation,alongthelengthofthechosensideint.Thisprocedureisrepeatedk>1times,whichamountstodevelopingtreesinrandomorder.Inthissetting,andsimilarlytoPERT,(strong)consistencyofPurelyRandomForestsisguaranteedwheneverk(N)→∞andk(N)N→0asN→∞(wherek(N)isthevalueofkforaforestgrownonlearningsetofsizeN)–whichisequivalenttolettingthenumberofpointsinterminalnodesgrowtoinﬁnity.InPurelyRandomForests,letusremarkthattreesarebuiltinadata-independentmanner,withoutevenlookingatthesam-plesinL.Inthissamework,andassumingnobootstrapsam-pling,theauthorsshowthatconsistencyishoweveralsoguaran-teedwhenthepositionofthecutischoseninadata-dependentmanner,byselectingarandomgapbetweenconsecutivenodesamples(orderedalongthechosenvariable)andthensamplinguniformlywithinthegap.Biau[2012]:Inthiswork,theauthorsmorecloselyapproachestheconsis-tencyoftheactualRandomForestalgorithmandprovethecon-sistencyofthefollowingvariant.Again,letusassumethattheinputspaceXissupportedon[0,1]pandthatterminalnodesrepresenthyperrectanglesof[0,1]p,formingtogetherapartitionoftheinputspace.Ateachstep,allcurrentterminalnodesareindependentlysplitusingoneofthepinputvariablesXj,drawnwithprobabilityp(N)j,andusingasthresholdthemid-pointofthechosensideint.Thisprocedureisrepeateddlog2ketimes,whichamounts84randomforeststodevelopingtreesinbreadth-ﬁrstorderuntildepthdlog2ke.(Strong)Consistencyisthenguaranteedwheneverp(N)jk(N)→∞(forj=1,...,p)andk(N)N→0asN→∞.Inparticular,byproperlydeﬁningtheprobabilitiespj,thisre-sultcanbeshowntoincludethesituationwhere,ateachnode,randomnessisintroducedbyselectingatrandomasubsetofKvariablesandsplittingalongtheonethatmaximizessomeim-puritycriterion,likeinRandomForest.(Notehoweverthatbestcut-pointscoincidewiththemid-pointsonlyforsomeproba-bilitydistributions.)Assumingnobootstrapsamplingandpro-videdthattwoindependentdatasetsareusedforevaluatingthegoodnessofthesplitsandﬁttingthepredictionvaluesatleafs,consistencyofthemethodisthenalsoestablished.Interestingly,andcorroboratingresultsof[Breiman,2004],thisworkalsohighlightsthefactthatperformanceofrandomforestsonlydependsonthenumberrofrelevantvariables,andnotonp,makingthemethodrobusttooverﬁtting.Deniletal.[2013a]:Buildingupon[Biau,2012],Deniletal.[2013a]narrowedthegapbetweentheoryandpracticebyprovingtheconsistencyofthefollowingvariant.Foreachtreeintheforest,thelearningsetispartitionedran-domlyintostructurepoints(usedfordeterminingsplits)andestimationpoints(usedforﬁttingvaluesatleafs).Again,letusassumethattheinputspaceXissupportedon[0,1]pandthatterminalnodesrepresenthyperrectanglesof[0,1]p,form-ingtogetherapartitionoftheinputspace.Ateachstep,currentterminalnodesareexpandedbydrawingatrandommin(1+Poisson(λ),p)variablesandthenlookingforthecut-pointthatmaximizestheimpuritycriterion,ascomputedovermrandomlydrawnstructurepoints.Theconstructionhaltswhennosplitleadingtochildnodeswithlessthanknodesamplescanbefound.Inregression,assumingnotbootstrapsampling,(strong)con-sistencyofthisvariantisguaranteedwheneverk(N)→∞andk(N)N→0asN→∞(wherek(N)isthevalueofkforaforestgrownonlearningsetofsizeN).Scornetetal.[2014]:Thisworkestablishestheﬁrstconsistencyresultfortheorigi-nalRandomForestalgorithm.Inparticular,(strong)consistencyisobtainedinthecontextofregressionadditivemodels,as-sumingsubsamplingwithoutreplacement(insteadofbootstrapsampling).Thisworkistheﬁrstresultestablishingconsistency4.5consistency85when(i)splitsarechoseninadata-dependentmannerand(ii)leafsarenotlettogrowtoaninﬁnitenumberofnodesamples.Inconclusions,despitethedifﬁcultyofthemathematicalanalysisofthemethod,thesetheoreticalworksprovidetogetherconvergingargumentsallconﬁrmingwhyrandomforests–includingtheRan-domForestalgorithmbutalsoExtremelyRandomizedTrees–appeartoworksowellinpractice.Finally,letuscompletethisreviewbymentioningconsistencyre-sultsinthecaseofdomain-speciﬁcadaptationsofrandomforests,includingquantileregression[Meinshausen,2006],survivalanaly-sis[IshwaranandKogalur,2010]andonlineforestconstruction[De-niletal.,2013b].5COMPLEXITYANALYSISANDIMPLEMENTATIONOutlineInthischapter,westudythecomputationalefﬁciencyoftree-basedensemblemethods.Insections5.1and5.2,wederiveanddiscussthetimecomplexityofrandomforests,ﬁrstforbuildingthemfromdataandthenformakingpredictions.InSection5.3,wediscusstechnicaldetailsthatarecriticalforefﬁcientlyimplementingrandomforests.Finally,weconcludeinSection5.4withbenchmarksoftherandomforestimplementationdevelopedwithinthisworkandcompareoursolutionwithalternativeimplementations.5.1complexityoftheinductionprocedureThedominantobjectiveofmostmachinelearningmethodsistoﬁndmodelsthatmaximizeaccuracy.Formodelsofequivalentperformance,asecondaryobjectiveisusuallytominimizecomplexity,bothfunc-tional,asstudiedinthepreviouschapters,andcomputational.Withregardstothelater,aﬁrstandimmediateaspectofcomputationalcomplexityindecisiontreesandrandomforestsisthetimecomplex-ityforlearningmodels,thatisthenumberofoperationsrequiredforbuildingmodelsfromdata.GiventheexponentialgrowthinthenumberofpossiblepartitionsofNsamples,wechoseinSection3.6torestrictsplittingrulestobinarysplitsdeﬁnedonsinglevariables.Notonlythisissufﬁcientforreachinggoodaccuracy(asdiscussedinthepreviouschapter),italsoallowsfortimecomplexitytoeffectivelyremainwithinreasonablebounds.Formally,letT(N)denotesthetimecomplexityforbuildingade-cisiontreefromalearningsetLofNsamples.FromAlgorithm3.2,T(N)correspondstothenumberofoperationsrequiredforsplittinganodeofNsamplesandthenforrecursivelybuildingtwosub-treesrespectivelyfromNtLandNtRsamples.Withoutlossofgenerality,letusassumethatlearningsamplesallhavedistinctinputvalues,suchthatitispossibletobuildafullydevelopeddecisiontreewhereeachleafcontainsexactlyonesample.Underthisassumption,deter-miningtimecomplexitythereforeboilsdowntosolvetherecurrenceequationT(1)=c1T(N)=C(N)+T(NtL)+T(NtR),(5.1)8788complexityanalysisandimplementationwherec1istheconstantcostformakingaleafnodeoutofasin-glesampleandC(N)istheruntimecomplexityforﬁndingasplitsandthenpartitioningtheNnodesamplesintotLandtR.Inparticu-lar,thislateroperationrequiresatleasttoiterateoverallNsamples,whichsetsalinearlowerboundonthetimecomplexitywithinanode,i.e.,C(N)=Ω(N).Asforﬁndingthesplits,thiscanbeachievedinseveralways,asoutlinedinthepreviouschaptersforseveralrandom-izedvariantsoftheinductionprocedure.Aswewillsee,notonlythishasanimpactontheaccuracyoftheresultingmodel,italsodrivesthetimecomplexityoftheinductionprocedure.BigOnotationsTimecomplexityanalyzestheasymptoticbehaviorofanalgorithmwithrespecttothesizeNofitsinputanditshyper-parameters.Inthisway,bigOnotationsareusedtoformallyexpressanasymptoticupperboundonthegrowthrateofthenumberf(N)ofstepsinthealgorithm.Formally,wewritethatf(N)=O(g(N))if∃c>0,N0>0,∀N>N0,f(N)6cg(N)(5.2)toexpressthatf(N)isasymptoticallyupperboundedbyg(N),uptosomenegligibleconstantfactorc.Similarly,bigΩnotationsareusedtoexpressanasymptoticlowerboundonthegrowthrateofthenumberofstepsinthealgorithm.Formally,wewritethatf(N)=Ω(g(N))if∃c>0,N0>0,∀N>N0,cg(N)6f(N)(5.3)toexpressthatf(N)isasymptoticallylowerboundedbyg(N).Conse-quently,iff(N)isbothO(g(N))andΩ(g(N))thenf(N)isbothlowerboundedandupperboundedasymptoticallybyg(N)(possiblyfordifferentconstants),whichwewriteusingbigΘnotations:f(N)=Θ(g(N))iff(N)=O(g(N))=Ω(g(N)).(5.4)IntheoriginalCARTinductionprocedure[Breimanetal.,1984](Al-gorithms3.3and3.4),ﬁndingasplitsrequires,foreachofthepvari-ablesXj(forj=1,...,p),tosortthevaluesxi,jofallNnodesamples(fori=1,...,N)andthentoiterateovertheseinordertoﬁndthebestthresholdv.Assumingthatthevalueoftheimpuritycriterioncanbecomputediterativelyforconsecutivethresholds,themostcostlyoper-ationissorting,whosetimecomplexityisatworstO(NlogN)usinganoptimalalgorithm.Asaresult,theoverallwithin-nodecomplex-ityisC(N)=O(pNlogN).InarandomizedtreeasbuiltwiththeRandomForestalgorithm[Breiman,2001](RF,Algorithm4.1),thesearchofthebestsplitsiscarriedoutinthesameway,butonlyonK6poftheinputvariables,resultinginawithin-nodecomplexity5.1complexityoftheinductionprocedure89C(N)=O(KNlogN).InExtremelyRandomizedTrees[Geurtsetal.,2006a](ETs,Algorithm4.3),discretizationthresholdsaredrawnatrandomwithintheminimumandmaximumnodesamplevaluesofXj,makingsortnolongernecessary.Assuch,thewithin-nodecom-plexityreducestothetimerequiredforﬁndingtheselowerandup-perbounds,whichcanbedoneinlineartime,henceC(N)=O(KN).Finally,inPerfectRandomTreeEnsembles[CutlerandZhao,2001](PERT,Algorithm4.2),cut-pointsvaresetmidwaybetweentworan-domlydrawnsamples,whichcanbedoneinconstanttime,inde-pendentlyofthenumberNofnodesamples.Yet,thewithin-nodecomplexityislowerboundedbythetimerequiredforpartitioningthenodesamplesintotLandtR,henceC(N)=O(N).SincebothCARTandPERTcanrespectivelybeconsideredasspe-cialcasesofRFandETswithregardstotimecomplexity(i.e.,forK=pinCART,forK=1inPERT),letusconsidertheoverallcom-plexityT(N)wheneitherC(N)=O(KNlogN)orC(N)=O(KN)(forK=1,...,p).Tomakeouranalysiseasier,letusfurtherassumethatitexistsc2,c3>0suchthatc2KNlogN6C(N)6c3KNlogNforallN>1(resp.c2KN6C(N)6c3KNforallN>1).ResultspresentedbelowextendhowevertothecasewhereC(N)=Θ(KN)(resp.Θ(KNlogN)),atthepriceofamorecomplicatedmathematicalanalysis.Timecomplexityisstudiedinthreecases:Bestcase.Theinductionprocedureisthemostefﬁcientwhennodesam-plescanalwaysbepartitionedintotwobalancedsubsetsofN2samples.Worstcase.Bycontrast,theinductionprocedureistheleastefﬁcientwhensplitsareunbalanced.Intheworstcase,thisresultsinsplitsthatmoveasinglesampleintheﬁrstsub-treeandputallN−1othersinthesecondsub-tree.Averagecase.Theaveragecasecorrespondstotheaveragetimecomplexity,astakenoverallpossiblelearningsetsL(ofagivensizeandforagivendistribution)andallrandomseedsθ.Sincetheanalysisofthiscaseishardlyfeasiblewithoutstrongassumptionsonthestructureoftheproblem,weconsiderinsteadthecasewherethesizesofthepossiblepartitionsofanodeareallequiprobable.Webelievethisisagoodenoughapproximation,thatshouldatleasthelpusderivetheorderofmagnitudeofthecomplexity(insteadofderivingitexactly).Sincetheinductionalgorithmlooksforsplitsthatmostdecreaseim-purity(inparticular,asK→p),weassumethatbalancedpartitionsofthenodessamplesshouldbemorelikelythanpartitionsthatare90complexityanalysisandimplementationunbalanced(suchaclaimishoweverhighlydatadependent).Underthisassumption,randomforestsshouldthereforeapproachthebestcaseratherthantheaveragecase(forwhichpartitionsareequallylikely).However,asrandomizationincreases(e.g.,asK→1),splitsyieldpartitionsthattendtobemoreequiprobable,henceapproach-ingtheaveragecase.Assuch,webelievethecomplexityforthetrueaveragecaseshouldliein-betweenthecomplexityofthebestcaseandthecomplexityoftheaveragecaseasdeﬁnedabove.Asfortheworstcase,itshouldonlyariseinexceptionalcircumstances.Letusmentionthatduetotheend-cutpreferenceofclassicalimpu-ritycriteria,worstsplitsareinfactlikelytobeselected(see[Breimanetal.,1984],Theorem11.1)ifnoneoftheKselectedvariablesareinformativewithrespecttotheoutput.(NotethatthiseffectislesspronouncedinETsbecausethresholdsaredrawnatrandomratherthanbeingoptimizedlocally,asinRF.)Intheanalysiscarriedbelow,interminglingeffectsduetogoodsplitsatthetopoftreesandsuchdegeneratedsplitsduetoend-cutpreferencewheninputvariablesbe-comeindependentoftheoutputarenotexplicitlytakenintoaccount.Yet,thesimplifyingassumptionsdeﬁningouraveragecaseappeartoconstituteagood-enoughapproximation,asfurtherconﬁrmedinempiricalbenchmarksinSection5.4.MasterTheoremSomeoftheresultsoutlinedintheremainingofthissectionmakeuseoftheMasterTheorem[Bentleyetal.,1980;GoodrichandTamassia,2006],whichisrecalledbelowtobeself-contained.Theorem5.1.LetconsidertherecurrenceequationT(1)=cifn<dT(n)=aT(nb)+f(n)ifn>d(5.5)whered>1isanintegerconstant,a>0,c>0andb>1arerealconstants,andf(n)isafunctionthatispositiveforn>d.(a)Ifthereisasmallconstant(cid:15)>0,suchthatf(n)isO(nlogba−(cid:15)),thenT(n)isΘ(nlogba).(b)Ifthereisaconstantk>0,suchthatf(n)isΘ(nlogbalogkn),thenT(n)isΘ(nlogbalogk+1n).(c)Iftherearesmallconstants(cid:15)>0andδ<1,suchthatf(n)isΩ(nlogba+(cid:15))andaf(nb)6δf(n),forn>d,thenT(n)isΘ(f(n)).5.1complexityoftheinductionprocedure91Theorem5.2.Forc2KNlogN6C(N)6c3KNlogN(forallN>1),thetimecomplexityforbuildingadecisiontreeinthebestcaseisΘ(KNlog2N).Proof.LetusrewriteT(N)asKT0(N)where,inthebestcase,T0(1)=c01T0(N)=C0(N)+2T0(N2),(5.6)withc01=c1KandC0(N)=C(N)K.Inthisform,thesecondcaseoftheMasterTheoremappliesforf(N)=C0(N)=Θ(NlogN),a=2,b=2andk=1.Accordingly,T0(N)=Θ(Nlogk+1N)=Θ(Nlog2N)andT(N)=Θ(KNlog2N).Theorem5.3.Forc2KN6C(N)6c3KN(forallN>1),thetimecomplexityforbuildingadecisiontreeinthebestcaseisΘ(KNlogN).Proof.Inthebestcase,T(N)=KT0(N),whereT0(1)=c01T0(N)=C0(N)+2T0(N2).(5.7)Again,thesecondcaseoftheMasterTheoremapplies,thistimeforf(N)=C0(N)=Θ(N),a=2,b=2andk=0.Accordingly,T0(N)=Θ(Nlogk+1N)=Θ(NlogN)andT(N)=Θ(KNlogN).Theorem5.4.Forc2KNlogN6C(N)6c3KNlogN(forallN>1),thetimecomplexityforbuildingadecisiontreeintheworstcaseisΩ(KN2)andO(KN2logN).Proof.Intheworstcase,T(N)=KT0(N),whereT0(1)=c01T0(N)=C0(N)+T0(1)+T0(N−1).(5.8)LetusﬁrstconsideranupperboundonT0(N).Byexpandingtherecurrence,wehaveT0(N)6c3NlogN+c01+T0(N−1)=NXi=1c01+c3ilogi=c01N+NXi=1c3ilogi6c01N+c3logNNXi=1i=c01N+c3logNN(N+1)292complexityanalysisandimplementation=O(N2logN).(5.9)Similarly,alowerboundonT0(N)canbederivedinthefollowingway:T0(N)>c2NlogN+c01+T0(N−1)=NXi=1c01+c2ilogi=c01N+NXi=1c2ilogi>c01N+c2NXi=2i=c01N+c2N(N+1)2−c2=Ω(N2).(5.10)Assuch,T(N)=Ω(KN2)andO(KN2logN)intheworstcase.LetusremarkthatthelowerandupperboundsderivedforT(N)inTheorem5.4arenottight.Nevertheless,giventhefactthatNXi=1ilogi=log(H(N)),(5.11)whereH(N)isthehyperfactorialfunction,complexitycouldbere-expressedtightlyasT(N)=Θ(Klog(H(N))).Theorem5.5.Forc2KN6C(N)6c3KN(forallN>1),thetimecomplexityforbuildingadecisiontreeintheworstcaseisΘ(KN2).Proof.Intheworstcase,T(N)=KT0(N),whereT0(1)=c01T0(N)=C0(N)+T0(1)+T0(N−1).(5.12)Byexpandingtherecurrence,wehaveT0(N)6c3N+c01+T0(N−1)=c01+NXi=2(c01+c3i)=c01N+c32(N2+3N−4)=O(N2).(5.13)Intheexactsameway,T0(N)canbelowerboundedbyc2N+c01+T0(N−1)andshowntobeΩ(N2).Asaresult,T(N)=Θ(KN2)intheworstcase.5.1complexityoftheinductionprocedure93Theorem5.6.Forc2KNlogN6C(N)6c3KNlogN(forallN>1),thetimecomplexityforbuildingadecisiontreeintheaveragecaseisΘ(KNlog2N).Proof.Intheaveragecase,T(N)=KT0(N),whereT0(1)=c01T0(N)=C0(N)+1N−1PN−1i=1(T0(i)+T0(N−i)).(5.14)LetusﬁrstconsideranupperboundonT0(N)byassumingthatC0(N)=c3NlogN.Bysymmetryandbymultiplyingbothsidesofthelastequationby(N−1),itcomes(N−1)T0(N)=(N−1)(c3NlogN)+2N−1Xi=1T0(i).(5.15)ForN>3,substitutingNwithN−1similarlyyields(N−2)T0(N−1)=(N−2)(c3(N−1)log(N−1))+2N−2Xi=1T0(i).(5.16)SubtractingEquation5.16from5.15,itcomesaftersimpliﬁcationsanddivisionofbothsidesbyN(N−1):T0(N)N=T0(N−1)N−1+c32Nlog(N−1)+c3logNN−1.(5.17)LetusnowintroduceS(N)=T0(N)N.Fromthelastequation,itcomesS(N)=S(N−1)+c32Nlog(N−1)+c3logNN−1=c01+c3NXi=22ilog(i−1)+logii−1=c01+c3logN+2c3NXi=21ilog(i−1)6c01+c3logN+2c3logNNXi=21i=c01+c3logN+2c3logN(HN−1)=O(HNlogN)(5.18)whereHNistheN-thharmonicnumber.UsingHN≈logN+γ+12N+O(1N2)(5.19)asapproximation(whereγistheEuler-Mascheroniconstant),wehaveT0(N)=O(NHNlogN)94complexityanalysisandimplementation=O(N(logN+γ+12N+1N2)logN)=O(Nlog2N).GivenTheorem5.2,wealsoknowthatT0(N)cannotbefasterthanΩ(Nlog2N),therebysettingalowerboundonthecomplexityoftheaveragecase.Asaresult,T(N)=Θ(KNlog2N)intheaveragecase.Theorem5.7.Forc2KN6C(N)6c3KN(forallN>1),thetimecomplexityforbuildingadecisiontreeintheaveragecaseisΘ(KNlogN).Proof.Intheaveragecase,T(N)=KT0(N),whereT0(1)=c01T0(N)=C0(N)+1N−1PN−1i=1T0(i)+T0(N−i).(5.20)LetusﬁrstconsideranupperboundonT0(N)byassumingthatC0(N)=c3N.Bysymmetryandbymultiplyingbothsidesofthelastequationby(N−1),itcomes(N−1)T0(N)=c3N(N−1)+2N−1Xi=1T0(i).(5.21)ForN>3,substitutingNwithN−1similarlyyields(N−2)T0(N−1)=c3(N−1)(N−2)+2N−2Xi=1T0(i).(5.22)SubtractingEquation5.22from5.21,itcomesaftersimpliﬁcationsanddivisionofbothsidesbyN(N−1):T0(N)N=T0(N−1)N−1+2c3N.(5.23)LetusnowintroduceS(N)=T0(N)N.Fromthelastequation,itcomesS(N)=S(N−1)+2c3N=c01+2c3NXi=21i=O(2HN)(5.24)whereHNistheN-thharmonicnumber.UsingHN≈logN+γ+12N+O(1N2)(5.25)asapproximation(whereγistheEuler-Mascheroniconstant),wehaveT0(N)=O(2HNN)5.1complexityoftheinductionprocedure95=O(2NlogN+2Nγ+1+2N)=O(NlogN).(5.26)Intheexactsameway,whenassumingthatC0(N)=c2N,T0(N)canbeshowntobelowerboundedbyΩ(NlogN).Asaresult,T(N)=Θ(KNlogN)intheaveragecase.FromTheorems5.2-5.7,thetotaltimecomplexityforbuildinganensembleofMrandomizedtreescanﬁnallybederived.Assumma-rizedinTable5.1,complexityremainswithinpolynomialtimeforallvariantsstudiedinthiswork.Inthebestcase,complexityislinearwiththenumberofsplitvariablesconsideredateachnode(i.e.,O(K))andlinearithmicorquasilinearwiththenumberof(unique)sampleseffectivelyusedtobuildeachtree(i.e.,O(NlogN)orO(Nlog2N)).Intheveryworstcasehowever,thislaterdependencybecomesquadratic(i.e.,O(N2)orO(N2logN)),whichmightgreatlyaffectperformanceinthecontextoflargedatasets.Reassuringly,theanalysisoftheaver-agecaseshowsthatpathologicalcasesarenotdominantandthat,onaverage,forallmethods,complexitybehavesasinthebestcase.Asexpected,thecomplexityofBagging[Breiman,1994]isaboutMtimesaslargeasthecomplexityofbuildingasingledecisiontree.Yet,bytakingintoaccountthefactthatbaggeddecisiontreesarebuiltonbootstrapreplicatesLmthatcontainabout63.2%ofuniquesam-ples,complexitycanbeexpressedwithrespecttoeN=0.632NinsteadofN.Fromanimplementationpointofview,repeatedoccurrencesofthesameinputvectorcanindeedbeaccountedforusingsampleweightsfortheevaluationoftheimpuritycriterion,therebysimulat-ingalearningsetofNsamplesfromeNuniquesampleswhilere-ducingtheeffectivesizeofthelearningset.Assumingcloseconstantfactors,buildingasinglebaggeddecisiontreeisthereforeasymptoti-callylimN→∞Nlog2N0.632Nlog20.632N=1.582(5.27)timesfasterthanbuildingaregulardecisiontree.ThecomplexityofRFisidenticaltoBagging,exceptthatthedependencytopbecomesadependencytoK,resultinginanaveragespeedupofpK.Inotherwords,notonlychoosingK6pimprovesaccuracy,italsosigniﬁ-cantlydecreasesthetimerequiredforbuildingtreesinaforest.InETs,duetothefactthatsamplesarenolongerrequiredtobesortedateachnode,thedependencytoNbecomeslinearithmicinsteadofquasilinear.WithrespecttoRF,speedupisasymptoticallyO(logN)inthebestandaveragecases.Finally,PERTshowstobethefastestmethodofall,whichisduetothefactthatonlyasinglesplitvari-ableisconsideredateachsplit.ForK=1however,ETsandPERThaveidenticaltimecomplexity.Notethattheanalysispresentedhere96complexityanalysisandimplementationBestcaseWorstcaseAveragecaseCARTΘ(pNlog2N)O(pN2logN)Θ(pNlog2N)BaggingΘ(MpeNlog2eN)O(MpeN2logeN)Θ(MpeNlog2eN)RFΘ(MKeNlog2eN)O(MKeN2logeN)Θ(MKeNlog2eN)ETsΘ(MKNlogN)Θ(MKN2)Θ(MKNlogN)PERTΘ(MNlogN)Θ(MN2)Θ(MNlogN)Table5.1:TimecomplexityforbuildingforestsofMrandomizedtrees.NdenotesthenumberofsamplesinL,pthenumberofinputvari-ablesandKthenumberofvariablesrandomlydrawnateachnode.eN=0.632N,duetothefactthatbootstrapsamplesdraw,onaver-age,63.2%ofuniquesamples.isonlyvalidasymptotically.Inpractice,constantfactorsmightleadtodifferentobservedresults,thoughtheyshouldnotsigniﬁcantlyde-viatefromourconclusionsifalgorithmsareallimplementedfromacommoncode-base.5.2complexityofthepredictionprocedureAsecondfacetofcomputationalcomplexityinrandomforestsisthetimerequiredformakingpredictions.Forasingletestpoint,thisrep-resentsthenumberofoperationsfortraversingeachoftheMtrees,fromtheroottooneoftheleaves.Assuch,computationalcomplexityisdirectlyrelatedtotheaveragedepthoftheleavesreachedbythetestsamples.Assumingthatboththelearningsetandthetestsetaredrawnfromthesameprobabilitydistribution,thecomplexityanaly-sisofthepredictionprocedurethereforereducestotheanalysisoftheaveragedepthoftheleavesinducedbyalearningsetL.AsinSection5.1,letusassumeafullydevelopeddecisiontree,whereeachleafcontainsexactlyonesamplefromL.LikewiseletusderivetheaveragedepthD(N)oftheleavesinthebest,worstandaveragecases.Theorem5.8.Inthebestcase,theaveragedepthoftheleavesisΘ(logN).Proof.Foradecisiontreewhichisperfectlybalanced,nodesamplesarerecursivelysplitintotwosubsetsofNt2samplesateachnode,whichleadstothefollowingrecurrenceequationinthebestcase:D(1)=1D(N)=1+12D(N2)+12D(N2)=1+D(N2).(5.28)Withthisequation,thesecondcaseoftheMasterTheoremappliesforf(N)=1,a=1,b=2andk=0.Accordingly,D(N)=Θ(logk+1N)=Θ(logN).5.2complexityofthepredictionprocedure97Theorem5.9.Intheworstcase,theaveragedepthoftheleavesisΘ(N).Proof.Intheworstcase,therecurrenceequationoftheaveragedepthoftheleavesis:D(1)=1D(N)=1+1ND(1)+N−1ND(N−1).(5.29)LetusnowintroduceS(N)=ND(N).Fromthepreviousequation,itcomesS(N)=N+1+S(N−1)=1+NXi=2(i+1)=N22+3N2−1.(5.30)SinceD(N)=S(N)N,wehaveD(N)=12(N−2N+3)=Θ(N).Theorem5.10.Intheaveragecase,theaveragedepthoftheleavesisΘ(logN).Proof.Intheaveragecase,therecurrenceequationoftheaveragedepthoftheleavesis:D(1)=1D(N)=1+1N−1PN−1i=1(iND(i)+N−iND(N−i)).(5.31)BysymmetryandbymultiplyingbothsidesbyN(N−1),itcomesN(N−1)D(N)=N(N−1)+2N−1Xi=1iD(i).(5.32)ForN>3,substitutingNwithN−1similarlyyields(N−1)(N−2)D(N−1)=(N−1)(N−2)+2N−2Xi=1iD(i).(5.33)SubtractingEquation5.33from5.32,itcomesaftersimpliﬁcationsanddivisionofbothsidesbyN(N−1)D(N)=D(N−1)+2N=1+2NXi=21i=2HN−1(5.34)whereHNistheN-thharmonicnumber.UsingHN≈logN+γ+12N+O(1N2)(5.35)asapproximation(whereγistheEuler-Mascheroniconstant),wehaveD(N)=Θ(logN).98complexityanalysisandimplementationFromTheorems5.8-5.10,thetotaltimecomplexityforcomputingpredictionsoutofaforestofMtreesisthereforeΘ(MlogN)inthebestcaseandΘ(MN)istheveryworstcase.Inaccordancewithpre-viousresults,theanalysisoftheaveragecaseshowshoweverthatpathologicalcasesarenotdominantandthat,onaverage,complexitybehavesonceagainasinthebestcase.RandomizedtreesarenotequiprobableWhentreesarebuilttotallyatrandom,thatiswhenallsizesofpar-titionsareequiprobable,theanalysisoftheaveragecaseshowsthattheaveragedepthoftheleavesremainslogarithmicwithsizeofthelearningset.Assuminguniqueinputvaluesforallsamplesandcon-sideringthespecialcasep=1,therandomconstructionofadecisiontreeisinfactequivalenttotheinsertioninrandomorderofNuniquekeysintoabinarysearchtree.Asshownexactlyin[SedgewickandFlajolet,2013],theaveragedepthofabinarysearchtreebuiltfromequiprobablepermutationsofNuniquekeysisO(logN),whichcor-roboratesourresults.Bycontrast,iftreesweredrawnuniformlyatrandomfromthesetofallpossibletrees(i.e.,inthecaseofCata-lantrees),thentheaveragedepthcanbeshowntobeO(√N).Thefundamentaldifferenceisthatbinarysearchtreesbuiltfromrandompermutationsarenotallequiprobable.Theremayexistseveralpermu-tationsmappingtothesamebinarysearchtree.Inparticular,shorttreesaremorelikelytooccurthandegeneratedlydeeptrees.Accord-ingly,decisiontrees,evenbuilttotallyatrandom,arealsonotallequiprobable.Becauseoftherecursiveconstructionprocedure,deepdegenerateddecisiontreesarelesslikelythanshorterdecisiontrees.5.3implementationImplementingdecisiontreesandrandomforestsinvolvesmanyis-suesthatareeasilyoverlookedifnotconsideredwithcare.Inthissection,wedescribetherandomforestimplementationthathasbeendevelopedinthisworkanddeployedwithintheScikit-Learnmachinelearninglibrary[Pedregosaetal.,2011].Theﬁrstpartofthissectionisbasedonpreviousworkpublishedin[Buitincketal.,2013].5.3.1Scikit-LearnTheScikit-LearnlibraryprovidesacomprehensivesuiteofmachinelearningtoolsforPython.Itextendsthisgeneral-purposeprogram-minglanguagewithmachinelearningoperations:learningalgorithms,preprocessingtools,modelselectionproceduresandacompositionmechanismtoproducecomplexmachinelearningwork-ﬂows.Theambitionofthelibraryistoprovideefﬁcientimplementationsofwell-5.3implementation99establishedalgorithmswithinaprogrammingenvironmentthatisac-cessibletonon-expertsandreusableinvariousscientiﬁcareas.ThelibraryisdistributedunderthesimpliﬁedBSDlicensetoencourageitsuseinbothacademiaandindustry.Scikit-Learnisdesignedtotieinwiththesetofnumericandsci-entiﬁcpackagescenteredaroundtheNumPy[Oliphant,2007]andSciPy[VanderWaltetal.,2011]libraries.NumPyaugmentsPythonwithacontiguousnumericarraydatatypeandfastarraycomputingprimitives,whileSciPyextendsitfurtherwithcommonnumericaloperations,eitherbyimplementingtheseinPython/NumPyorbywrappingexistingC/C++/Fortrancode.Thename“scikit”derivesfrom“SciPytoolkit”andissharedwithscikit-image.IPython[PerezandGranger,2007]andMatplotlib[Hunter,2007]complementSciPytoprovideamatlab-likeworkingenvironmentsuitedforscientiﬁcuse.Since2007,Scikit-Learnhasbeendevelopedbymorethanadozencoredevelopers,mostlyresearchersinﬁeldsrangingfromneurosciencetoastrophysics.Italsobeneﬁtsfromoccasionalcontributorspropos-ingsmallbug-ﬁxesorimprovements.DevelopmentproceedsonGitHub1,aplatformwhichgreatlyfacilitatesthiskindofcollaboration.Be-causeofthelargenumberofdevelopers,emphasisisputonkeep-ingtheprojectmaintainable.Inparticular,codemustfollowspeciﬁcqualityguidelines,suchasstyleconsistencyandunit-testcoverage.Documentationandexamplesarerequiredforallfeatures,andma-jorchangesmustpasscodereviewbyatleasttwootherdevelopers.Thepopularityoftheprojectcanbegaugedfromvariousindicatorssuchasthehundredsofcitationsinscientiﬁcpublications,successesinvariousmachinelearningchallenges(e.g.,Kaggle),andstatisticsderivedfromourrepositoriesandmailinglist.Atthetimeofwrit-ing2,theprojectiswatchedby3,445peopleandforked1,867timesonGitHub;themailinglistreceivesmorethan300mailspermonth;versioncontrollogsshowmorethan200uniquecontributorstothecode-baseandtheonlinedocumentationreceives37,000uniquevisi-torsand295,000pageviewspermonth.Ourimplementationguidelinesemphasizewritingefﬁcientbutread-ablecode.Inparticular,wefocusonmakingthecode-basemain-tainableandunderstandableinordertofavorexternalcontributions.Wheneverpractical,algorithmsimplementedinScikit-Learnarewrit-teninPython,usingNumPyvectoroperationsfornumericalwork.Thisallowsthecodetoremainconcise,readableandefﬁcient.ForcriticalalgorithmsthatcannotbeeasilyandefﬁcientlyexpressedasNumPyoperations,werelyonCython[Behneletal.,2011]toachievecompetitiveperformanceandscalability.Cythonisacompiledpro-gramminglanguagethatextendsPythonwithstatictyping.Itpro-1https://github.com/scikit-learn2July2014.100complexityanalysisandimplementationducesefﬁcientCextensionmodulesthatareimportablefromthePythonrun-timesystem.ExamplesofCythoncodeinScikit-Learnarestochasticgradientdescentforlinearmodels,someclusteringal-gorithms,anddecisiontrees.5.3.1.1DataMachinelearningrevolvesarounddata,sogooddatastructuresareparamounttodesigningsoftwareforit.Inmosttasks,dataismodeledbyasetofpnumericalvariables,sothatasinglesampleisavectorx∈Rp.AcollectionofsuchsamplesisnaturallyregardedastherowsinamatrixXofsizeN×p.Inthecommoncaseofsupervisedlearning(classiﬁcation,regression),wehaveanadditionalvectoryoflengthNattrainingtimeandwantanalgorithmtoproducesuchayfornewdata.Scikit-Learn’sdatarepresentationiskeptascloseaspossibletothismatrixformulation:datasetsareencodedastwo-dimensionalNumPyarraysorSciPysparsematrices[VanderWaltetal.,2011],whiletargetvectorsareﬂatarraysofnumbersorstrings.Whilethesemayseemratherunsophisticatedwhencomparedtomoreobject-orientedcon-structs,suchastheonesusedbyWeka[Halletal.,2009],theyallowustorelyonefﬁcientNumPyandSciPyvectoroperationswhilekeep-ingthecodeclosetothetextbook.GiventhepervasivenessofNumPyandSciPyinmanyotherscientiﬁcPythonpackages,manyscientiﬁcusersofPythonwillalreadybefamiliarwiththesedatastructures,andacollectionofavailabledataloadingandconversiontoolsfa-cilitateinteroperability.Fortaskswheretheinputsaretextﬁlesorsemi-structuredobjects,weprovidevectorizerobjectsthatefﬁcientlyconvertsuchdatatotheNumPyorSciPyformats.Thepublicinterfaceisorientedtowardsprocessingabatchofsam-ples,ratherthanasinglesample,ineachAPIcall.Whileclassiﬁca-tionandregressionalgorithmscanmakepredictionsforsinglesam-ples,Scikit-Learnobjectsarenotoptimizedforthisusecase.(Theonlinelearningalgorithmsinthelibraryareintendedtotakemini-batches.)BatchprocessingmakesoptimaluseofNumPyandSciPybypreventingtheoverheadinherenttoPythonfunctioncallsorduetoper-elementdynamictypechecking.AlthoughthismightseemtobeanartifactofthePythonlanguage,andthereforeanimplemen-tationdetailthatleaksintotheAPI,wearguethatAPIsshouldbedesignedsoasnottotiealibrarytoasuboptimalimplementationstrategy.Batchprocessingalsoenablesfastimplementationsinlower-levellanguages,wherememoryhierarchyeffectsandthepossibilityofinternalparallelizationcomeintoplay.5.3implementation1015.3.1.2EstimatorsTheestimatorinterfaceisatthecoreofthelibrary.Itdeﬁnesinstanti-ationmechanismsofobjectsandexposesafitmethodforlearningamodelfromtrainingdata.Allsupervisedandunsupervisedlearn-ingalgorithms(e.g.,forclassiﬁcation,regressionorclustering)areof-feredasobjectsimplementingthisinterface.Machinelearningtaskslikefeatureextractionandselectionarealsoprovidedasestimators.Estimatorinitializationandactuallearningarestrictlyseparated,inawaythatissimilartopartialfunctionapplication:anestimatorisinitializedfromasetofnamedhyper-parametervalues(e.g.,thenumberoftreesinaforest)andcanbeconsideredafunctionthatmapsthesevaluestoactuallearningalgorithms.Theconstructordoesnotseeanyactualdata.Allitdoesisattachthegivenparameterstotheobject.Forthesakeofmodelinspection,hyper-parametersaresetaspublicattributes,whichisespeciallyimportantinmodelselectionsettings.Defaulthyper-parametervaluesareprovidedforallbuilt-inestimators.Thesedefaultsaresettoberelevantinmanycommonsituationsinordertomakeestimatorseffectiveout-of-the-box.Actuallearningisperformedbythefitmethod.Thismethodiscalledwithtrainingdata(e.g.,suppliedastwoarraysX_trainandy_traininsupervisedlearningestimators).Itstaskistorunalearn-ingalgorithmandtodeterminemodel-speciﬁcparametersfromthetrainingdataandsettheseasattributesontheestimatorobject.Asaconvention,theparameterslearnedbyanestimatorareexposedaspublicattributeswithnamessufﬁxedwithatrailingunderscore(e.g.,coef_forthelearnedcoefﬁcientsofalinearmodel),againtofacilitatemodelinspection.Inthepartialapplicationview,fitisafunctionfromdatatoamodelofthatdata.Italwaysreturnstheesti-matorobjectitwascalledon,whichnowservesasamodelandcanbeusedtoperformpredictionsortransformationsofnewdata.Thechoicetoletasingleobjectservedualpurposeasestimatorandmodelhasbeendrivenbyusabilityandtechnicalconsiderations.Hav-ingtwocoupledinstances(anestimatorobjectusedasafactory,andamodelobjectproducedbytheestimator)makesalibraryhardertolearnanduse.Fromthedeveloperpointofview,decouplingestima-torsfrommodelswouldcreateparallelclasshierarchiesandincreasestheoverallmaintenanceburden.Agoodreasonfordecouplingwouldbetomakeitpossibletoshipamodeltoanewenvironmentwherethefulllibrarycannotbeinstalled.However,ourinspectablesetupwheremodelparametersaredocumentedpublicattributesandpre-dictionformulasfollowstandardtextbooks,goesalongwayinsolv-ingthisproblem.Toillustratetheinitialize-ﬁtsequence,letusconsiderasupervisedlearningtaskusingasingledecisiontree.GiventheAPIdeﬁnedabove,solvingthisproblemisassimpleasthefollowingexample.102complexityanalysisandimplementation#Importthetreemodulefromsklearn.treeimportDecisionTreeClassifier#Instantiateandsethyper-parametersclf=DecisionTreeClassifier(min_samples_split=5)#Learnamodelfromdataclf.fit(X_train,y_train)Inthissnippet,aDecisionTreeClassifierestimatorisﬁrstinitial-izedbysettingthemin_samples_splithyper-parameterto5(SeeSection3.5).Uponcallingfit,amodelislearnedfromthetrain-ingarraysX_trainandy_train,andstoredontheobjectforlateruse.Sinceallestimatorssharethesameinterface,usingadifferentlearningalgorithmisassimpleasreplacingtheconstructor(theclassname).Tobuildarandomforestonthesamedata,onewouldsim-plyreplaceDecisionTreeClassifier(min_samples_split=5)inthesnippetabovebyRandomForestClassifier().InScikit-Learn,classicallearningalgorithmsarenottheonlyob-jectstobeimplementedasestimators.Forexample,preprocessingroutines(e.g.,scalingoffeatures)orfeatureextractiontechniques(e.g.,vectorizationoftextdocuments)alsoimplementtheestimatorinterface.Evenstatelessprocessingsteps,thatdonotrequirethefitmethodtoperformusefulwork,implementtheestimatorinterface.Thisdesignpatternisofprimeimportanceforconsistency,composi-tionandmodelselectionreasons,asfurtherillustratedin[Buitincketal.,2013].5.3.1.3PredictorsThepredictorinterfaceextendsthenotionofanestimatorbyaddingapredictmethodthattakesanarrayX_testandproducespredictionsforX_test,basedonthelearnedparametersoftheestimator(wecalltheinputtopredict“X_test”inordertoemphasizethatpredictgeneralizestonewdata).Inthecaseofsupervisedlearningestima-tors,thismethodreturnsthepredictedlabelsorvaluescomputedbythemodel:#Makepredictionsonnewdatay_pred=clf.predict(X_test)Apartfrompredict,predictorsmayalsoimplementmethodsthatquantifytheconﬁdenceofpredictions.Inthecaseoflinearmodels,thedecision_functionmethodreturnsthedistanceofsamplestotheseparatinghyperplane.Somepredictorsalsoprovideapredict_probamethodwhichreturnsclassprobabilityestimates.Finally,supervisedpredictorsprovideascorefunctiontoassesstheirperformanceonabatchofinputdata.ThismethodtakesasinputarraysX_testandy_testandtypicallycomputesthecoefﬁ-cientofdeterminationbetweeny_testandpredict(X_test)inre-gression,ortheaccuracyinclassiﬁcation.Theonlyrequirementis5.3implementation103thatthescoremethodreturnavaluethatquantiﬁesthequalityofitspredictions(thehigher,thebetter).Anunsupervisedestimatormayalsoexposeascorefunctiontocompute,forinstance,datalikelihoodunderitsmodel.5.3.1.4APIforrandomforestsScikit-Learnprovidesefﬁcientimplementationsofdecisiontreesandrandomforests,allofferedasobjectsimplementingtheestimatorandpredictorinterfacespresentedabove.Mostofthehyper-parametersdescribedinthisworkaresupported.DecisionTreeClassifier,DecisionTreeRegressor:Implementsingledecisiontrees[Breimanetal.,1984],asde-scribedinChapter3.BaggingClassifier,BaggingRegressor:ImplementBagging[Breiman,1994],RandomSubspaces[Ho,1998]andEnsemblesofRandomPatches[LouppeandGeurts,2012],asdescribedinChapters4and8.RandomForestClassifier,RandomForestRegressor:ImplementRandomForest[Breiman,2001],asdescribedinChap-ter4.ExtraTreesClassifier,ExtraTreesRegressor:ImplementExtremelyRandomizedTrees[Geurtsetal.,2006a],asdescribedinChapter4.5.3.2InternaldatastructuresAmongallpossiblewaysofrepresentingadecisiontree,oneofthesimplestandmostdirectrepresentationsistoadoptanobject-orientedapproach.Inthisparadigm,adecisiontreeisnaturallyrepresentedasahierarchyofhigh-levelobjects,whereeachobjectcorrespondstoanodeofthetreeandcomprisesattributesreferencingitschildrenorstoringitssplitandvalue.Sucharepresentationwouldmakeforacorrect,intuitiveandﬂexibleimplementationbutmayinfactnotbethemostappropriatewhenaimingforhigh-performance.Oneofthebiggestissuesindeedisthatobject-orientedprogrammingusuallyfragmentscomplexandnestedobjectsintonon-contiguousmemoryblocks,therebyrequiringmultiplelevelsofindirectionfortraversingthestructure.Inparticular,thisdesigncaneasilyimpaircomputingtimesinperformance-criticalapplications,e.g.,bynotmakingitpos-sibletoleverageCPUcacheorpre-fetchingmechanisms.Atthepriceoflessabstractionandﬂexibility,weadoptinsteadinthisworkacompactlow-levelrepresentationofdecisiontrees,allowingusfor104complexityanalysisandimplementationaﬁne-grainedandcompletecontrolovermemorymanagementandCPUmechanisms.Lett∈{0,...,T−1}denoteuniquenodeidentiﬁersandlett=0correspondstotheidentiﬁeroftherootnode.Thedatastructurethatweproposeforrepresentingdecisiontreesconsistsinusingcontigu-ousarraysforsimultaneouslystoringthecontentofallnodes,asde-ﬁnedbelow:left_child(arrayofTintegers):Storethenodeidentiﬁerleft_child[t]∈{0,...,T−1}oftheleftchildofnodet.right_child(arrayofTintegers):Storethenodeidentiﬁerright_child[t]∈{0,...,T−1}oftherightchildofnodet.feature(arrayofTintegers):Storetheidentiﬁerfeature[t]∈{1,...,p}ofthevariableusedforsplittingnodet.threshold(arrayofTreals):Storethecut-offvaluethreshold[t]∈Rusedforsplittingnodet.impurity(arrayofTreals):Storetheimpurityi(t)atnodet,ascomputedonthelearningsetL.n_samples(arrayofTintegersorreals):Storethe(weighted)numbern_samples[t]oflearningsamplesreachingnodet.value(arrayofT×JrealsorTreals):Storetheclassprobabilityestimates(i.e.,thenumberofsamplesofeachclass)orthemeanregressionvalues,ascomputedfromthelearningsamplesreachingnodet.Asanexample,Table5.2illustratesthearrayrepresentationofthedecisiontreeshowninFigure5.2,asbuiltfromthelearningsetLofFigure5.1.Internalnodes(t0,t2,t3andt6)arenodesforwhichthecorrespondingvaluesinleft_child,right_child,featureandthresholdarenotempty,whileleaves(t1,t4,t7andt8)correspondtonodesforwhichthesevaluesarenotdeﬁned.Inthecaseofclassiﬁ-cation,thevaluearraycontainsthenumberofsamplesofeachclassforeachnode.Fromthese,classprobabilityestimatespL(Y=c|t)canbecomputedbydividingvalue[t][c]bythenumberofsam-plesn_samples[t]int.Inthecaseofregression,value[t]wouldcontaintheaverageoutputvalueforthesamplesint.Finally,letusnotethatstoringnodeimpuritiesintheimpurityarrayisnotstrictly5.3implementation1050.20.00.20.40.60.81.01.20.20.00.20.40.60.81.01.2Figure5.1:Binaryclassiﬁcationtask.t0t1t2t3t4t5t6t7t8X2≤0.303X2≤0.696X1≤0.296X1≤0.703c1c1c1c2c1Figure5.2:DecisiontreelearnedfromFigure5.1.t012345678left_child1–35––7––right_child2–46––8––feature2–21––1––threshold0.303–0.6960.296––0.703––impurity0.2730.0.3680.4820.0650.0510.480.0420.n_samples300992011138838754629value251/4999/0152/4967/4685/337/130/451/4529/0Table5.2:ArrayrepresentationofthedecisiontreeinFigure5.2.necessary,sincethesevaluesareonlyusedduringconstruction.Yet,storingthemcanprovetobevaluable,e.g.,forlaterinspectionofthedecisiontreeorforcomputingvariableimportances(seeChapter6)morereadily.Byimplementingthearrayrepresentationasdynamictables[Cor-menetal.,2001],insertionofnewnodeshasanO(1)amortizedcost,whilekeepingmemoryallocationsataminimumandtherebyreducingtheoverheadthatwouldotherwiseoccurusingper-nodedatastructures.Maintainingtherepresentationcontiguouslyinmem-oryalsobringsthebeneﬁtsofleveragingCPUcaches,whichmightgreatlyimproveperformancewhenfastpredictionsarecritical.Sincenodesareaccessedsuccessivelyandrepeatedlyattesttime,storingtheminnearbymemorylocationsisindeedhighlyrecommended.106complexityanalysisandimplementation5.3.3BuildersTheimplementationoftheinductionprocedureinScikit-Learnre-volvesaroundthreenestedcomponents:(a)TheﬁrstcomponentisaBuilderobjectwhoseroleistoeffec-tivelybuildthetreearrayrepresentationpresentedabove,byrecursivelypartitioningnodesusingsplitsfoundbyaSplitterobject.(b)ThesecondcomponentisaSplitterobjectwhoseroleistoﬁndsplitsoninternalnodes.(c)ThethirdcomponentisaCriterionobjectwhoseroleistoeval-uatethegoodnessofasplit.ThemostdirectBuilderimplementationisthedepth-ﬁrstgreedyinductionprocedureasoriginallyoutlinedinAlgorithm3.2.Acriticalaspectofthisalgorithmishowtokeepaccountofthetheinputsam-ples(x,y)∈Ltthatarriveatnodet.Astraightforwardsolutionistostorelistsofindicesoftheinputsamplesatnodet.Aspointedoutin[CriminisiandShotton,2013],buildingmanysuchlistsishoweverinefﬁcientbecauseofrepeatedmemoryallocationsanddeallocations.Abettersolutionistohaveinsteadallindicesstoredinasinglestaticarrayandtousein-placereorderingoperationswhenpartitioningt.Morespeciﬁcally,letassumethatsamplesisthelistofallindicesandthatstartandendareboundssuchthatsamples[start:end]containsthesampleindicesatthecurrentnodet.Iftissplitonfeaturefeature[t]andthresholdthreshold[t],thenLtcanbepar-titionedintoLtLandLtRbyreorganizingsamples[start:end]intosamples[start:pos]andsamples[pos:end],suchthatallsamplesintheﬁrstpartareontheleftsideofthesplitwhileallsamplesinthesecondpartareontherightsideofthesplit.Theinductionprocedurethenproceedsbypushingtheboundsstart:posandpos:endonthestackS,asanefﬁcientwaytoeffectivelyrepresentLtLandLtR.AnalternativeimplementationoftheBuilderinterfaceconsistsinreplacingthestackSinAlgorithm3.2byapriorityqueue,hencechangingtheorderinwhichthenodesaresplit.Inparticular,ifnodestareprioritizedbyweightedpotentialimpuritydecreasep(t)∆i(s∗,t)(wheres∗isthebestsplitont),thenthegreedyinductionprocedureswitchesfromadepth-ﬁrstconstructionofthetreetoabest-ﬁrstinduc-tionprocedure.Inthisway,anadditionalstoppingcriterioncanbede-ﬁnedasthemaximumnumbermax_leaf_nodesofleavesinthetree.Ifnodesareexpandedinbest-ﬁrstorder,thentheresultingtreeonlyincludesthemostsigniﬁcantsplits,therebypre-pruningall(seem-ingly)irrelevantbrancheswithoutwastingcomputationalresources.Alternativesalsoincludeprioritizingnodesaccordingtotheirimpu-rityi(t)ortheirsizeNt.5.3implementation107Likewise,thestackSinAlgorithm3.2canbereplacedbyadequedatastructure,inwhichcasetheinductionprocedureswitchestoabreadth-ﬁrstconstructionofthetree.Withsomemodiﬁcations,breadth-ﬁrstconstructionshowstobemoreefﬁcientwhenitisexpensivetorandomlyaccessthedata[CriminisiandShotton,2013],e.g.,whendataaretoobigtoﬁtintomemoryandmustbestreamedfromdisk.Breadth-ﬁrstinductionalsoprovestobeanefﬁcientstrategywhencombinedwithparallelism,e.g.,forbuildingawholelevelofthede-cisiontreesimultaneouslyusingmultiplecores[Liaoetal.,2013].5.3.4SplittersInScikit-Learn,Splitterobjectsimplementsearchproceduresforﬁndingsplitsoninternalnodes.Inthecaseofdecisiontrees,theyimplementalgorithms3.3and3.4forﬁndingthebestsplitoverallpinputvariables.Inthecaseofrandomizedtrees,theyimplementthesearchprocedure4.1overK6prandomlydrawninputvariables,combinedwitheitheralgorithm3.4or4.3torespectivelyobtainRan-domForestsorExtremelyRandomizedTrees.Again,severalaspectsofthealgorithmshouldbeconsideredwithcaretoobtainanefﬁcientimplementation:Dataaccess.LookingforthebestsplitontheinputvariableXjandparti-tioningLtrequirestorepeatedlyaccessoverthenodesamplevaluesxi,j(i.e.,overvaluesinthej-thcolumnifsamplesarerepresentedasatwodimensionalarray),whichmaycomesatanonnegligiblecostifdataisnotorderedproperly.However,duetoCPUcachingandpre-fetchingeffects,theclosertheval-uesinmemory,usuallythelowerittakestoaccessthem.Inourcase,thiscanbeexploitedintwowaystominimizethecostofdataaccess:-BystoringthelearningsetLusingcolumn-majororder(i.e.,Fortranarraymemorylayout),hencestoringtheval-uesxi,jofXj(forallsamplesi=1,...,N)contiguouslyinmemory.-Bypre-fetchingthenodesamplevaluesxi,j(fori=1,...,Nt)manuallyintoastaticandcontiguousbuffer,onwhichthesearchprocedureisthenapplied.Sortalgorithm.InCARTandRandomForests,ﬁndingthebestsplitonXjre-quirestosortthesampleindicessamples[start:end]alongtheirrespectivevaluesonXj,i.e.,suchthatX[samples[start],j]6···6X[samples[start+i],j]108complexityanalysisandimplementation6···6X[samples[end-1],j],fori=0,...,Nt−1.AsshowninSection5.1,thisoperationdrivesthecomplexityoftheoverallinductionprocedureandisthereforecriticalintheimplementationofthealgorithm.Toguaranteethelowesttimecomplexityinallcases,werelyonIntrosort[Musser,1997]whichcombinesQuicksortandHeap-sortintoahybridsortingalgorithm.Basically,sortinginIn-trosortbeginswithQuicksortandthenswitchestoHeapsortwhenthedepthofpartitioningexceedsΘ(logN).Assuch,thepracticalΘ(NlogN)performanceofIntrosortiscomparabletotheaverageperformanceofQuicksort,exceptthatperformanceintheworstcaseisboundedtoΘ(NlogN)duetoHeapsort,insteadofΘ(N2)intheworstcaseforQuicksort.Addition-ally,Quicksortisimplementedusingthemedian-of-threeaspivot[BentleyandMcIlroy,1993],henceyieldingbetterparti-tionsandfurtherimprovingperformance.Inthecontextofthetreeinductionprocedure,letusﬁnallyno-ticethatpartitioningnodesamplesLtintosubsetsLtLandLtRnotonlymakesthempurerintermsoftheoutputvariableY,italsoindirectlymakesnodesamplesmoreandmoreidenticalintermsofthevaluestakenbytheinputvariables.Aswegetdeeperintothetree,thispropertycanbeleveragedbyimple-mentingQuicksortasa3-wayrecursivepartition[BentleyandMcIlroy,1993],asillustratedinFigure5.3.Inthisvariant,ele-mentsthatareidenticaltothepivotareallsetattheirﬁnalpo-sitionsinasinglerecursivecall,henceacceleratingthesortingprocedure.Ifthenumberofdistinctvaluesisconstant,3-wayQuicksortcanbeshown[SedgewickandWayne,2011]tore-ducerunningtimesfromO(NlogN)toO(NH),whereHistheShannonentropydeﬁnedonthefrequenciesofthevaluestobesorted.Asaconsequence,inthecaseofmanyduplicates(i.e.,whenH=O(1)),C(N)=O(N)andusing3-wayQuicksortforsortingthesampleindicesinfactreducestheoverallcomplexityofRandomForeststotheasymptoticcomplexityofExtremelyRandomizedTrees(seeSection5.1).samplesstartendlir<=>Figure5.3:3-waypartitioninQuicksort.Oncei=r,elementsthatareidenti-caltothepivotareallsetattheirﬁnalpositionssamples[l:r],inasinglerecursivecall.Thesub-arrayssamples[start:l]andsamples[r:end]arethenrecursivelysorted.5.3implementation109Skippinglocallyconstantinputvariables.Intheextremecase,recursivelypartitioningnodesamplesmightresultininputvariablesXjtobecomelocallyconstantatt.Thatis,xj=x0jforall(x,y),(x0,y)∈Lt.Insuchacase,thereisnovalidsplitonXjandtryingtoﬁndoneatt,butalsoatanyofthedescendantnodes,isawasteofcomputationalre-sources.Accordingly,Algorithm4.1canbeextendedtoaccountforvariablesthatareknowntobeconstant,therebyskippingnon-informativevariablesifweknowinadvancethatnovalidsplitcanbefound.Tostayascloseaspossibletotheoriginalal-gorithm,notehoweverthatconstantvariablesarestillincludedwhendrawingKvariablesatrandom.Splitapproximations.InChapter4,weshowedthatanincreaseofbiasduetoran-domizationisbeneﬁcialaslongasitsufﬁcientlydecorrelatesthepredictionsoftheindividualtrees.Giventhisresult,ale-gitimatequestionistowonderifﬁndingtheverybestsplitss∗jreallyisimperativeintheﬁrstplacetoachievegoodaccuracyinrandomforests.AsprovedbythegoodresultsusuallyobtainedbyExtremelyRandomizedTrees,evensplitsthataredrawnatrandomareinfactoftensufﬁcienttoreachgood(sometimesevenbetter)performance.Moreimportantly,notonlythisyieldscomparableaccuracy,itisalsomorecomputationallyefﬁcient.Atmidwaybetweenexactbestsplits(asinAlgorithm3.4)andrandomsplits(asinAlgorithm4.3),anintermediateandprag-maticsolutionisthereforetoconsiderapproximationsofthebestsplits.Thetwomostcommonstrategiesarebasedonsub-samplingandbinning:-LetN0denoteanupperlimitonthenodesamplesize.IfNt>N0,thesubsamplingapproximationofthebestsplits∗jattonXjconsistsinlookingforthebestsplitusingonlyN0randomlydrawnnodesamplesfromLt,andallnodesamplesotherwise.Therationalebehindthisstrategyisthat,intheﬁrstnodesofthetree,thebestsplitsareoftensomarkedlysuperiortoallothersplitsthatthisclear-cutinformationalsoreﬂectsinasubsample.Fornodesfurtherdowninthetree(i.e.,forNt6N0),splitsareusuallylessmarkedbutthenallnodesamplesinLtareused,henceguaranteeingtoﬁndthesamesplitsasintheoriginalpro-cedure.Historically,thesubsamplingstrategywasﬁrstpro-posedin[Breimanetal.,1984]inthecontextofsingledeci-siontrees,fordatasetstoolargetobeheldinmemory.-Analternativebutclosestrategyistoconsideronlyasub-setofthepossiblediscretizationthresholdsv0kinsteadofexhaustivelyevaluatingallcandidatesplits.Inbinning,this110complexityanalysisandimplementationisperformedbygroupingtogethernodesamplesthatareclosetoeachotherintobinsandthenevaluatingonlythethresholdsin-betweenthesegroups.ThesimpleststrategyofallistodividethevalueintervalofXjattintoDinter-valsofequallength.AnotherstrategyistosortthenodesamplesalongtheirrespectivevaluesofXjandtoparti-tionthemintoDsubsetsofequalsize.Moreelaborateal-gorithms,alsoknownasattributediscretizationprocedures,arereviewedin[ZighedandRakotomalala,2000].Pre-sortingdata.Asshownearlier,sortingnodesamplesforeachcandidatesplitsigniﬁcantlyimpactstheoverallcomplexityoftheinductionprocedure.Analternativestrategyispossible[Breiman,2002]andconsistsinpresortingthesamplesforallpinputvariablesbeforetheconstructionofthetree.Morespeciﬁcally,leti=1,...,eNdenotetheoriginalindicesoftheuniqueinputsamplesinLm.ForeachinputvariableXj(forj=1,...,p),thesortedindicesσj1,...,σjeN,suchthatxσj1,j6···6xσjeN,j,(5.36)canbecomputedinO(peNlogeN).Giventheseindices,ﬁndingthebestsplitatanodethensimplyamountstoiterate,inthatorder,overthesamplesσj1,...,σjeN(forallKofthesplitvariablesXj),whichreducescomplexitytoO(KeN)insteadofO(KeNlogeN).PartitioningthenodesamplesintotLandtRthenrequirestopartitionallplistsofsortedindicesinto2psub-listsofeNtLandeNtRsortedindicesσj1,...,σjeNtLandσj1,...,σjeNtR,whichcanbedoneinO(peN).Intotal,thewithin-nodecomplexityisC(eN)=O(KeN+peN)=O(peN).(5.37)Usingthisalternativestrategy,thetimecomplexityofRFforthebest,theworstandtheaveragecasesisrespectivelyO(MpeNlogeN),O(MpeN2)andO(MpeNlogeN),asderivedfromtheorems5.3,5.5and5.7forK=p.Neglectingconstantfactors,theratiobetweenthetwoimplementationsisO(pKlogeN),whichmightnotneces-sarilyleadtofasterbuildingtimesdependingonKandthesizeoftheproblem.Forthisreason,pre-sortingisinfactnotusedwithintheScikit-Learnimplementationofrandomforests.5.3.5CriteriaThelastcomponentsoftheimplementationofdecisiontreesinScikit-LearnareCriterionobjectsforevaluatingthegoodnessofsplits.Supportedcriteriaare"gini"and"entropy"inclassiﬁcation,and5.3implementation111thereductionofvariance"mse"inregression.AllofthemimplementtheupdatemechanismsdescribedinSection3.6.3.1,suchthattheit-erativeevaluationofNt−1splitsonanorderedvariableremainsaO(Nt)operation.5.3.6ParallelizationScikit-Learnimplementationofrandomforestssupportsparallelismtodistributecomputationsonmulti-corearchitectures.Thesimple,yeteffective,approachthatweimplementistoconsidertheconstruc-tionofaforestasanembarrassinglyparallelproblem,inwhichtheMdecisiontreesarebuiltconcurrentlyandindependentlyonmultipleprocessors.Assumingnooverheadduetoparallelization,thetheoret-icalspeedupofthisstrategyisequaltothenumberNpofprocessorsusedforbuildingtheforest.Inpracticehowever,thisupperboundisnotalwaysstrictlyreachedduetothevarianceofthetimerequiredforbuildingrandomizedtrees.Itmayindeedhappenthatbuildingtreestakelongerthanbuildingsomeothers,therebyunder-utilizingcomputationalresourcessincejobsmayhaveﬁnishedsoonerthanothers.Moreﬁne-grainedapproachesconsistinbuildingdecisiontreesoneattime,butusingmultipleprocessors.Inthenode-baseddecomposition,theconstructionofatreeisdistributedbybuildingmultiplenodesconcurrently.Inthiscase,workloadcanbedividedbetweenproces-sorsusingabreadth-ﬁrstinductionprocedureandassigningwholesub-treestodeveloponcethewaitingqueuecontainsNpnodes.Onceagainhowever,sub-treesmaytakelongertobuildthanothers,henceunder-utilizingcomputationalresourcesiftheresultingdecisiontreeisnotbalanced.Toalleviatethisissue,processorsmaybeassignedsinglenodestodevelop(thatis,oneatatime)usingaproducer-consumerschemetobalanceworkloadinafairway.Unfortunately,thislatterapproachoftenprovestobedominatedinpracticebytheoverheadduetotaskassignmentandbookkeepingactivities.Alter-natively,theconstructionofatreecanalsobedistributedusinganattribute-baseddecomposition.Inthiscase,theworkloadisdividedbyparallelizingthesearchoftheKbestsplitsatagivennode(seeAlgo-rithm4.1).Fordetailedreviewsonthetopic,see[Kufrin,1997;Srivas-tavaetal.,2002].Usingsimilarorhybridapproaches,letusﬁnallynotethattheparallelinductionofrandomforestsextendtootherdistributedar-chitectures,includingGPUs[Sharp,2008;Liaoetal.,2013],FPGA[Narayananetal.,2007]orclusters[Mitchelletal.,2011].112complexityanalysisandimplementation5.4benchmarks5.4.1ComplexityonartiﬁcialdataInthissection,westudytheempiricalcomplexityofrandomforestsonartiﬁcialdata.OurgoalistoinvestigatewhetherthetheoreticalresultsthathavebeenderivedinSections5.1and5.2holdtrueinpractice,evenwithoutourassumptionsnecessarilysatisﬁed.Forourexperimentsonsimulateddata,weconsidertheFried-man#1artiﬁcialregressionproblem[Friedman,1991].Itconsistsin10independentinputvariablesX1,...,X10,eachuniformlydistributedover[0,1].TheoutputYisareal-valuedvariableandisgivenbyY=10sin(πX1X2)+20(X3−0.48)2+10X4+5X5+(cid:15)(5.38)where(cid:15)isN(0,1).WestudytheeffectsofthenumberMoftreesintheforest,thenumberNofinputsamples,thenumberpofinputvariables(byaddingnewirrelevantvariables),thenumberKofvari-ablesdrawnateachnodeandtheeffectsofusingbootstrapreplicatesLminsteadofL.Hyper-parametersarestudiedindependentlyforboth(fullydeveloped)RandomForests(RF)andExtremelyRandom-izedTrees(ETs)builtonN=1000learningsamplesofp=10inputvariables,withM=250treesandK=√psetbydefault.Statisticsreportedbelowareaveragesover10runs.Figures5.4-5.8allillus-tratetheeffectofonethehyper-parameterswithrespecttothetimerequiredforbuildingaforest(ontheleftplots),theaveragedepthofthetrees(inthemiddleplots)andthemeansquarederroroftheensemble(ontherightplots).Figure5.4ﬁrstdemonstratestheeffectofthenumberMoftrees.Asexpected,thetimecomplexityoftheinductionprocedureisO(M)whiletheaveragedepthoftheleavesisconstantwithM,sincethelaterhasnoeffectonthestructureoftheindividualtrees.TheleftplotalsoconﬁrmsthatETsarefastertobuildthanRF,eveniftreesinETsareonaverageoneleveldeeperthattreesinRFs,asshowninthemiddleplot.Finally,themeansquarederrorofthemodelshowstobeinverselyproportionaltothenumberoftreesintheforest,whichconﬁrmsourpreviousresultsonvariancereductionfromChapter4.Figure5.5considerstheeffectofthenumberNoftrainingsamples.Asshownontheleftplot,buildingtimesgrowslightlyfasterthanlinearly,whichappearstoconﬁrmtherespectiveO(Nlog2N)andO(NlogN)dependenciesofRFandETswiththesizeofthelearningset(asderivedinSection5.1).Similarly,themiddleplotconﬁrmsthattheaveragedepthoftheleavesgrowsinO(logN)withN(asshowninSection5.2).Asexpected,therightplotalsoillustratesthatthemorethedata,thebettertheresultingmodel.Additionally,itshowsthatRFandETstendtowardsthesameerrorrateasNincreases,evenifRFwasstrictlybetteronlessdata.Thisconﬁrmsonceagainthatﬁndingtheverybestsplitsisnotstrictlynecessarytoachievegoodresults.5.4benchmarks113100200300400500600700800n_estimators0123456Fittime(s)Scikit-Learn-RFScikit-Learn-ETs100200300400500600700800n_estimators11.411.611.812.012.212.412.6Averagedepth100200300400500600700800n_estimators246810121416MSEFigure5.4:EffectofthenumberM(=n_estimators)oftreesontrain-ingtime(left),averagedepth(middle)andmeansquarederror(right).N=1000,p=10,K=√p.020000400006000080000100000n_train050100150200250Fittime(s)Scikit-Learn-RFScikit-Learn-ETs020000400006000080000100000n_train0510152025Averagedepth020000400006000080000100000n_train01020304050MSEFigure5.5:EffectofthesizeN(=n_train)ofthelearningsetontrain-ingtime(left),averagedepth(middle)andmeansquarederror(right).M=250,p=10,K=√p.2004006008001000n_features02468101214Fittime(s)Scikit-Learn-RFScikit-Learn-ETs2004006008001000n_features11.011.512.012.513.013.5Averagedepth2004006008001000n_features0510152025MSEFigure5.6:Effectofthenumberp(=n_features)ofinputvariablesontrain-ingtime(left),averagedepth(middle)andmeansquarederror(right).N=1000,M=250,K=√p.114complexityanalysisandimplementation12345678910max_features0.00.51.01.52.02.53.03.54.0Fittime(s)Scikit-Learn-RFScikit-Learn-ETs12345678910max_features02468101214Averagedepth12345678910max_features0123456789MSEFigure5.7:EffectofK(=max_features)inrandomvariableselectionontrainingtime(left),averagedepth(middle)andmeansquarederror(right).N=1000,M=250,p=10.FalseTruebootstrap0.00.51.01.52.02.5Fittime(s)Scikit-Learn-RFScikit-Learn-ETsFalseTruebootstrap02468101214AveragedepthFalseTruebootstrap0.00.51.01.52.02.53.03.54.04.5MSEFigure5.8:Effectofbootstrapreplicatesontrainingtime(left),averagedepth(middle)andmeansquarederror(right).N=1000,M=250,p=10,K=√p.Next,Figure5.6showstheeffectofirrelevantandnoisyvariables.Therightplotﬁrstindicatesthataddingirrelevantvariablesdeteri-oratestheaccuracyoftheforests.Thisisexpectedsincethemoretheirrelevantvariables,thehighertheprobabilityofsplittingononeofthemandthereforeofﬁttingnoiseinthedata.Moreimportantly,theleftandmiddleplotsshowthatRFismoreaffectedthanETsbytheadditionofnoisyvariables.Thisisactuallyaconsequenceoftheend-cutpreferenceoftheclassicalimpuritycriteria.Whensplittingonnoisyvariablesandlookingforthebestthreshold,partitionsofthenodesamplesaremorelikelytobeunbalancedratherthantheopposite.ThisexplainswhyonthemiddleplottheaveragedepthofRFeventuallygetslargerthanthedepthofETs–whichsufferslessfromend-cutpreferencesincethresholdsarenotoptimizedlocally.Figure5.7illustratestheeffectofrandomvariableselection.Ontheleftplot,buildingtimesgrowasexpectedinO(K)withthenumberKofvariablesrandomlydrawnateachnode.TheaveragedepthofthetreeshowsthatincreasingKslightlyreducesthedepthofthetrees,whichisexplainedbythefactthatbettersplitsareselectedas5.4benchmarks115morevariablesareevaluated.Finally,therightplotagainconﬁrmsresultsfromChapter4.Randomperturbationsnegativelyimpacttheresultingmodelwhentheyaretoostrong(atK=1)butthenbecomebeneﬁcialasKincreases.ForRF,theoptimaltrade-offisatK=5whilethelowesterrorcanbeachievedinETsforK=7.Finally,Figure5.8studiestheeffectofusingbootstrapreplicates.ForRF,learningtreesfromlearningsetsLmdrawnwithreplacementfromL(bootstrap=True)isabout1.5fasterthanbuildingtreesdi-rectlyonL(bootstrap=False),whichisinaccordancewithourthe-oreticalresultsfromSection5.1.TheeffectforETsislessstrong,butstillleadstoanon-negligiblespeedup.TheaveragedepthforRFandETsisroughly0.5lowerwhenusingbootstrapreplicates.Again,thisisexpectedsincetheaveragedepthgrowswithO(logN)andthatre-ducingtheeffectivesizeofthelearningsettoeN=0.632Nreducesitslogarithmby−log(0.632)=0.662.Finally,therightplotshowsthatusingbootstrapreplicatesactuallyimpairsperformanceonthisproblem.Whilenotdiscussedhere,furtherexperimentscarriedoutonotherartiﬁcialdata,forbothregressionandclassiﬁcation,leadtosimilarconclusions.Theyallcorroboratethetheoreticalresultspresentedear-lier.5.4.2ComparisonwithotherimplementationsDuetotheirapparentsimplicity,randomforestshavebeenreimple-mentedatmultipleoccasionsinvariousmachinelearninglibrariesandprogramminglanguages.Inthissection,wecomparetheScikit-Learnimplementationdevelopedwithinthisworkwithpopularal-ternativesavailableinothermachinelearningpackages.Table5.3summarizesthemainopensourceimplementationsofrandomforestsalongwithsomeoftheirsupportedfeatures.Allim-plementtheoriginalRandomForestalgorithm[Breiman,2001]andthereforealsoprovideaninterfaceforBagging[Breiman,1994](sinceitcorrespondstothespecialcaseK=p).Scikit-Learn,OpenCVandOK3alsooffervariantslikeExtremelyRandomizedTrees[Geurtsetal.,2006a]orRandomSubspaces[Ho,1998].Allsupportbothclas-siﬁcationandregressiontasks,withtheexceptionsofWekaandH2Owhichappeartoonlysupportclassiﬁcation.Fromaparameterpointofview,implementationsmostlydifferfromeachotherintheimpu-rityandstoppingcriteriatheysupport.ThemostcommonimpuritycriterionisGini(or,equivalently,MSE)butsomepackages,likeOr-ange,includealternativemeasuressuchasentropy,gainratioorRe-lief[KiraandRendell,1992].Themostcommonstoppingcriteriaareanupperboundonthedepthofthetrees(e.g.,max_depthinScikit-Learn)andaminimumnumberofsamplesrequiredforsplittinganode(e.g.,nmininOK3).Somepackagesalsoallowtosetanupper116complexityanalysisandimplementationLibraryAlgorithmsTasksImpurityStoppingcriteriaVariableimportancesMulti-threadOpensourceLanguageReferenceScikit-LearnBagging,RF,ETs,RS,RPC/RGini,Entropy,MSEmax_depth,min_samples_split,min_samples_leaf,max_leaf_nodes33BSDPython[Pedregosaetal.,2011]OpenCVBagging,RF,ETsC/RGinimax_depth,min_samples_count,forest_accuracy37BSDC/C++[BradskiandKaehler,2008]OK3Bagging,RF,ETsC/RMSEvarmin,nmin,maxnbsplits37Source-availableC[Geurtsetal.,2006a]WekaBagging,RFCGinidepth73GPLJava[Halletal.,2009]randomForestBagging,RFC/RGininodesize,maxnodes37GPLR[LiawandWiener,2002]OrangeBagging,RFC/RGainRatio,Gini,Relief,MSEworst_acceptable,min_susbet,min_instances,max_depth,max_majority77GPLPython[Demšaretal.,2013]H2OBagging,RFCGini,EntropymaxDepth73ApacheJava[Vitek,2013]Table5.3:Popularlibrariesforrandomforests.5.4benchmarks117limitonthenumberofnodesinthetreesortostoptheconstructionwhenaﬁxedaccuracyisreached.Despitetheembarrassingparal-lelism,onlyScikit-Learn,WekaandH2Omakeitpossibletobuildrandomforestsusingmultiplecores.Mostnotably,H2ObuildsontopofHadooptoprovideafullydistributedimplementationofran-domforests(i.e.,onacluster).Forperformancereasons,implementationslistedinTable5.3havemostlybeenwritteninlow-levelprogramminglanguageslikeC,C++orJava,butusuallyinterfacewithhigherlevellanguages,likePython,MATLABorR,forconveniencereasons.InthecaseofOpenCVforexample,thecoreimplementationiswritteninC++butcaneas-ilybeencalledfromPythonthroughbindingsshippedwiththeli-brary.LetusﬁnallynotethatTable5.3isbynomeansanexhaustivelistofallimplementationsofrandomforests.Domain-speciﬁcimple-mentations(e.g.,RandomJungle[Schwarzetal.,2010]forGWASorTMVA[Hoeckeretal.,2007]inparticlephysics)andproprietarysoft-ware(e.g.,SalfordSystems,whichownstheRandomForeststrade-mark)arenotlistednorevaluatedhere.Intheexperimentscarriedoutbelow,webenchmarktheScikit-LearnimplementationsofRFandETsagainstalllibrarieslistedinTable5.3.WedonotcompareagainstH2Osinceitrequiresadedi-catedcloudenvironment.Implementationsareallbenchmarkedon29well-knownandpubliclyavailableclassiﬁcationdatasetsthatwerechosenaprioriandindependentlyoftheresultsobtained.Overall,thesedatasetscoverawiderangeofconditions(includingbotharti-ﬁcialandrealdata),withasamplesizeNrangingfrom208to70000andanumberpofvariablesvaryingfrom6to24496.Implementa-tionsareevaluatedfor(fullydeveloped)RandomForests(RF)andExtremelyRandomizedTrees(ETs)wheneveravailable,usingrespec-tively75%and25%oftheoriginaldatasetaslearningandtestsets,M=250treesandK=√psetbydefault.Resultsreportedbelowareaveragesover10runs,withthelearningandtestsetsresampledateachfold.Tables5.4and5.5respectivelyreporttheaveragetimerequiredforbuildingarandomforestandtheaveragetimerequiredmakingpredictions,onall29datasetsandforallimplementations.ComputingtimesarereportedusingtheScikit-LearnimplementationofRFasabaseline.Resultsinboldindicatethattheimplementationisthefastestonthedataset.Remarkthattimesarenotreportedoncifar10forRandOrangebecausetheseimplementationsfailedatbuildingasingleforestwithin96hoursforCPUtime.WithrespecttoRF,Table5.4showsthatScikit-Learnisthefastestonaverage,farbeforeallothers.OK3isthesecondfastestimple-mentation(2.63×sloweronaverage),Wekaisthird(2.92×slower),OpenCVisfourth(12.37×slower),Orangeisﬁfth(17.80×slower)andtheRimplementationislast(30.73×slower).Inparticular,theRimplementationshowstobeveryineffectiveonlargedatasets,when118complexityanalysisandimplementation02000400060008000100001200014000Fittime(s)203.01211.534464.653342.831518.141711.941027.9113427.0610941.72Scikit-Learn-RFScikit-Learn-ETsOpenCV-RFOpenCV-ETsOK3-RFOK3-ETsWeka-RFR-RFOrange-RF0102030405060708090Predicttime(s)3.774.1111.248.2410.0911.6411.6813.2180.62Figure5.9:Averagetimerequiredforbuildingaforestonthemnistdataset(left)andaveragetimerequiredformakingpredictions(right).bothNandparemoderatelylarge(e.g.,onmnist,asfurtherillus-tratedinFigure5.9).ApossibleexplanationisthattheRimplemen-tationusespre-sorting(seeSection5.3.4),whichmakescomplexitylinearwithpratherthanwithK.RegardingOrange,resultscanbeexplainedbythefactthattheimplementationispurelywritteninPython(i.e.,aninterpretedhigh-levelprogramminglanguage),whileallothersarewritteninoptimizedlow-levelprogramminglanguages.WithrespecttoETs,theScikit-Learnimplementationisagainthefastest,farbeforeallothers.Moreinterestingly,thetablealsoshowsthatETsareusuallyfastertobuildthanRF,whichconﬁrmsthetheo-reticalresultspresentedearlier.FortheScikit-Learnimplementation,ETsareindeedempirically10.71=1.41×fasterthanRFonaverage.Table5.5reportsresultsregardingtheaveragetimerequiredformakingpredictionsonthetestset.Again,theScikit-Learnimplemen-tationofRFisthefastestimplementationonaverage.OpenCVissec-ond(2.07×sloweronaverage),OK3isthird(3.71×slower),Wekaisfourth(4.31×slower),Risﬁfth(9.64×slower)andOrangeislast(19.82×slower).Bycontrastwithﬁttingtimes,makingpredictionsfromETsisnowslightlyslowerthanRF,whichisexplainedbythefactthattreesinETsareonaveragedeeperthaninRF.Inconclusions,benchmarksshowthattheScikit-Learnimplemen-tationisonaveragesigniﬁcantlyfasterthanOpenCV,OK3,Weka,RandOrange.Whiletheseresultssufferfromaselectionbias(i.e.,theydependonthe29selecteddatasets),webelievethatthegeneralconclusionsextendtootherdatasets.Moreimportantly,thecarefuldesignandimplementationofeachandeverycomponentofrandomforests,asdiscussedallthroughoutthiswork,eventuallyshowstobehighlyrewardingintermsofcomputationalperformance.5.4benchmarks119DatasetSklearn-RFSklearn-ETsOpenCV-RFOpenCV-ETsOK3-RFOK3-ETsWeka-RFR-RFOrange-RFarcene1.000.7726.3316.730.810.858.7022.844.78breast21.000.4135.1019.031.200.993.8833.4111.42cifar101.000.5222.8213.763.782.303.29––diabetes1.000.880.730.750.590.652.251.072.42dig441.000.391.010.712.682.031.701.6010.85ionosphere1.000.710.790.560.530.341.870.803.01isolet1.000.365.393.394.482.762.248.7016.58letter1.000.942.341.829.0510.573.134.4321.04liver1.000.950.380.460.330.422.800.581.42madelon1.000.465.824.071.380.822.066.1848.48marti01.000.315.704.451.080.551.3618.997.16mnist1.001.0421.9916.477.488.435.0666.1453.90mnist3vs81.000.9518.7413.903.323.043.6854.8927.80mnist4vs91.000.9720.2114.703.463.224.0957.1029.42musk21.000.444.592.442.000.951.975.4822.63pendigits1.000.611.601.123.613.092.302.649.24reged01.000.436.654.291.180.641.6310.027.04ring-norm1.000.220.630.431.130.421.111.219.92satellite1.000.562.101.362.691.971.942.5613.88secom1.000.215.592.611.540.481.005.4612.88segment1.000.761.090.811.911.791.831.645.97sido01.001.55133.11140.639.708.629.69468.8549.11sonar1.000.780.800.640.390.301.820.812.61spambase1.001.414.063.362.243.252.904.5915.85tis1.001.8426.8324.593.734.315.4174.7769.51two-norm1.000.300.980.661.120.551.211.3317.12vehicle1.000.741.401.081.631.462.231.696.51vowel1.000.590.670.591.871.501.991.088.18waveform1.000.431.200.941.490.981.491.509.79Average1.000.7112.3710.222.632.322.9230.7317.80Median1.000.614.062.441.871.462.234.5111.14Table5.4:Averagetimerequiredforbuildingarandomforest,relativetotheScikit-LearnimplementationoftheRandomForestalgorithm(ﬁrstcolumn).Thelower,thebetter.120complexityanalysisandimplementationDatasetSklearn-RFSklearn-ETsOpenCV-RFOpenCV-ETsOK3-RFOK3-ETsWeka-RFR-RFOrange-RFarcene1.001.020.380.400.550.785.655.466.70breast21.001.112.001.763.634.9733.9233.2644.73cifar101.001.133.172.252.823.056.23––diabetes1.001.251.001.781.342.471.490.9911.41dig441.001.253.604.404.625.863.251.4421.86ionosphere1.001.050.350.610.470.741.360.456.56isolet1.001.192.212.252.032.632.922.1712.28letter1.001.152.252.713.183.872.690.8514.91liver1.001.140.490.930.621.221.540.586.01madelon1.001.292.834.017.2811.033.583.0133.41marti01.001.100.681.000.731.093.232.429.80mnist1.001.092.982.182.683.093.103.5021.39mnist3vs81.001.051.741.711.902.372.553.4615.76mnist4vs91.001.212.292.242.422.923.215.2119.46musk21.001.152.623.313.104.182.882.0729.81pendigits1.001.182.703.723.664.972.891.0322.49reged01.001.090.480.690.510.812.842.3710.70ring-norm1.001.484.356.245.748.293.301.5928.55satellite1.001.072.643.433.464.512.631.1623.14secom1.001.071.871.982.092.223.062.7417.35segment1.001.491.252.151.662.862.230.8218.98sido01.001.122.022.182.522.9611.25184.5446.13sonar1.001.030.200.330.230.411.010.394.70spambase1.001.382.913.904.328.893.671.7326.51tis1.001.332.702.662.823.663.403.7016.65two-norm1.001.334.095.935.357.573.521.5232.80vehicle1.001.171.742.502.263.212.571.0717.61vowel1.001.181.071.601.432.121.530.7610.83waveform1.001.353.484.954.376.343.401.5224.53Average1.001.192.072.542.683.764.319.6419.82Median1.001.152.212.242.523.053.061.6618.29Table5.5:Averagetimerequiredformakingpredictions,relativetotheScikit-LearnimplementationoftheRandomForestalgorithm(ﬁrstcolumn).Thelower,thebetter.PartIIINTERPRETINGRANDOMFORESTS6UNDERSTANDINGVARIABLEIMPORTANCESOutlineInthischapter,westudyvariableimportancemeasuresascomputedfromforestsofrandomizedtrees.InSection6.1,weﬁrstpresenthowrandomforestscanbeusedtoassesstheimportanceofinputvari-ables.WethenderiveinSection6.2acharacterizationinasymptoticconditionsandshowthatvariableimportancesderivedfromtotallyrandomizedtreesofferathree-leveldecompositionoftheinforma-tionjointlycontainedintheinputvariablesabouttheoutput.InSec-tion6.3,weshowthatthischaracterizationonlydependsontherele-vantvariablesandthendiscusstheseideasinSection6.4inthecon-textofvariantsclosertotheRandomForestalgorithm.Finally,weillustratetheseresultsonanartiﬁcialprobleminSection6.5.Thischapterisbasedonpreviousworkpublishedin[Louppeetal.,2013].Animportanttaskinmanyscientiﬁcﬁeldsisthepredictionofare-sponsevariablebasedonasetofpredictorvariables.Inmanysitua-tionsthough,theaimisnotonlytomakethemostaccuratepredic-tionsoftheresponsebutalsotoidentifywhichpredictorvariablesarethemostimportanttomakethesepredictions,e.g.inordertounder-standtheunderlyingprocess.Becauseoftheirapplicabilitytoawiderangeofproblemsandtheircapabilitytobuildaccuratemodelsand,atthesametime,toprovidevariableimportancemeasures,randomforestshavebecomeamajordataanalysistoolusedwithsuccessinvariousscientiﬁcareas.Despitetheirextensiveuseinappliedresearch,onlyacoupleofworkshavestudiedthetheoreticalpropertiesandstatisticalmecha-nismsofthesealgorithms.Zhao[2000],Breiman[2004],Meinshausen[2006],LinandJeon[2002]andBiauetal.[2008];Biau[2012]investi-gatedsimpliﬁedtoveryclosevariantsofthesealgorithmsandprovedtheconsistencyofthosevariants.Littleisknownhoweverregardingthevariableimportancescomputedbyrandomforests,and–asfarasweknow–theworkofIshwaran[2007]isindeedtheonlytheoreticalstudyoftree-basedvariableimportancemeasures.Inthischapter,weaimatﬁllingthisgapandpresentatheoreticalanalysisoftheMeanDecreaseImpurityimportancederivedfromensemblesofrandom-izedtrees.123124understandingvariableimportances6.1variableimportances6.1.1ImportancesinsingledecisiontreesInthecontextofsingledecisiontrees,Breimanetal.[1984]ﬁrstde-ﬁnedthemeasureofimportanceofavariableXjasImp(Xj)=Xt∈ϕ∆I(˜sjt,t),(6.1)where˜sjtisthebestsurrogatesplitforst,thatistheclosestsplitdeﬁnedonvariableXjthatcanmimictheactualsplitstdeﬁnedatnodet.Theuseofsurrogatesplitswasproposedtoaccountformaskingeffects:itmayindeedhappenthatsomevariableXj2neveroccursinanysplitbecauseitleadstosplitsthatareslightlyworse,andthereforenotselected,thanthoseofsomeothervariableXj1.However,ifXj1isremovedandanothertreeisgrown,Xj2maynowoccurprominentlywithinthesplitsandtheresultingtreemaybenearlyasgoodastheoriginaltree.Insuchacase,arelevantmeasureshoulddetecttheimportanceofXj2.Accordingly,ifXj2isbeingmaskedattbyXj1(i.e.,ifXj1isusedtosplitt),butif˜sj2tissimilartost,butnotquiteasgood,then∆I(˜sj2t,t)willbenearlyaslargeas∆I(st,t)andthereforetheproposedmeasurewillindeedaccountfortheimportanceofXj2.6.1.2ImportancesinforestsThankstorandomization,maskingeffectsaredampenedwithinforestsofrandomizedtrees.EvenifXj2isbeingmaskedbyXj1thereisin-deedstillachanceforXj2tobechosenasasplitifXj1isnotselectedamongtheKvariableschosenatrandom.DependingonthevalueK,maskingeffectsdonotdisappearentirelythough.Theuseofboot-strapsamplesalsohelpsreducemaskingeffects,makingXj1orXj2justslightlybetterthantheotherduetothevariationsinthebootstrapsamples.Forthisreason,Breiman[2001,2002]proposedtoevaluatetheim-portanceofavariableXjforpredictingYbyaddinguptheweightedimpuritydecreasesp(t)∆i(st,t)forallnodestwhereXjisused,av-eragedoveralltreesϕm(form=1,...,M)intheforest:Imp(Xj)=1MMXm=1Xt∈ϕm1(jt=j)hp(t)∆i(st,t)i,(6.2)wherep(t)istheproportionNtNofsamplesreachingtandwherejtdenotestheidentiﬁerofthevariableusedforsplittingnodet.WhenusingtheGiniindexasimpurityfunction,thismeasureisknownastheGiniimportanceorMeanDecreaseGini.However,sinceitcanbedeﬁnedforanyimpuritymeasurei(t),wewillrefertoEquation6.2as6.1variableimportances125theMeanDecreaseImpurityimportance(MDI),nomattertheimpuritymeasurei(t).Wewillcharacterizeandderiveresultsforthismeasureintherestofthistext.InadditiontoMDI,Breiman[2001,2002]alsoproposedtoevaluatetheimportanceofavariableXjbymeasuringtheMeanDecreaseAccu-racy(MDA)or,equivalently,bymeasuringtheMeanIncreaseError,oftheforestwhenthevaluesofXjarerandomlypermutedintheout-of-bagsamples.Forthatreason,thislattermeasureisalsoknownasthepermutationimportance.Formally,inregression,thepermutationimportanceofXjisgivenas:Imp(Xj)=Eπj(cid:14)1NX(x0i,yi)∈πj(L)L(1M−iM−iXl=1ϕLmkl(x0i),yi)(cid:15),→−1NX(xi,yi)∈LL(1M−iM−iXl=1ϕLmkl(xi),yi)(6.3)whereπj(L)denotesareplicateofLinwhichinthevaluesofXjhavebeenrandomlypermuted,andwheremk1,...,mkM−idenotethein-dicesofthetreesthathavebeenbuiltfrombootstrapreplicatesthatdonotinclude(xi,yi).Forclassiﬁcation,thepermutationimportanceisderivedsimilarlyasinEquation6.3,exceptthattheout-of-bagav-eragepredictionsarereplacedwiththeclasswhichisthemostlikely,ascomputedfromtheout-of-bagclassprobabilityestimates.Itsratio-naleisthatrandomlypermutingtheinputvariableXjshouldbreakitsassociationwiththeresponseY.Therefore,ifXjisinfactasso-ciatedtoY,permutingitsvaluesshouldalsoresultinasubstantialincreaseoferror,asheremeasuredbythedifferencebetweentheout-of-bagestimatesofthegeneralizationerror.Thatis,thelargertheincreaseoferror,themoreimportantthevariable,andvice-versa.Thankstopopularmachinelearningsoftwares[Breiman,2002;LiawandWiener,2002;Pedregosaetal.,2011],bothofthesevariableim-portancemeasureshaveshowntheirpracticalutilityinanincreasingnumberofexperimentalstudies.Littleisknownhoweverregardingtheirinnerworkings.Strobletal.[2007b]comparebothMDIandMDAandshowexperimentallythattheformerisbiasedtowardssomepredictorvariables.AsexplainedbyWhiteandLiu[1994]incaseofsingledecisiontrees,thisbiasstemsfromanunfairadvan-tagegivenbytheusualimpurityfunctionsi(t)towardspredictorswithalargenumberofvalues(seeSection7.2.2).Strobletal.[2008]latershowedthatMDAisbiasedaswell,andthatitoverestimatestheimportanceofcorrelatedvariables–althoughthiseffectwasnotcon-ﬁrmedinalaterexperimentalstudybyGenueretal.[2010].Fromatheoreticalpointofview,Ishwaran[2007]providesadetailedtheoret-icaldevelopmentofasimpliﬁedversionofMDA,givingkeyinsightsfortheunderstandingoftheactualMDA.126understandingvariableimportances6.2theoreticalstudy6.2.1BackgroundTobeself-contained,weﬁrstrecallseveraldeﬁnitionsfrominforma-tiontheory(see[CoverandThomas,2012],forfurtherproperties).Wesupposethatwearegivenaprobabilityspace(Ω,E,P)andcon-siderrandomvariablesdeﬁnedonittakingaﬁnitenumberofpossi-blevalues.Weuseuppercaseletterstodenotesuchrandomvariables(e.g.X,Y,Z,W...)andcalligraphicletters(e.g.X,Y,Z,W...)tode-notetheirimagesets(ofﬁnitecardinality),andlowercaseletters(e.g.x,y,z,w...)todenoteoneoftheirpossiblevalues.Fora(ﬁnite)setof(ﬁnite)randomvariablesX={X1,...,Xp},wedenotebyPX(x)=PX(x1,...,xp)theprobabilityP({ω∈Ω|∀j:1,...,p:Xj(ω)=xj}),andbyX=X1×···×Xpthesetofjointconﬁgurationsoftheseran-domvariables.Giventwosetsofrandomvariables,X={X1,...,Xp}andY={Y1,...,Yq},wedenotebyPX|Y(x|y)=PX,Y(x,y)/PY(y)theconditionaldensityofXwithrespecttoY.1Withthesenotations,thejoint(Shannon)entropyofasetofrandomvariablesX={X1,...,Xp}isthusdeﬁnedbyH(X)=−Xx∈XPX(x)log2PX(x),(6.4)whilethemeanconditionalentropyofasetofrandomvariablesX={X1,...,Xp},giventhevaluesofanothersetofrandomvariablesY={Y1,...,Yq}isdeﬁnedbyH(X|Y)=−Xx∈XXy∈YPX,Y(x,y)log2PX|Y(x|y).(6.5)ThemutualinformationamongthesetofrandomvariablesX={X1,...,Xp}andthesetofrandomvariablesY={Y1,...,Yq}isde-ﬁnedbyI(X;Y)=−Xx∈XXy∈YPX,Y(x,y)log2PX(x)PY(y)PX,Y(x,y)(6.6)=H(X)−H(X|Y)=H(Y)−H(Y|X)Themeanconditionalmutualinformationamongthesetofran-domvariablesX={X1,...,Xp}andthesetofrandomvariablesY={Y1,...,Yq},giventhevaluesofathirdsetofrandomvariablesZ={Z1,...,Zr},isdeﬁnedbyI(X;Y|Z)=H(X|Z)−H(X|Y,Z)(6.7)1Toavoidproblems,wesupposethatallprobabilitiesarestrictlypositive,withoutfundamentallimitation.6.2theoreticalstudy127=H(Y|Z)−H(Y|X,Z)=−Xx∈XXy∈YXz∈ZPX,Y,Z(x,y,z)log2PX|Z(x|z)PY|Z(y|z)PX,Y|Z(x,y|z)WealsorecallthechainingruleI(X,Z;Y|W)=I(X;Y|W)+I(Z;Y|W,X),(6.8)andthesymmetryofthe(conditional)mutualinformationamongsetsofrandomvariablesI(X;Y|Z)=I(Y;X|Z).(6.9)6.2.2AsymptoticanalysisLetusnowconsidertheMDIimportanceasdeﬁnedbyEquation6.2,andletusassumeasetV={X1,...,Xp}ofcategoricalinputvariablesandacategoricaloutputY.ForthesakeofsimplicitywewillusetheShannonentropyasimpuritymeasure,andfocusontotallyrandom-izedtrees;lateronwewilldiscussotherimpuritymeasuresandtreeconstructionalgorithms.GivenatrainingsampleLofNjointobservationsofX1,...,Xp,YindependentlydrawnfromthejointdistributionP(X1,...,Xp,Y),letusassumethatweinferfromitaninﬁnitelylargeensembleoftotallyrandomizedandfullydevelopedtrees.Deﬁnition6.1.AtotallyrandomizedandfullydevelopedtreeisadecisiontreeinwhicheachnodetispartitionedusingavariableXjpickeduniformlyatrandomamongthosenotyetusedattheparentnodesoft,whereeachnodetissplitinto|Xj|sub-trees,i.e.,oneforeachpossiblevalueofXj,andwheretherecursiveconstructionprocesshaltsonlywhenallpvariableshavebeenusedalongthecurrentbranch.Insuchatree,leavesareallatthesamedepthp,andthesetofleavesofafullydevelopedtreeisinbijectionwiththesetXofallpossiblejointconﬁgurationsofthepinputvariables.Forexample,iftheinputvariablesareallbinary,theresultingtreewillhaveexactly2pleaves.Asaresult,totallyrandomizedtrees,asconsideredhere,areinfactclosertotreesgrownwithID3[Quinlan,1986]thantreesbuiltfromtheCARTprocedure(asdescribedthroughoutChapters3and4).Theorem6.1.TheMDIimportanceofXj∈VforYascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesandaninﬁnitelylargetrainingsampleis:Imp(Xj)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B),(6.10)128understandingvariableimportanceswhereV−jdenotesthesubsetV\{Xj},Pk(V−j)isthesetofsubsetsofV−jofcardinalityk,andI(Xj;Y|B)istheconditionalmutualinfor-mationofXjandYgiventhevariablesinB.Proof.Byexpanding∆i(s,t)=i(t)−pLi(tL)−pRi(tR)intoEqua-tion6.2andusingtheentropyH(Y|t)=−Pjp(j|t)log2(p(j|t))asimpuritymeasurei(t),Equation6.2canberewrittenintermsofmu-tualinformation:Imp(Xj)=1MMXm=1Xt∈ϕm1(jt=j)p(t)I(Y;Xj|t)(6.11)AsthesizeNofthetrainingsamplegrowstoinﬁnity,p(t)be-comesthe(exact)probability(accordingtoP(X1,...,Xp,Y))thatanobjectreachesnodet,i.e.,aprobabilityP(B(t)=b(t))whereB(t)=(Xi1,...,Xik)isthesubsetofkvariablestestedinthebranchfromtherootnodetotheparentoftandb(t)isthevectorofvaluesofthesevariables.AsthethenumberMoftotallyrandomizedtreesalsogrowstoinﬁnity,theimportanceofavariableXjcanthenbewritten:Imp(Xj)=XB⊆V−jXb∈Xi1×...×Xikα(B,b,Xj,p)P(B=b)I(Y;Xj|B=b),(6.12)wherebisasetofvaluesforthevariablesinBandα(B,b,Xj,p)istheprobabilitythatanodet(atdepthk)inatotallyrandomizedtreeteststhevariableXjandissuchthatB(t)=Bandb(t)=b.Letuscomputeα(B,b,Xj,p).First,letusconsidertheprobabilitythatanodetteststhevariableXjandissuchthatthebranchleadingtotfollowsapathdeﬁned,inthatparticularorder,byallkvariablesXi1,...,Xik∈Bandtheircorrespondingvaluesinb.Theprobabilityofthatbranchistheprobabilityofpicking(uniformlyatrandom)Xi1attherootnodetimestheprobabilityoftesting,inthatorder,theremainingXi2,...,Xikvariablesinthesub-treecorrespondingtothevaluexi1ofXi1deﬁnedinb.Notethat,byconstruction,itiscertainthatthisparticularsub-treeexistssincetherootnodeissplitinto|Xi1|sub-trees.Then,theprobabilityoftestingXjattheendofthisbranchistheprobabilityofpickingXjamongtheremainingp−kvariables.Byrecursion,wethushave:1p1p−1...1p−k+11p−k=(p−k)!p!1p−k(6.13)Sincetheorderalongwhichthevariablesappearinthebranchisofnoimportance,α(B,b,Xj,p)actuallyincludesallk!equiprobablewaysofbuildingabranchcomposedofthevariablesandvaluesinBandb.Then,sinceatreemayatmostcontainasinglesuchbranch,6.2theoreticalstudy129whatevertheorderofthetests,theprobabilitiesmaybeaddedupanditcomes:α(B,b,Xj,p)=k!(p−k)!p!1p−k=1Ckp1p−k(6.14)Fromtheaboveexpression,itappearsthatα(B,b,Xj,p)dependsonlyonthesizekofBandonthenumberpofvariables.Assuch,bygroupinginthepreviousequationofImp(Xj)conditioningvariablesubsetsBaccordingtotheirsizesandusingthedeﬁnitionofcondi-tionalmutualinformation,αcanbefactoredout,henceleadingtotheformforetoldbyTheorem6.1:Imp(Xj)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B).(6.15)Theorem6.2.Foranyensembleoffullydevelopedtreesinasymptoticlearn-ingsamplesizeconditions(e.g.,inthesameconditionsasthoseofTheo-rem6.1),wehavethatpXj=1Imp(Xj)=I(X1,...,Xp;Y).(6.16)Proof.Foranytreeϕ,wehavethatthesumofallimportanceses-timatedbyusinganinﬁnitelylargesampleL(orequivalently,byassumingperfectknowledgeofthejointdistributionP(X1,...,Xp,Y))isequaltoH(Y)−Pt∈eϕp(t)H(Y|b(t)),whereeϕdenotesthesetofallleavesofϕ,andwhereb(t)denotesthejointconﬁgurationofallinputvariablesleadingtoleaft.Thisistruebecausetheimpuritiesofalltestnodesinterveninginthecomputationofthevariableimpor-tances,excepttheimpurityH(Y)attherootnodeofthetree,canceleachotherwhensumminguptheimportances.Since,whenthetreeisfullydeveloped,Pt∈eϕp(t)H(Y|b(t))isob-viouslyequaltothemeanconditionalentropyH(Y|X1,...,Xp)ofYgivenallinputvariables,thisimpliesthatforanyfullydevelopedtreewehavethatthesumofvariableimportancesisequaltoI(X1,...,Xp;Y),andsothisrelationalsoholdswhenaveragingoveraninﬁniteensem-bleoftotallyrandomizedtrees.Notethat,forthesamereasonsasintheproofofTheorem6.1,thisresultholdsinasymptoticconditionsonly,i.e.,whenp(t)becomestheexactprobabilityP(B(t)=b(t)).Together,theorems6.1and6.2showthatvariableimportancesde-rivedfromtotallyrandomizedtreesinasymptoticconditionsprovideathree-leveldecompositionoftheinformationI(X1,...,Xp;Y)con-tainedinthesetofinputvariablesabouttheoutputvariable.Theﬁrstlevelisadecompositionamonginputvariables(seeEquation6.16of130understandingvariableimportancesTheorem6.2),thesecondlevelisadecompositionalongthedegreeskofinteractiontermsofavariablewiththeotherones(seetheoutersuminEquation6.10ofTheorem6.1),andthethirdlevelisadecom-positionalongthecombinationsBofinteractiontermsofﬁxedsizekofpossibleinteractingvariables(seetheinnersuminEquation6.10).Weobservethatthedecompositionincludes,foreachvariable,eachandeveryinteractiontermofeachandeverydegreeweightedinafashionresultingonlyfromthecombinatoricsofpossibleinteractionterms.Inparticular,sinceallI(Xj;Y|B)termsareatmostequaltoH(Y),thepriorentropyofY,theptermsoftheoutersumofEqua-tion6.10areeachupperboundedby1Ckp1p−kXB∈Pk(V−j)H(Y)=1Ckp1p−kCkp−1H(Y)=1pH(Y).(6.17)Assuch,thesecondleveldecompositionresultingfromtotallyran-domizedtreesmakesthepsub-importanceterms1Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)(6.18)toequallycontribute(atmost)tothetotalimportance,eventhoughtheyeachincludeacombinatoriallydifferentnumberofterms.6.3relevanceofvariablesFollowingKohaviandJohn[1997],letusdeﬁnerelevantandirrele-vantvariableasfollows:Deﬁnition6.2.AvariableXjisrelevanttoYwithrespecttoVifthereexistsatleastonesubsetB⊆V(possiblyempty)suchthatI(Xj;Y|B)>0.Deﬁnition6.3.AvariableXiisirrelevanttoYwithrespecttoVif,forallB⊆V,I(Xi;Y|B)=0.RemarkthatifXiisirrelevanttoYwithrespecttoV,thenbydeﬁ-nitionitisalsoirrelevanttoYwithrespecttoanysubsetofV.How-ever,ifXjisrelevanttoYwithrespecttoV,thenitisnotnecessarilyrelevanttoYwithrespecttoallsubsetsofV.Amongtherelevantvariables,wealsodistinguishthemarginallyrelevantones,forwhichI(Xj;Y)>0,thestronglyrelevantones,forwhichI(Xj;Y|V−j)>0,andtheweaklyrelevantvariables,whicharerelevantbutnotstronglyrelevant.Theorem6.3.Xi∈VisirrelevanttoYwithrespecttoVifandonlyifitsinﬁnitesamplesizeimportanceascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonVforYis0.6.3relevanceofvariables131Proof.Theproofdirectlyresultsfromthedeﬁnitionofirrelevance.IfXiisirrelevantwithrespecttoV,thenI(Xi;Y|B)iszeroforallB⊆V−i⊂VandEquation6.10reducesto0.Also,sinceI(Xi;Y|B)isnon-negativeforanyB,Imp(Xi)iszeroifandonlyifallitsI(Xi;Y|B)termsarezero.SinceImp(Xi)includesallI(Xi;Y|B)termsforB⊆V−i,andsinceallofthemarethereforenullifImp(Xi)=0,Xiisthus,bydeﬁnition,irrelevantwithrespecttoV−i.XiisthenalsotriviallyirrelevantwithrespecttoV=V−i∪{Xi}sinceI(Xi;Y|B∪{Xi})=0foranyB.Lemma6.4.LetXi/∈VbeanirrelevantvariableforYwithrespecttoV.TheinﬁnitesamplesizeimportanceofXj∈VascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonVforYisthesameastheimportancederivedwhenusingV∪{Xi}tobuildtheensembleoftreesforY.Proof.LetXi/∈VbeanirrelevantvariablewithrespecttoV.ForXj∈V,B⊆V−j,usingthechainrulesofmutualinformation,wehave:I(Xj,Xi;Y|B)=I(Xj;Y|B)+I(Xi;Y|B∪{Xj})(6.19)=I(Xi;Y|B)+I(Xj;Y|B∪{Xi})(6.20)IfXiisirrelevantwithrespecttoV,i.e.,suchthatI(Xi;Y|B)=0forallB⊆V,thenI(Xi;Y|B∪{Xj})andI(Xi;Y|B)bothequal0,leadingtoI(Xj;Y|B∪{Xi})=I(Xj;Y|B)(6.21)Then,fromTheorem6.1,theimportanceofXjascomputedwithaninﬁniteensembleoftotallyrandomizedtreesbuiltonV∪{Xi}canbesimpliﬁedto:Imp(Xj)=p−1+1Xk=01Ckp+11p+1−kXB∈Pk(V−j∪{Xi})I(Xj;Y|B)=pXk=01Ckp+11p+1−kXB∈Pk(V−j)I(Xj;Y|B)+XB∈Pk−1(V−j)I(Xj;Y|B∪{Xi})=p−1Xk=01Ckp+11p+1−kXB∈Pk(V−j)I(Xj;Y|B)+,→pXk=11Ckp+11p+1−kXB∈Pk−1(V−j)I(Xj;Y|B)=p−1Xk=01Ckp+11p+1−kXB∈Pk(V−j)I(Xj;Y|B)+,→p−1Xk0=01Ck0+1p+11p+1−k0−1XB∈Pk0(V−j)I(Xj;Y|B)132understandingvariableimportances=p−1Xk=0"1Ckp+11p+1−k+1Ck+1p+11p−k#XB∈Pk(V−j)I(Xj;Y|B)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)(6.22)ThelastlineaboveexactlycorrespondstotheimportanceofXjascomputedwithaninﬁniteensembleoftotallyrandomizedtreesbuiltonV,whichprovesLemma6.4.Theorem6.5.LetVR⊆VbethesubsetofallvariablesinVthatarerelevanttoYwithrespecttoV.TheinﬁnitesamplesizeimportanceofanyvariableXj∈VRascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonVRforYisthesameasitsimportancecomputedinthesameconditionsbyusingallvariablesinV.Thatis:Imp(Xj)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)=r−1Xl=01Clr1r−lXB∈Pl(V−jR)I(Xj;Y|B)(6.23)whereristhenumberofrelevantvariablesinVR.Proof.LetusassumethatVRcontainsr6prelevantvariables.Ifaninﬁniteensembleoftotallyrandomizedtreesweretobebuiltdirectlyonthoservariablesthen,fromTheorem6.1,theimportanceofarel-evantvariableXjwouldbe:Imp(Xj)=r−1Xl=01Clr1r−lXB∈Pl(V−mR)I(Xj;Y|B)(6.24)LetXi∈V\VRbeoneofthep−rirrelevantvariablesinVwithrespecttoV.SinceXiisalsoirrelevantwithrespecttoVR,usingLemma6.4,theimportanceofXjwhentheensembleisbuiltonVR∪{Xi}isthesameastheonecomputedonVRonly(i.e.,ascomputedbytheequationabove).Usingthesameargument,addingasecondirrelevantvariableXi0withrespecttoV–andthereforealsowithrespecttoVR∪{Xi}–andbuildinganensembleoftotallyrandomizedtreesonVR∪{Xi}∪{Xi0}willyieldimportancesthatarethesameasthosecomputedonVR∪{Xi},whicharethemselvesthesameasthosecomputedbyanensemblebuiltonVR.Byinduction,addingallp−rirrelevantvariableshasthereforenoeffectontheimportanceofXj,whichmeansthat:Imp(Xj)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)6.4variableimportancesinrandomforestvariants133=r−1Xl=01Clr1r−lXB∈Pl(V−mR)I(Xj;Y|B)(6.25)Theorems6.3and6.5showthattheimportancescomputedwithanensembleoftotallyrandomizedtreesdependsonlyontherelevantvariables.Irrelevantvariableshaveazeroimportanceanddonotaf-fecttheimportanceofrelevantvariables.Practically,webelievethatsuchpropertiesaredesirableconditionsforasoundcriterionassess-ingtheimportanceofavariable.Indeed,noiseshouldnotbecreditedofanyimportanceandshouldnotmakeanyothervariablemore(orless)important.Intuitively,theindependencewithrespecttoirrelevantvariablescanbepartlyattributedtothefactthatsplittingattonsomeirrel-evantvariableXishouldonlydillutethelocalimportancep(t)∆i(t)ofarelevantvariableXjintothechildrentLandtR,butnotaffectthetotalsum.Forinstance,ifXjwastobeusedatt,thenthelocalimportancewouldbeproportionaltop(t).Bycontrast,ifXiwastobeusedattandXjattLandtR,thenthesumofthelocalimpor-tancesforXjwouldbeproportionaltop(tL)+p(tR)=p(t),whichdoesnotchangeanything.Similarly,onecanrecursivelyinvokethesameargumentifXjwastobeuseddeeperintLortR.AsecondreasoncomesfromthefactthatlocalimportancesarecollectedonlyinnodestwhereXjisused.Bycontrast,iflocalimpor-tancesweresummedoverallnodes(e.g.,usingsurrogatesplits),thenitwouldnecessarilydependonthetotalnumberofnodesinatree,whichitselfdirectlydependsonp–thatis,notonr.Finally,itisalsoworthnotingthatthisresultisconsistentwiththeworkofBiau[2012],whoprovedthatrateofconvergenceofforestsofrandomizedtreesalsoonlydependsontherelevantvariables.6.4variableimportancesinrandomforestvariantsInthissection,weconsideranddiscussvariableimportancesascom-putedwithothertypesofensemblesofrandomizedtrees.Weﬁrstshowhowourresultsextendtoanyotherimpuritymeasure,andthenanalyzeimportancescomputedbydepth-prunedensembleofrandomizedtreesandthosecomputedbyrandomizedtreesbuiltonrandomsubspacesofﬁxedsize.Finally,wediscussthecaseofnon-totallyrandomizedtrees.6.4.1GeneralizationtootherimpuritymeasuresAlthoughourcharacterizationinsections6.1and6.3usesShannonentropyastheimpuritymeasure,theorems6.1,6.3and6.5holdfor134understandingvariableimportancesotherimpuritymeasures,simplysubstitutingconditionalmutualin-formationforconditionalimpurityreductioninthedifferentformu-lasandinthedeﬁnitionofirrelevantvariables.Inparticular,ourre-sultsthusholdfortheGiniindexinclassiﬁcationandcanbeextendedtoregressionproblemsusingvarianceastheimpuritymeasure.Letusconsideragenericimpuritymeasurei(Y|t)and,bymim-ickingthenotationusedforconditionalmutualinformation,letusdenotebyG(Y;Xj|t)theimpuritydecreaseforasplitonXjatnodet:G(Y;Xj|t)=i(Y|t)−Xx∈Xjp(tx)i(Y|tx),(6.26)wheretxdenotesthesuccessornodeoftcorrespondingtovaluexofXj.TheimportancescoreassociatedtoavariableXj(seeEquation6.2)isthenrewritten:Imp(Xj)=1MMXm=1Xt∈ϕm1(jt=j)p(t)G(Y;Xj|t).(6.27)AsexplainedintheproofofTheorem6.1,conditioningoveranodetisequivalenttoconditioningoveraneventoftheformB(t)=b(t),whereB(t)andb(t)denoterespectivelythesetofvariablestestedinthebranchfromtheroottotandtheirvaluesinthisbranch.WhenthelearningsamplesizeNgrowstoinﬁnity,thisyieldsthefollowingpopulationbasedimpuritydecreaseatnodet:G(Y;Xj|B(t)=b(t))(6.28)=i(Y|B(t)=b(t))−Xx∈XjP(Xj=x|B(t)=b(t))i(Y|B(t)=b(t),Xj=x)Againbyanalogywithconditionalentropyandmutualinformation2,letusdeﬁnei(Y|B)andG(Y;Xj|B)forsomesubsetofvariablesB⊆Vasfollows:i(Y|B)=XbP(B=b)i(Y|B=b)(6.29)G(Y;Xj|B)=XbP(B=b)G(Y;Xj|B=b)(6.30)=i(Y|B)−i(Y|B,Xj)wherethesumsrunoverallpossiblecombinationsbofvaluesforthevariablesinB.Withthesenotations,theproofofTheorem6.1canbeeasilyadaptedtoleadtothefollowinggeneralizationofEquation6.10:Imp(Xj)=p−1Xk=01Ckp1p−kXB∈Pk(V−j)G(Y;Xj|B).(6.31)2NotehoweverthatG(Y;Xj|B)doesnotshareallpropertiesofconditionalmutualinformationasforexampleG(Xj;Y|B)mightnotbeequaltoG(Y;Xj|B)orevenbedeﬁned,dependingontheimpuritymeasureandthenatureoftheoutputY.6.4variableimportancesinrandomforestvariants135Notethatthisgeneralizationisvalidwithoutanyfurtherspeciﬁccon-straintsontheimpuritymeasurei(Y|t).LetusnowdeﬁneasirrelevanttoYwithrespecttoVavariableXiforwhich,forallB⊆V,G(Y;Xi|B)=0(i.e.avariablethatneitheraffectsimpuritywhatevertheconditioning).Fromthisdeﬁnition,onecandeducethefollowingpropertyofanirrelevantvariableXi(forallB⊆VandXj∈V):G(Y;Xj|B∪{Xi})=G(Y;Xj|B).Indeed,byasimpleapplicationofpreviousdeﬁnitions,wehave:G(Y;Xj|B)−G(Y;Xj|B∪{Xi})=i(Y|B)−i(Y|B∪{Xj})−i(Y|B∪{Xi})+i(Y|B∪{Xi,Xj})=i(Y|B)−i(Y|B∪{Xi})−i(Y|B∪{Xj})+i(Y|B∪{Xi,Xj})=G(Y;Xi|B)−G(Y;Xi|B∪{Xj})=0,(6.32)wherethelaststepisaconsequenceoftheirrelevanceofXi.Usingthisproperty,theproofsofLemma6.4andTheorem6.5canbestraightforwardlyadapted,showingthat,inthegeneralcasealso,theMDIimportanceofavariableisinvariantwithrespecttotheremovalortheadditionofirrelevantvariables.Giventhegeneraldeﬁnitionofirrelevance,allirrelevantvariablesalsogetzeroMDIimportancebut,withoutfurtherconstraintsontheimpuritymeasurei,thereisnoguaranteethatallrelevantvari-ables(deﬁnedasallvariablesthatarenotirrelevant)willgetanonzeroimportance.Thisproperty,andinconsequencetheorem6.3,willbehoweversatisﬁedassoonastheimpuritymeasureissuchthatG(Y;Xj|B)>0forallXj∈VandforallB⊆V.Previousdevelopmentsshowthatallresultspresentedinthischap-terremainvalidforanyimpuritymeasureleadingtononnegativeimpuritydecreases,providedthatthedeﬁnitionofvariableirrele-vanceisadaptedtothisimpuritymeasure.Thechoiceofaspeciﬁcimpuritymeasureshouldthusbeguidedbythemeaningonewantstoassociatetoirrelevance.MeasuringimpuritywithShannonentropy,i.e.,takingi(Y|t)=H(Y|t)andi(Y|B=b)=H(Y|B=b),onegetsbackallpreviousresults.Giventhepropertiesofconditionalmutualinformation,irrel-evanceforthisimpuritymeasurestrictlycoincideswithconditionalindependence:avariableXiisirrelevanttoYwithrespecttoVifandonlyifXi⊥Y|BforallB⊆V.AcommonalternativetoShannonentropyforgrowingclassiﬁca-tiontreesisGiniindex,which,intheﬁniteandinﬁnitesamplecases,iswritten:i(Y|t)=−Xjp(j|t)(1−p(j|t))(6.33)136understandingvariableimportancesi(Y|B=b)=−XjP(Y=j|B=b)(1−P(Y=j|B=b)).(6.34)LiketheShannonentropy,thismeasureleadstononnegativeim-puritydecreasesandthecorrespondingnotionofirrelevanceisalsodirectlyrelatedtoconditionalindependence.Themostcommonimpuritymeasureforregressionisvariance,which,intheﬁniteandinﬁnitesamplecases,iswritten:i(Y|t)=1NtXi∈t(yi−1NtXi∈tyi)2(6.35)i(Y|B=b)=EY|B=b{(Y−EY|B=b{Y})2}.(6.36)Variancecanonlydecreaseasaconsequenceofasplitandthere-fore,Theorem6.3isalsovalidforthisimpuritymeasure,meaningthatonlyirrelevantvariableswillgetazerovariancereduction.Notehoweverthatwiththisimpuritymeasure,irrelevanceisnotdirectlyrelatedtoconditionalindependence,assomevariableXicanbeirrel-evantinthesenseofourdeﬁnitionandstillaffectsthedistributionofoutputvalues.6.4.2PruningandrandomsubspacesInsections6.1and6.3,weconsideredtotallyrandomizedtreesthatwerefullydeveloped,i.e.untilallpvariableswereusedwithineachbranch.Whentotallyrandomizedtreesaredevelopedonlyuptosomesmallerdepthq6p,weshowinProposition6.6thatthevari-ableimportancesascomputedbythesetreesislimitedtotheqﬁrsttermsofEquation6.10.WethenshowinProposition6.7thattheselatterimportancesareactuallythesameaswheneachtreeoftheen-sembleisfullydevelopedoverarandomsubspace[Ho,1998]ofqvariablesdrawnpriortoitsconstruction.Proposition6.6.TheimportanceofXj∈VforYascomputedwithaninﬁniteensembleofprunedtotallyrandomizedtreesbuiltuptodepthq6pandaninﬁnitelylargetrainingsampleis:Imp(Xj)=q−1Xk=01Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)(6.37)Proof.TheproofofTheorem6.1canbedirectlyadaptedtoproveProposition6.6.Iftherecursiveprocedureisstoppedatdepthq,thenitmeansthatB(t)mayincludeuptoq−1variables,whichisstrictlyequivalenttosummingfromk=0toq−1intheoutersumofEqua-tion6.10.Proposition6.7.TheimportanceofXj∈VforYascomputedwithaninﬁniteensembleofprunedtotallyrandomizedtreesbuiltuptodepthq6p6.4variableimportancesinrandomforestvariants137andaninﬁnitelylargetrainingsampleisidenticaltotheimportanceascom-putedforYwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonrandomsubspacesofqvariablesdrawnfromV.Proof.LetusdeﬁnearandomsubspaceofsizeqasarandomsubsetVS⊆Vsuchthat|VS|=q.ByreplacingpwithqinEquation6.10(sinceeachtreeisbuiltonqvariables)andadjustingbytheprobabil-ityCq−k−1p−k−1CqpofhavingselectedXjandthekvariablesinthebranchwhendrawingVSpriortotheconstructionofthetree,itcomes:Imp(Xj)=q−1Xk=0Cq−k−1p−k−1Cqp1Ckq1q−kXB∈Pk(V−j)I(Xj;Y|B)(6.38)Themultiplicativefactorintheoutersumcanthenbesimpliﬁedasfollows:Cq−k−1p−k−1Cqp1Ckq1q−k=(p−k−1)!(p−k)!(q−k−1)!p!(p−q)!q!1Ckq1q−k=(p−k−1)!q!(q−k−1)!p!1Ckq1q−k=q(q−1)...(q−k)p(p−1)...(p−k)1Ckq1q−k=q(q−1)...(q−k)p(p−1)...(p−k)k!(q−k)!q!1q−k=1p(p−1)...(p−k)k!(q−k)!(q−k−1)!1q−k=k!p(p−1)...(p−k)=k!(p−k)!p!1p−k=1Ckp1p−k(6.39)whichyieldsthesameimportanceasinProposition6.6andprovestheproposition.Aslongasq>r(whererdenotesthenumberofrelevantvariablesinV),itcaneasilybeshownthatallrelevantvariableswillstillobtainastrictlypositiveimportance,whichwillhoweverdifferingeneralfromtheimportancescomputedbyfullygrowntotallyrandomizedtreesbuiltoverallvariables.Also,eachirrelevantvariableofcourse138understandingvariableimportanceskeepsanimportanceequaltozero,whichmeansthat,inasymptoticconditions,thesepruningandrandomsubspacemethodswouldstillallowusidentifytherelevantvariables,aslongaswehaveagoodupperboundqonr.6.4.3Non-totallyrandomizedtreesInouranalysisintheprevioussections,treesarebuilttotallyatran-domandhencedonotdirectlyrelatetothosebuiltinRandomFor-est[Breiman,2001]orinExtremelyRandomizedTrees[Geurtsetal.,2006a].Tobetterunderstandtheimportancesascomputedbythosealgorithms,letusconsideraclosevariantoftotallyrandomizedtrees:ateachnodet,letusinsteaddrawuniformlyatrandom16K6pvariablesandletuschoosetheonethatmaximizes∆i(t).Asprevi-ously,tissplitintoasmanysubtreesasthecardinalityofthecho-senvariable.Asymptotically,forbinaryvariables,thisvariantexactlymatchesRandomForestsandExtremelyRandomizedTrees.Forvari-ableswithalargercardinality,thecorrespondencenolongerexactlyholdsbutthetreesstillcloselyrelate.Noticethat,forK=1,thispro-cedureamountstobuildingensemblesoftotallyrandomizedtreesasdeﬁnedbefore,while,forK=p,itamountstobuildingclassicalsingletreesinadeterministicway.First,theimportanceofXj∈Vascomputedwithaninﬁniteensem-bleofsuchrandomizedtreesisnotthesameasEquation6.10.ForK>1,maskingeffectsindeedappear:att,somevariablesareneverselectedbecausetherealwaysissomeothervariableforwhich∆i(t)islarger.Sucheffectstendtopullthebestvariablesatthetopofthetreesandtopushtheothersattheleaves.Asaresult,theimportanceofavariablenolongerdecomposesintoasumincludingallI(Xj;Y|B)terms.Theimportanceofthebestvariablesdecomposesintoasumoftheirmutualinformationaloneorconditionedonlywiththebestothers–butnotconditionedwithallvariablessincetheynolongereverappearatthebottomoftrees.Bycontrast,theimportanceoftheleastpromisingvariablesnowdecomposesintoasumoftheirmutualinformationconditionedonlywithallvariables–butnotaloneorcon-ditionedwithacoupleofotherssincetheynolongereverappearatthetopoftrees.Inotherwords,becauseoftheguidedstructureofthetrees,theimportanceofXjnowtakesintoaccountonlysomeoftheconditioningsetsB,whichmayover-orunderestimateitsoverallrelevance.Tomakethingsclearer,letusconsiderasimpleexample.LetX1perfectlyexplainsYandletX2beaslightlynoisycopyofX1(i.e.,I(X1;Y)≈I(X2;Y),I(X1;Y|X2)=(cid:15)andI(X2;Y|X1)=0).Usingtotally6.5illustration139randomizedtrees,theimportancesofX1andX2arenearlyequal–theimportanceofX1beingslightlyhigherthantheimportanceofX2:Imp(X1)=12I(X1;Y)+12I(X1;Y|X2)=12I(X1;Y)+(cid:15)2(6.40)Imp(X2)=12I(X2;Y)+12I(X2;Y|X1)=12I(X2;Y)+0(6.41)Innon-totallyrandomizedtrees,forK=2,X1isalwaysselectedattherootnodeandX2isalwaysusedinitschildren.Also,sinceX1perfectlyexplainsY,allitschildrenarepureandthereductionofentropywhensplittingonX2isnull.Asaresult,ImpK=2(X1)=I(X1;Y)andImpK=2(X2)=I(X2;Y|X1)=0.Maskingeffectsarehereclearlyvisible:thetrueimportanceofX2ismaskedbyX1asifX2wereirrelevant,whileitisonlyabitlessinformativethanX1.Asadirectconsequenceoftheexampleabove,forK>1,itisnolongertruethatavariableisirrelevantifandonlyifitsimportanceiszero.Inthesameway,itcanalsobeshownthattheimportancesbecomedependentonthenumberofirrelevantvariables.Letusin-deedconsiderthefollowingcounter-example:letusaddinthepre-viousexampleanirrelevantvariableXiwithrespectto{X1,X2}andletuskeepK=2.TheprobabilityofselectingX2attherootnodenowbecomespositive,whichmeansthatImpK=2(X2)nowincludesI(X2;Y)>0andisthereforestrictlylargerthantheimportancecom-putedbefore.ForKﬁxed,addingirrelevantvariablesdampensmask-ingeffects,whichtherebymakesimportancesindirectlydependentonthenumberofirrelevantvariables.Inconclusion,theimportancesascomputedwithtotallyrandom-izedtreesexhibitpropertiesthatdonotpossess,byextension,neitherRandomForestsnorExtremelyRandomizedTrees.Withtotallyran-domizedtrees,theimportanceofXjonlydependsontherelevantvariablesandis0ifandonlyifXjisirrelevant.Aswehaveshown,itmaynolongerbethecaseforK>1.Asymptotically,theuseoftotallyrandomizedtreesforassessingtheimportanceofavariablemaythereforebemoreappropriate.Inaﬁnitesetting(i.e.,alimitednumberofsamplesandalimitednumberoftrees),guidingthechoiceofthesplittingvariablesremainshoweverasoundstrategy.Insuchacase,I(Xj;Y|B)cannotbemeasuredneitherforallXjnorforallB.Itisthereforepragmatictopromotethosethatlookthemostpromising,eveniftheresultingimportancesmaybebiased.6.5illustrationInthissection,weconsiderthedigitrecognitionproblemof[Breimanetal.,1984]forillustratingvariableimportancesascomputedwithtotallyrandomizedtrees.Weverifythattheymatchwithourtheo-reticaldevelopmentsandthattheydecomposeasforetold.Wealso140understandingvariableimportancesX1X2X3X4X5X6X7Figure6.1:7-segmentdisplaycomparetheseimportanceswiththosecomputedbyanensembleofnon-totallyrandomizedtrees,asdiscussedinsection6.4.3.Letusconsideraseven-segmentindicatordisplayingnumeralsus-inghorizontalandverticallightsinon-offcombinations,asillustratedinFigure6.1.LetYbearandomvariabletakingitsvaluein{0,1,...,9}withequalprobabilityandletX1,...,X7bebinaryvariableswhosevaluesareeachdeterminedunivocallygiventhecorrespondingvalueofYinTable6.1.SinceTable6.1perfectlydeﬁnesthedatadistribution,andgiventhesmalldimensionalityoftheproblem,itispracticabletodirectlyapplyEquation6.10tocomputevariableimportances.Toverifyourtheoreticaldevelopments,wethencompareinTable6.2variableim-portancesascomputedbyEquation6.10andthoseyieldedbyanen-sembleof10000totallyrandomizedtrees(K=1).Notethatgiventheknownstructureoftheproblem,buildingtreesonasampleofﬁnitesizethatperfectlyfollowsthedatadistributionamountstobuildingthemonasampleofinﬁnitesize.Atbest,treescanthusbebuiltona10-sampledataset,containingexactlyonesampleforeachoftheequiprobableoutcomesofY.Asthetableillustrates,theimportancesyieldedbytotallyrandomizedtreesmatchthosecomputedbyEqua-tion6.10,whichconﬁrmsTheorem6.1.Smalldifferencesstemfromthefactthataﬁnitenumberoftreeswerebuiltinoursimulations,butthosediscrepanciesshoulddisappearasthesizeoftheensemblegrowstowardsinﬁnity.ItalsoshowsthatimportancesindeedadduptoI(X1,...X7;Y),whichconﬁrmsTheorem6.2.Regardingtheac-tualimportances,theyindicatethatX5isstrongerthanallothers,followed–inthatorder–byX2,X4andX3whichalsoshowlargeimportances.X1,X7andX6appeartobethelessinformative.Theta-blealsoreportsimportancesforincreasingvaluesofK.Asdiscussedbefore,weseethatalargevalueofKyieldsimportancesthatcanbeeitheroverestimated(e.g.,atK=7,theimportancesofX2andX5arelargerthanatK=1)orunderestimatedduetomaskingeffects(e.g.,atK=7,theimportancesofX1,X3,X4andX6aresmallerthanatK=1,asiftheywerelessimportant).AsFigure6.2illustrates,itcanalsobeobservedthatmaskingeffectsmayeveninducechangesinthe6.5illustration141yx1x2x3x4x5x6x701110111100100102101110131011011401110105110101161101111710100108111111191111011Table6.1:ValuesofY,X1,...,X7variablerankings(e.g.,comparetherankingsatK=1andatK=7),whichthusconﬁrmsthatimportancesaredifferentlyaffected.Tobetterunderstandwhyavariableisimportant,itisalsoinsight-fultolookatitsdecompositionintoitspsub-importancesterms,asshowninFigure6.3.EachrowintheplotsoftheﬁgurecorrespondstoonethepvariablesX1,...,X7andeachcolumntoasizekofcon-ditioningsets.Assuch,thevalueatrowjandcolumnkcorrespondstheimportanceofXjwhenconditionedwithkothervariables(e.g.,totheterm1Ckp1p−kPB∈Pk(V−j)I(Xj;Y|B)inEquation6.10inthecaseoftotallyrandomizedtrees).Intheleftplot,forK=1,theﬁgureﬁrstillustrateshowimportancesyieldedbytotallyrandomizedtreesde-composesalongthedegreeskofinteractionsterms.Wecanobservethattheyeachequallycontribute(atmost)thetotalimportanceofavariable.TheplotalsoillustrateswhyX5isimportant:itisinforma-tiveeitheraloneorconditionedwithanycombinationoftheothervariables(allofitstermsaresigniﬁcantlylargerthan0).Bycontrast,italsoclearlyshowswhyX6isnotimportant:neitheralonenorcom-binedwithothersX6seemstobeveryinformative(allofitstermsarecloseto0).Moreinterestingly,thisﬁgurealsohighlightsredundan-cies:X7isinformativealoneorconditionedwithacoupleofothers(theﬁrsttermsaresigniﬁcantlylargerthan0),butbecomesuninfor-mativewhenconditionedwithmanyothers(thelasttermsarecloserto0).Therightplot,forK=7,illustratesthedecompositionofim-portanceswhenvariablesarechoseninadeterministicway.Theﬁrstthingtonoticeismaskingeffects.SomeoftheI(Xj;Y|B)termsareindeedclearlyneverencounteredandtheircontributionisthereforereducedto0inthetotalimportance.Forinstance,fork=0,thesub-importancesofX2andX5arepositive,whileallothersarenull,whichmeansthatonlythosetwovariablesareeverselectedattherootnode,hencemaskingtheothers.Asaconsequence,thisalsomeansthatthe142understandingvariableimportancesEqn.6.10K=1K=2K=3K=4K=5K=6K=7X10.4120.4140.3620.3270.3090.3040.3050.306X20.5810.5830.6630.7150.7570.7870.8010.799X30.5310.5320.5120.4960.4890.4830.4750.475X40.5420.5430.5250.4840.4450.4140.4090.412X50.6560.6580.7310.7780.8100.8270.8310.835X60.2250.2210.1400.1260.1220.1220.1210.120X70.3720.3680.3850.3920.3870.3820.3750.372P3.3213.3213.3213.3213.3213.3213.3213.321Table6.2:Variableimportancesascomputedwithanensembleofrandom-izedtrees,forincreasingvaluesofK.ImportancesatK=1fol-lowtheirtheoreticalvalues,aspredictedbyEquation6.10inThe-orem6.1.However,asKincreases,importancesdivergeduetomaskingeffects.InaccordancewithTheorem6.2,theirsumisalsoalwaysequaltoI(X1,...,X7;Y)=H(Y)=log2(10)=3.321sinceinputsallowtoperfectlypredicttheoutput.12345670.10.20.30.40.50.60.70.80.9X1X2X3X4X5X6X7Figure6.2:Variableimportancesascomputedwithanensembleofrandom-izedtrees,forincreasingvaluesofK.ImportancesatK=1followtheirtheoreticalvalues,aspredictedbyEquation6.10inTheo-rem6.1.However,asKincreases,importancesdivergeduetomaskingeffects.6.6conclusions1430123456X1X2X3X4X5X6X7K=10123456X1X2X3X4X5X6X7K=70.00.20.4Figure6.3:Decompositionofvariableimportancesalongthedegreeskofinteractionsofonevariablewiththeotherones.AtK=1,allI(Xj;Y|B)areaccountedforinthetotalimportance,whileatK=7onlysomeofthemaretakenintoaccountduetomask-ingeffects.importancesoftheremainingvariablesarebiasedandthattheyactu-allyonlyaccountoftheirrelevancewhenconditionedtoX2orX5,butnotoftheirrelevanceinothercontexts.Atk=0,maskingeffectsalsoamplifythecontributionofI(X2;Y)(resp.I(X5;Y))sinceX2(resp.X5)appearsmorefrequentlyattherootnodethanintotallyrandomizedtrees.Inaddition,becausenodesbecomepurebeforereachingdepthp,conditioningsetsofsizek>4areneveractuallyencountered,whichmeansthatwecannolongerknowwhethervariablesarestillinformativewhenconditionedtomanyothers.Allinall,thisﬁgurethusindeedconﬁrmsthatimportancesascomputedwithnon-totallyrandomizedtreestakeintoaccountonlysomeoftheconditioningsetsB,hencebiasingthemeasuredimportances.6.6conclusionsInthischapter,wemadeaﬁrststeptowardsunderstandingvari-ableimportancesascomputedwithaforestofrandomizedtrees.Inparticular,wederivedatheoreticalcharacterizationoftheMeanDecreaseImpurityimportancesascomputedbytotallyrandomizedtreesinasymptoticconditions.Weshowedthattheyofferathree-leveldecompositionoftheinformationjointlyprovidedbyallinputvariablesabouttheoutput(Section6.2).Wethendemonstrated(Sec-tion6.3)thatMDIimportancesascomputedbytotallyrandomizedtreesexhibitdesirablepropertiesforassessingtherelevanceofavari-able:itisequaltozeroifandonlyifthevariableisirrelevantanditdependsonlyontherelevantvariables.WediscussedthecaseofRandomForestsandExtremelyRandomizedTrees(Section6.4)andﬁnallyillustratedourdevelopmentsonanartiﬁcialbutinsightfulex-ample(Section6.5).144understandingvariableimportancesThereremainseverallimitationstoourframeworkthatwewouldlikeaddressinthefuture.First,ourresultsshouldbeadaptedtobi-narysplitsasusedwithinanactualRandomForest-likealgorithm.Inthissetting,anynodetissplitinonlytwosubsets,whichmeansthatanyvariablemaythenappearoneorseveraltimeswithinabranch,andthusshouldmakevariableimportancesnowdependentonthecardinalitiesoftheinputvariables.Inthesamedirection,ourframe-workshouldalsobeextendedtothecaseofcontinuousvariables.Fi-nally,resultspresentedinthisworkarevalidinanasymptoticsettingonly.Animportantdirectionoffutureworkincludesthecharacteri-zationofthedistributionofvariableimportancesinaﬁnitesetting.7FURTHERINSIGHTSFROMIMPORTANCESOutlineInthischapter,webuilduponresultsfromChapter6tofurtherstudyvariableimportancesascomputedfromrandomforests.InSec-tion7.1,weﬁrstexamineimportancesforvariablesthatareredun-dant.InSection7.2,werevisitvariableimportancesinthecontextofbinarydecisiontreesandorderedvariables.Inthisframework,wehighlightvarioussourcesofbiasthatmayconcurrentlyhappenwhenimportancesarecomputedfromactualrandomforests.Finally,wepresentinSection7.3somesuccessfulapplicationsofvariableimpor-tancemeasures.Caution.Theworkpresentedinthischapterisexploratory.Conclusionsshouldbeconsideredwithagrainofsalt,untilfurtherempiricalveriﬁcations.7.1redundantvariablesInmostmachinelearningproblems,itistypicalforinputvariablestobecorrelated,atleasttosomeextent,andtosharecommonbitsofinformation.Inimageclassiﬁcationforinstance,pixelsareusuallyhighlycorrelatedandindividuallyrepresentnearlythesameinfor-mationastheirneighbors.Inthatsense,variablesareoftenpartiallyredundant,i.e.,someofthevariablesmaysharesomeofthesameinfor-mationabouttheoutputvariableY.Intheextremecase,redundancyistotalorcomplete,withsomeofthevariablesredundantlyconveyingexactlythesameinformationwithrespecttotheoutputvariableY.Inthissection,westudyredundancyinrandomforestsandshowthatitmayhaveasigniﬁcanteffectonboththeaccuracyoftheensembleandvariableimportancemeasures.Asaguidingexampleforourdiscussion,letusconsiderasetofinputvariablesandletusdiscusstheeffectofaddingredundantvari-ablesonthestructureofrandomizedtrees.Intuitively,twovariablesXiandXjareredundantifonecanperfectlyexplainstheotherandvice-versa.Formally,wedeﬁneredundancyasfollows:Deﬁnition7.1.TwovariablesXi,XjaretotallyredundantifnoadditionalinformationisrequiredfordescribingXigivenXjandvice-versa.I.e.,ifH(Xi|Xj)=H(Xj|Xi)=0.(7.1)Inparticular,avariableXjanditscopy,denotedX0j,aretotallyre-dundant.Withrespecttorandomforests,addingcopiesofvariables145146furtherinsightsfromimportances(e.g.,duplicatingXj,henceresultinginanewsetofp+1inputvari-ables)hasnoeffectwhentheselectionofthesplitisdeterministic(e.g.,inRFforKsettothemaximumvalue).Nomatterthenumberoftotallyredundantvariables,thebestsplitthatisselectedisalwaysthesame,evenifthesamesplitsneedtoberecomputedmultipletimesduetoredundancy.Whenthechoiceofthebestsplitisstochastichow-ever(e.g.,forKstrictlysmallerthanthetotalnumberofvariables),addingmultiplecopiesofavariableXjresultsinsplitsthatmaybebiasedtowardsthisvariable(oroneofitscopies),whichinturnmayhaveasigniﬁcanteffectontheresultingaccuracyoftheensemble.ForaﬁxedvalueofK,itisindeednotdifﬁculttoseethataddingcopiesofXjincreasestheprobabilityofXj,orofoneofitscopies,tobeintherandomsubsetofKinputvariablesonwhichtolookforsplits.Asacorollary,itthereforealsosimultaneouslydecreasestheproba-bilityofanyoftheotherstobeselected,hencebiasingthestructureofthegenerateddecisiontrees.Notethattheresultingneteffectonaccuracydependsonthenatureofduplicatedvariable.IfXjisveryinformativewithrespecttotheinput,thenfavoringsplitsonXjbyaddingcopiesmayresultinanincreaseofaccuracy.Bycontrast,ifXjisirrelevant,thenaddingcopiesincreasestheriskofoverﬁtting.Withrespecttovariableimportances,theeffectofaddingredun-dantvariablescanbederivedbothqualitativelyandquantitativelyusingresultsfromChapter6.FromTheorem6.5,wealreadyknowthataddingirrelevantvariablesdoesnotchangetheresultingvari-ableimportances.Addingcopiesofarelevantvariablehowever,hasaneffectonboththeimportanceoftheduplicatedvariableandontheimportanceoftheremainingvariables.Asinthepreviouschapter,letusassumeasetV={X1,...,Xp}ofcategoricalinputvariablesandacategoricaloutputY,forwhichwederiveMDIimportances,ascom-putedfromtotallyrandomizedandfullydevelopedtreesbuiltonaninﬁnitelylargedataset.Lemma7.1.LetXiandXjbetotallyredundantvariables.Foranycondi-tioningsetB,I(Xi;Y|B,Xj)=I(Xj;Y|B,Xi)=0(7.2)I(Xi;Y|B)=I(Xj;Y|B).(7.3)Proof.Bysymmetryofthemutualinformation,itcomesI(Xi;Xj)=H(Xi)−H(Xi|Xj)=H(Xj)−H(Xj|Xi),(7.4)whichimpliesthatH(Xi)=H(Xj)sinceH(Xi|Xj)=H(Xj|Xi)=0ifXiandXjaretotallyredundant.Since06H(Xi|Xj,B)6H(Xi|Xj)andH(Xi|Xj)=0,wealsohaveH(Xi|Xj,B)=0foranycondition-ingsetB.Likewise,H(Xj|Xi,B)=0.ByreusingthesameargumentforI(Xi;Xj|B)(insteadofI(Xi;Xj)),equalitythereforeextendstoany7.1redundantvariables147conditioningsetB,givingH(Xi|B)=H(Xj|B).Fromthese,itfollowsthat,I(Xi;Y|B,Xj)=H(Xi|B,Xj)−H(Xi|B,Xj,Y)=0−0,(7.5)I(Xj;Y|B,Xi)=H(Xj|B,Xi)−H(Xj|B,Xi,Y)=0−0,(7.6)whichprovesEquation7.2.WealsohaveI(Xi;Y|B)=H(Xi|B)−H(Xi|B,Y)(7.7)=H(Xj|B)−H(Xj|B,Y)(7.8)=I(Xj;Y|B),(7.9)whichprovesEquation7.3.Proposition7.2.LetXj∈VbearelevantvariablewithrespecttoYandVandletX0j/∈VbeatotallyredundantvariablewithrespecttoXj.TheinﬁnitesamplesizeimportanceofXjascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonV∪{X0j}isImp(Xj)=p−1Xk=0p−kp+11Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B)(7.10)Proof.FromTheorem6.1,thevariableimportanceofXjisImp(Xj)=p−1+1Xk=01Ckp+11p+1−kXB∈Pk(V−j∪{X0j})I(Xj;Y|B)=p−1Xk=01Ckp+11p+1−kXB∈Pk(V−j)I(Xj;Y|B)=p−1Xk=0p−kp+11Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B),(7.11)sincefromLemma7.1,I(Xj;Y|B∪X0j)=0forallB∈P(V−j).Lemma7.3.LetXiandXjbetotallyredundantvariables.Foranycondi-tioningsetBandforanyvariableXl,I(Xl;Y|B,Xi)=I(Xl;Y|B,Xj)=I(Xl;Y|B,Xi,Xj)(7.12)Proof.Fromthechainingruleofthemutualinformation,wehaveI(Xi,Xj,Xl;Y|B)=I(Xl;Y|B)+I(Xi,Xj;Y|B,Xl)=I(Xl;Y|B)+I(Xi;Y|B,Xl)+I(Xi;Y|B,Xj,Xl)=I(Xl;Y|B)+I(Xi;Y|B,Xl)(Lemma7.1)=I(Xi,Xl;Y|B)=I(Xi;Y|B)+I(Xl;Y|B,Xi).(7.13)148furtherinsightsfromimportancesBysymmetry,I(Xi,Xj,Xl;Y|B)=I(Xj;Y|B)+I(Xl;Y|B,Xj),(7.14)whichprovesthatI(Xl;Y|B,Xi)=I(Xl;Y|B,Xj),bycombiningbothequationsandusingthefactthatI(Xi;Y|B)=I(Xj;Y|B)(Lemma7.1).Fromthechainingrule,wealsohaveI(Xi,Xj,Xl;Y|B)=I(Xi,Xj;Y|B)+I(Xl;Y|B,Xi,Xj)=I(Xi;Y|B)+I(Xj;Y|B,Xi)+I(Xl;Y|B,Xi,Xj)=I(Xi;Y|B)+I(Xl;Y|B,Xi,Xj).(7.15)BycombiningthislastequationwithEquation7.13,weﬁnallyhaveI(Xl;Y|B,Xi)=I(Xl;Y|B,Xi,Xj),whichprovesLemma7.3.Proposition7.4.LetXj∈VbearelevantvariablewithrespecttoYandVandletX0j/∈VbeatotallyredundantvariablewithrespecttoXj.TheinﬁnitesamplesizeimportanceofXl∈V−jascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonV∪{X0j}isImp(Xl)=p−2Xk=0p−kp+11Ckp1p−kXB∈Pk(V−l\Xj)I(Xl;Y|B)+(7.16),→p−2Xk=0"2Xk0=1Ck02Ck+k0p+11p+1−(k+k0)#XB∈Pk(V−l\Xj)I(Xl;Y|B∪Xj).Proof.FromLemma7.3,conditioningbyeitherXj,X0jorbybothvari-ablesyieldtermsI(Xl;Y|B,Xj),I(Xl;Y|B,X0j)andI(Xl;Y|B,Xj,X0j)thatareallequal.FromTheorem6.1,thevariableimportanceofXlcanthereforeberewrittenasfollows:Imp(Xl)=p−1+1Xk=01Ckp+11p+1−kXB∈Pk(V−l∪X0j)I(Xl;Y|B)=p−2Xk=02Xk0=01Ck+k0p+11p+1−(k+k0)XB∈Pk(V−l\Xj)B0∈Pk0({Xj,X0j})I(Xl;Y|B∪B0)=p−2Xk=01Ckp+11p+1−kXB∈Pk(V−l\Xj)I(Xl;Y|B)+,→p−2Xk=0"2Xk0=1Ck02Ck+k0p+11p+1−(k+k0)#XB∈Pk(V−l\Xj)I(Xl;Y|B∪Xj)=p−2Xk=0p−kp+11Ckp1p−kXB∈Pk(V−l\Xj)I(Xl;Y|B)+7.1redundantvariables149,→p−2Xk=0"2Xk0=1Ck02Ck+k0p+11p+1−(k+k0)#XB∈Pk(V−l\Xj)I(Xl;Y|B∪Xj).Proposition7.2showsthattheimportanceofXjdecreaseswhenaredundantvariableX0jisaddedtothesetofinputvariables,sinceallmutualinformationtermsaremultipliedbyafactorp−kp+1<1.In-tuitively,thisresultisinfactexpectedsincethesameinformationisthenconveyedwithintwovariables(i.e.,inXjanditscopyX0j).Italsoshowsthatthetermsinthetotalimportancearenotallmodiﬁedinthesameway.Theweightofthetermscorrespondingtosmallcondi-tioningsetsremainsnearlyunchanged(i.e.,foralargenumberpofvariablesandsmallvaluesofk,p−kp+1iscloseto1),whiletheweightofthetermsoflargeconditioningsetsisgreatlyimpacted(i.e.,forlargevaluesofk,p−kp+1tendsto0).AsshownbyProposition7.4,theeffectofaddingaredundantvari-ableX0jontheimportanceoftheothervariablesXl(forl6=j)istwofold.TheﬁrstpartofEquation7.16showsthattheweightofalltermsthatdonotincludeXj(oritscopy)strictlydecreasesbyafactorp−kp+1.ThesecondpartofEquation7.16showsthatthetheweightofalltermsthatincludeXj(oritscopy)increases,sinceseveralequivalentconditioningsets(i.e.,B∪{Xj},B∪{Xj}0andB∪{Xj,X0j})cannowap-pearwithinthebranchesofatree.LikeforProposition7.2,impuritytermsarenotallmodiﬁedinthesamewayandchangesdependonthesizekoftheconditioningsetB.Overall,theneteffectonthetotalimportanceofXlisthereforeacompromisebetweentheseopposingchanges.IftheweightedsumoftheI(Xl;Y|B,Xj)termsissmallwithrespecttothesumofthetermsthatdonotincludeXj(oritscopy),thenthedecreaseeffectdominatesandtheimportanceofXlshouldbesmaller.Bycontrast,iftheI(Xl;Y|B,Xj)termsarelarger,thentheincreaseeffectdominatesandtheresultingimportanceislarger.AsshownlaterinFigure7.2,redundantvariablesthereforeincreasetheimportanceofallvariablesthatinteractwiththeduplicatedvariable.Propositions7.2and7.4canbeextendedtothecasewhereNcredundantvariablesXcj(forc=1,...,Nc)areaddedtotheinputvariablesinsteadofone,leadingtothegeneralProposition7.5.Fromthisresult,thesamequalitativeconclusionscanbedrawn,exceptthatthedecreaseorincreaseeffectsdiscussedaboveareevenstrongerasmoreredundantvariablesareadded.Proposition7.5.LetXj∈VbearelevantvariablewithrespecttoYandVandletXcj/∈V(forc=1,...,Nc)beNctotallyredundantvariableswithrespecttoXj.TheinﬁnitesamplesizeimportancesofXjandXl∈V150furtherinsightsfromimportancesascomputedwithaninﬁniteensembleoffullydevelopedtotallyrandomizedtreesbuiltonV∪{X1j,...,XNcj}areImp(Xj)=p−1Xk=0"Ckp(p−k)Ckp+Nc(p+Nc−k)#1Ckp1p−kXB∈Pk(V−j)I(Xj;Y|B),Imp(Xl)=p−2Xk=0"Ckp(p−k)Ckp+Nc(p+Nc−k)#1Ckp1p−kXB∈Pk(V−l\Xj)I(Xl;Y|B)+,→p−2Xk=0"Nc+1Xk0=1Ck0Nc+1Ck+k0p+Nc1p+Nc−(k+k0)#XB∈Pk(V−l\Xj)I(Xl;Y|B∪Xj).Proof.Omittedhere,butProposition7.5canbeprovedbygeneraliz-ingforNctheproofsofPropositions7.2and7.4.Finally,letusnotethatPropositions7.2,7.4and7.5areinfactvalidassoonasvariablesXiandXjsatisfyconditionsofLemma7.1,eveniftheyarenottotallyredundant.Accordingly,wecalltwovariablessatisfyingtheseconditionstotallyredundantwithrespecttotheoutputY.Asanillustrativeexample,letusreconsidertheLEDclassiﬁcationproblemfromSection6.5,forwhichX5wasfoundtobethemostimportantvariable.AsshowninFigure7.1,addingvariablesthatareredundantwithX5makesitsimportancedecrease,aspredictedbyourtheoreticalresultfromPropositions7.2and7.5.When5ormorecopiesofX5areadded,theimportanceofX5isthesmallestofall,asifX5hadbecomelessinformative.Similarly,weobservethattheim-portanceoftheothervariablesremainsaboutthesameorslightlyde-creases,asiftheyallhadbecomeabitlessinformative.WithregardstoourpreviousresultsinPropositions7.4and7.5,thisindicatesthattheimportanceduetotheI(Xl;Y|B)termsprevailsfromtheimpor-tanceduetotheI(Xl;Y|B,Xc5)terms.Asamatteroffact,thisexamplehighlightsafundamentalpropertyofvariableimportancesascom-putedinarandomforest:importancemeasuresarecomputednotonlywithrespecttotheoutputY,butalsowithrespecttoalltheotherinputvariablesthatdeﬁnetheproblem.Inparticular,avariablewhichisnotimportantisnotnecessarilyuninformative,astheexampleillustrates.Avariablemaybeconsideredaslessimportantbecausetheinfor-mationitconveysisalsoredundantlyconveyedanddilutedinothervariables,andnotnecessarilybecauseithasnoinformationabouttheoutput.Asasecondexample,Figure7.2illustratesredundancyeffectsforaXORclassiﬁcationproblemdeﬁnedontwovariablesX1andX2.Again,theimportanceoftheduplicatedvariableX1decreasesasre-dundantvariablesareadded,whichconﬁrmsourresultsfromPropo-sitions7.2and7.5.Moreinterestingly,wenowobservethattheimpor-tanceoftheothervariable,X2,increasesascopiesofX1areadded.Forthisproblem,theI(X2;Y|B,Xc1)termsareprevalentwithrespectto7.1redundantvariables15102468100.00.10.20.30.40.50.60.7AddingcopiesofX5X1X2X3X4X5X6X7Figure7.1:AddingcopiesofX5ontheLEDclassiﬁcationtask.Themoreredundantvariablesareadded,thelessertheimportanceofX5.02468100.00.20.40.60.81.0AddingcopiesofX1X1X2Figure7.2:AddingcopiesofX1onaXORclassiﬁcationtask.Themorere-dundantvariablesareadded,thelessertheimportanceofX1,butthelargertheimportanceofX2.152furtherinsightsfromimportancestheI(X2;Y|B)terms(whichisinfactuniqueandequalto0),therebyartiﬁciallyincreasingtheoverallimportanceofX2asredundancyaug-ments,asexpectedfromPropositions7.4and7.5.Overall,resultspresentedinthissectioncallforcautionwheninter-pretingvariableimportancescores.Duetoredundancyeffects–eithertotal,asstudiedhere,orpartialasitwouldoftenariseinpractice–itmayhappenthatthetotalimportanceofagivenvariableiseithermisleadinglylowordeceptivelyhighbecausethesameinformationisspreadwithinseveralredundantvariablesandthereforetakenintoac-countseveraltimeswithinthetotalimportances.Assuch,weadvisetocomplementtheinterpretationwithasystematicdecompositionofvariableimportancescores,e.g.,aspreviouslydoneinFigure6.3,inordertobetterunderstandwhyavariableisinfactimportantandtopossiblydetectredundancy.7.2biasinvariableimportancesInthissection,westudysourcesofbiasinvariableimportancesandshowthatvariableselection(aspreviouslydiscussedinSection6.4.3)isnottheonlycauseofbias.Inpractice,complementaryforcesduetomaskingeffects,impuritymisestimationsandthestructureofthetreesmakevariableimportancesdeviatefromthetheoreticalresultsfoundinasymptoticconditionsfortotallyrandomizedtrees.7.2.1BiasduetomaskingeffectsAsshowninthepreviouschapters,theguidedselectionofthesplitvariable(i.e.,forK>1)isnecessaryforbalancingbiasandvarianceinrandomizeddecisiontreesandtoproduceaccurateensembles.Inparticular,westudiedthatdecisiontreesbuiltwithtoomuchran-domizationusuallyleadtoanincreaseofbias(withrespecttothegeneralizationerror)whichcannotbecompensatedbyareciprocaldecreaseofvariance,makingitnecessarytoadjustthevalueofKtoﬁndtheappropriatetrade-off.Bycontrast,wealsoshowedinSec-tion6.4.3thatwhenvariableselectionisnottotallyrandom(i.e.,assoonasK>1),maskingeffectsinduceabiaswithrespecttovari-ableimportances,sinceitforcessomeofthebranchestoneverbebuilt,andthereforesomeoftheconditioningsetsB∈P(V)toneverbetakenintoaccount.Asaconsequence,randomforestswhosepa-rameterKhasbeentunedtomaximizeaccuracymayyieldvariableimportancesthatarebiased(eitherover-orunderestimated).Morespeciﬁcally,itcanbeshown(seeSection6.4.3)thatarelevantvari-ablemaybenullwithregardstoitsimportance,therebymakingitindistinguishablefromirrelevantvariables,andthattheimportanceofrelevantvariablesbecomesdependentonthenumberofirrelevantvariables.7.2biasinvariableimportances153X1∼N(0,1)X2∼M(2)X3∼M(4)X4∼M(10)X5∼M(20)nullcaseY∼B(0.5)powercaseY|X2=0∼B(0.5−relevance)Y|X2=1∼B(0.5+relevance)Table7.1:Inputvariablesareindependentrandomvariablesasdeﬁnedfromthetable.N(0,1)isthestandardnormaldistribution.M(k)isthemultinomialdistributionwithvaluesin{0,...,k−1}andequalprobabilities.B(p)isthebinomialdistribution.Inthenullcase,YisindependentfromX1,...,X5.Inthepowercase,YdependsonthevalueX2whileotherinputvariablesremainirrelevant.7.2.2BiasduetoempiricalimpurityestimationsTheanalysisofvariableimportancescarriedoutsofarhasconsid-eredasymptoticconditionsforwhichthetruenodeimpurityi(t)isassumedtobeknown.Inpracticehowever,duetotheﬁnitesizeofthelearningset,impuritymeasurementssufferfromanempiricalmisestimationbias.Inthissection,westudythiseffectinthecon-textofheterogeneousvariables1,withrespecttotheirscaleortheirnumberofcategories,andshowthatthemisestimationofnodeim-purityisdirectlyproportionaltothecardinalityofthesplitvariableandinverselyproportionaltothenumberNtofsamplesusedfortheevaluation.Asaresult,impurityreductionsbecomeoverestimatedaswegodeeperinthetreeand/orasthenumberofvaluesofthevari-ableislarge.Inconsequence,variableimportancesalsosufferfrombias,makingvariablesofhighercardinalitywronglyappearasmoreimportant.Toguideourdiscussion,letusrevisitthesimulationstudiesfrom[Strobletal.,2007b]whichconsiderabinaryoutputvariableYandﬁveinputvariablesX1,...,X5,asdeﬁnedinTable7.1.LetusﬁrstanalyzethecasewhereYisindependentfromX1,...,X5,i.e.,suchthatnoneoftheinputvariablesareinformativewithrespecttotheoutput.ForarandomlysampleddatasetLofN=120samples,Figure7.3plotsvariableimportancesfordifferentkindsofrandomforests.TRTcorrespondstototallyrandomizedtrees,asdeﬁnedinSection6.2,RFcorrespondstostandardRandomForestwithboot-strapsamplingandETscorrespondstoExtremelyRandomizedTrees.1Asanexample,inthecaseofmeteorologicalproblems,variablesoftencomprisemixedenvironmentalmeasurementsofdifferentnatureandscale,likespeedofwind,temperature,humidity,pressure,rainfallorsolarradiation.154furtherinsightsfromimportancesX1X2X3X4X50.00.10.20.30.40.50.6TRTETsK=1ETsK=3ETsK=5RFK=1RFK=3RFK=5Figure7.3:VariableimportancesforYindependentofX1,...,X5.(N=120,M=500)BothRFandETsusebinarysplitswhileTRTrelyonmultiwayex-haustivesplits2.Inasymptoticconditions,weprovedinTheorem6.3thattheimportanceofirrelevantvariablesisstrictlyequalto0.ForaﬁnitevalueofNhowever,thisresultdoesnothold,asFigure7.3in-deedconﬁrms.Incontrastwithwhatwouldbeexpected,weobservethattheimportanceofnoneofthevariablesisinfactnowherecloseto0.InlightofTheorem6.2however,thisresultisnotthatsurprising:aslongasdecisiontreescanbefullydeveloped,thesumofvariableim-portancesisequaltothe(empiricallyestimated)mutualinformationbetweenX1,...,XpandtheoutputY,whichisitselfupperboundedbythe(empiricallyestimated)entropyH(Y)oftheoutputvariable.Inthiscase,H(Y)=log2(2)=1,whichindeedcorrespondstothesumofvariableimportancesforallmethodscomparedintheﬁgure.Moreimportantly,wealsoobservethatthelargerthecardinalityofthevariable(i.e.,thelargeritsnumberofuniquevalues),thelargeritsimportance.Forexample,theimportanceofX1(forwhichsam-plesallhaveuniquevalues)orofX5(whichcountsupto40uniquevalues)appearsnearly3timeslargerastheimportanceofX2(whichisbinary).Intheirstudy,Strobletal.[2007b]arguethatthisbiasisduetovari-ableselection:variableswithmorepotentialcut-pointsaremorelikelytoproduceagoodcriterionvaluebychance,asinamultipletestingsituation.Asaresult,variablesofhighercardinalityaremorelikelytobecho-senforsplittingthanthoseoflowercardinality.Whilethisbiashas2Therebycreatingasmanybranchesasthenumberofvaluesofthesplitvariable,evenifthisvariableiscontinuousandcountuniquevaluesonly.7.2biasinvariableimportances155beenknownforlongindecisiontrees[Kononenko,1995;KimandLoh,2001;Hothornetal.,2006],wearguethatitisnottheprimarycauseforthebiasobservedhere.Indeed,thisargumentdoesnotdi-rectlyexplainwhysimilartrendsarealsoobservedwhennovariableselectionisperformed(e.g.,forTRTorforK=1)norwhyitsimilarlyhappenswhencut-pointsarechosenatrandom,independentlyofthecardinalityofthevariable(e.g.,inETs).FormultiwaysplitslikeinTRT,biasinvariableimportancescanbetracedtothemisestimationsofthemutualinformationterms∆i(s,t)≈I(Xj;Y|t)(7.17)duetotheﬁnitesizeNtofthenodesamples.Asshownin[Goebeletal.,2005],whenXjandYareindependentrandomvariables(i.e.,whenXjisirrelevant),thedistributionofﬁnitesamplesizeestimatesoftheirmutualinformationfollowsapproximatelyagammadistribu-tionbI(Xj;Y)∼Γ(cid:16)12(|Xj|−1)(|Y|−1),1Ntlog2(cid:17)(7.18)whosemeanislinearlyproportionaltothecardinalities|Xj|and|Y|ofXjandYandinverselyproportionaltoNt,thatisE{bI(Xj;Y)}=(|Xj|−1)(|Y|−1)2Ntlog2.(7.19)Asaresult,estimatesgetlargerasXjcountsmanyuniquevalues,andbecomeevenlargerasnodesaredeepinthetree(sinceNtgetssmaller).Consequently,theweightedmeanofallsuchestimatedim-puritytermsI(Xj;Y|t),forallnodestwhereXjisthesplitvariable,andresultinginthetotalimportanceImp(Xj),isalsolinearlydepen-dentonthecardinalityofXj.ForTRT,thisresultexplainswhyvari-ablesofhighcardinalityinFigure7.3appearasmoreimportantthanthoseoflowercardinality.Intuitively,thecloserthenumberofuniquevalueswithrespecttothetotalnumberofsamples,thelargertheim-puritydecreasewhensplittingexhaustivelyonthisvariable.Intheextremecase,whenvaluesforXjareallunique,splittingonthevari-ableperfectlymemorizesthevaluesofY,resultinginchildnodesthatareallpure,thereforemaximizingtheestimatedmutualinformation.Assuch,thisexplainswhyX1,whosevaluesareallunique,appearsasthemostimportantvariable.Forbinarysplits(i.e.,forRFandETs)themutualinformationI(Xj;Y|t)isnotdirectlyestimatedateachnode.Rather,inthecaseoforderedvariables,∆i(s,t)correspondstoanestimateofthemutualinforma-tionI(Xj6v;Y|t)ofthebinarysplitXj6v.Underthesimplifyingassumptionthatbinarysplitsonthesamevariablearealldirectlyconsecutiveinthedecisiontree,itiseasytoseethatbinarytreesareequivalenttomultiwaytrees[Knuth,1968],asillustratedinFigure7.4.156furtherinsightsfromimportancesXj≤1Xj>1Xj≤0Xj>0Xj=0Xj=1Xj=2Figure7.4:Consecutivebinarysplitsonthesamevariableareequivalenttodirectmultiwaysplits.UsinganargumentsimilartotheproofofTheorem6.2,intermedi-ateimpuritytermsbetweentheﬁrstsplitandthelastofthosesplitscanceleachotherwhensumminguptheimportances,whichﬁnallyamountstocollectanactualestimateofI(Xj;Y|t)fromthesequenceofbinarysplits.Forthesamereasonsasbefore,variablesofhighcardinalityarethereforebiasedinthesameway.(AswewillstudyinSection7.2.3,thisconsecutivenessassumptiondoesnotholdinpractice,makingtheimportancesfrombinarydecisiontreesstrictlydifferentfromthoseofmultiwaydecisiontrees.Yet,thequalitativeconclusionsarestillvalidsincevariablesofhighcardinalitycanbereusedfarmoreoftenthanvariablesoflowcardinality,beforeallpos-siblesplitsareexhausted.)Inbothsituations,theoriginoftheproblemstemsfromthefactthatnodeimpurityismisestimatedwhenthesizeNtofthenodesamplesistoosmall.Toalargeextent,theissueisaggravatedbythefactthattreesarefullydevelopedbydefault,makingimpuritytermscollectedneartheleavesusuallyunreliable.Asaprecaution,asafeandeffectivesolutionforthebiasproblemthereforesimplyconsistsincollectingimpuritytermsonlyforthosenodeswheretheimpurityestimatescanbeconsideredasreliable.Equivalently,theconstruc-tionofthetreecanalsobestoppedearly,whenimpurityestimatesbecomeunreliable,e.g.,bylimitingthedepthofthetree,controllingfortheminimumnumberofsamplesininternalnodesorusinganyoftheotherstoppingcriteriadeﬁnedinSection3.5.Amongallalter-natives,conditionalinferencetrees[Hothornetal.,2006]andearliermethods[Quinlan,1986;Wehenkel,1998]makeuseofstatisticaltestsforassessingtheindependenceofXjandYatapre-speciﬁedlevelofconﬁdenceα.Ifthenullhypothesiscannotberejected,thenrecursivepartitioninghalts.Inparticular,variableimportancescollectedfromconditionalinferencetreeswereshownexperimentallybyStrobletal.[2007b]nottosufferfrombias.Theauthorsarguethatitisduetotheunbiasedvariableselectionmechanismsalsoimplementedincondi-tionalinferencetrees.Bycontrast,wearguethattheabsenceofbias7.2biasinvariableimportances157inimportancesfromsuchtreesismostlyduetotheearlystoppingcriterion,andnottovariableselection.Althoughvariableselectionplaysanimportantandexacerbatingrole,itisnotthetruecauseoftheobservedbias.Indeed,sincetheimpurityreductionofvari-ablesofhighcardinalityisoverestimated,searchingforasplitamongK>1randomlydrawnvariablesincreasestheirprobabilityofbe-ingselectedwhencomparedtoothersoflowercardinality,thereforemaskingandreducingtheimportancesoftheselattervariables.Yet,biasstemsfromthefactthatimpurityreductionsaremisestimatedintheﬁrstplace.Asanillustrativeexample,Figure7.5reconsidersthesimulationstudyofTable7.1,whenvaryingboththemaximumdepthofthetrees(frommax_depth=1to9)andtherelevanceofX2withrespecttoY.LetusﬁrstconsiderETsbuiltwithnovariableselection(K=1),asshowninfourtopplotsoftheﬁgure.Forthenullcase,whenrelevance=0,limitingthedepthofthetreescorrectlyﬁxesthebiasthatwasobservedbefore.Forshallowtrees,theimportancesbeforenormalizationofallﬁveinputvariablesarecloseto0,asexpectedfromirrelevantvariables.Thenormalizedimportances,asshownintheﬁgure,arealsoallcloseto1p=0.2,conﬁrmingthatnovariableisdetectedasmorerelevantthantheothers.However,whenthedepthofthedecisiontreesincreases,importancesdeviateandbiasproportionaltothecardinalityofthevariablesappearsasdiscussedbefore.WhenX2isarelevantvariable(i.e.,forrelevance>0),itsimportanceisexpectedtobestrictlypositiveandatleastaslargeastheimportancesoftheirrelevantvariables.Forrelevance=0.1andmax_depth=1,theimportanceofX2appearsnearly6timeslargerthantheimportancesoftheothervariables,conﬁrmingthatX2iscorrectlyidentiﬁedasarelevantvariable.Fordeepertreeshowever,noisedom-inatesandtheimportanceoftheirrelevantvariablesislargerduetomisestimationsoftheimpurityterms.Asrelevanceincreases,X2canmoreclearlybeidentiﬁedasarelevantvariable.Inparticular,themorerelevantX2,thatisthestrongerthesignal,thedeepertreescanbebuiltuntilX2ismadeunrecognizablefromtheirrelevantvariables.Bycomparison,thefourbottomplotsofFigure7.5illustratevari-ableimportancesforRFbuiltwithvariableselection(K=5).Again,weobservethatlimitingthedepthofthetreeshelpsreducethemis-estimationbias.However,thesupplementaryeffectduevariablese-lectionisalsoclearlyvisible:variablesoflargercardinalityappearassigniﬁcantlymoreimportantthantheothervariables.Consequently,thismakesthedetectionofX2asarelevantvariablemoredifﬁcultwhentreesaregrowndeeper.Whencomparingtherelativeimpor-tanceofX2foragivendepthandrelevance,weindeedobservethatX2consistentlyappearsaslessimportantinRFthaninETs.Itisonlyforveryshallowtrees(max_depth=1or2)andhighrelevancethatX2isidentiﬁedwithhigherconﬁdencethaninETs.158furtherinsightsfromimportancesETswithoutvariableselection1234567890.00.20.40.60.81.0Relevance=0.0X1X2X3X4X51234567890.00.20.40.60.81.0Relevance=0.11234567890.00.20.40.60.81.0Relevance=0.21234567890.00.20.40.60.81.0Relevance=0.3RFwithvariableselection1234567890.00.20.40.60.81.0Relevance=0.01234567890.00.20.40.60.81.0Relevance=0.11234567890.00.20.40.60.81.0Relevance=0.21234567890.00.20.40.60.81.0Relevance=0.3Figure7.5:VariableimportancesofX1,...,X5whenvaryingboththemax-imumdepthofthetreesandthedegreeofrelevanceofX2.Im-portancescoresarenormalizedbythesumofimportances.(Top)ETswithnovariableselection,K=1,N=120,M=500.(Bot-tom)RandomForestwithvariableselection,K=5,N=120,M=500.7.2biasinvariableimportances159Inconclusion,evaluatingimpurityonsmallsamplesleadtoover-estimationsofthemutualinformation,resultinginbiasedvariableimportances.Inparticular,thehigherthecardinalityofthevariable,thelargerthemisestimations.Tominimizethiseffect,cautionshouldbetakenbyonlyconsideringimpuritytermsthatwerecomputedfromalargeenoughsample.Thiscanbeguaranteed,e.g.,bystoppingtheconstructionofthetreeearlyormakingleavesgrowmoreslowlythanthesizeNofthelearningset.Additionally,wehavealsoshownthatvariableselectionmayincreasethebiasduetoover-estimations.Inthiscase,asimpleremedyconsistsinnotusingvariableselectionwhenassessingtherelevanceofvariables.Finally,letusalsonotetheconnectionwithPropositions6.6and6.7:aslongastreesarebuilttoamaximumdepthwhichislargerthanthenumberrofrelevantvari-ables,earlystoppingtheconstructionofthetreesdoesnotpreventusfromdetectingtherelevantvariables.7.2.3BiasduetobinarytreesandthresholdselectionPreviousdevelopmentsfromChapter6studiedvariableimportancesforfullydevelopedtotallyrandomizedtreesandmultiwayexhaus-tivesplits.Inpracticehowever,randomforestsusuallyrelyonbinarysplitsratherthanonmultiwaysplits.Intermsofimpurity,thisresultsinadditionalanddistinctinformationtermsthatwerenotpreviouslyaccountedfor,becausei)asamevariablecanbereusedseveraltimesalongthesamebranchandii)binarysplitsdiscretizetheinformationcontainedinavariable,makingvariableimportancesdependentonthesplitthresholdselectionstrategy.Inlackofarigoroustheoreticalframework,wegiveinthissectionpreliminaryinsightsonvariableimportancesforbinarydecisiontrees,hopefullysheddingsomelightontheirinterpretation.Asasimplisticbutillustrativeexample,letusconsideratoyclas-siﬁcationproblemcomposedofaternaryinputvariableX1andofabinaryinputvariableX2,bothofthembeingordered.Letusfur-therassumethatinputsamplesareuniformlydrawnfromTable7.2,whichdeﬁnestheoutputasY=X1<1andX2asacopyofY.WithrespecttoY,bothvariablesareasinformativeandonewouldexpecttheirimportancestobethesame.Withtotallyrandomizedtreesandexhaustivesplits,twoequiprobabledecisiontreescanbebuilt,asrep-resentedinFigure7.6.Inbothofthem,splittingeitheronX1oronX2attherootnoderesultsinchildnodesthatarepure,hencehaltingtheconstructionprocess.Asexpected,themeasuredvariableimpor-tancesarethesame:Imp(X1)=12I(X1;Y)=12H(Y)=0.459,Imp(X2)=12I(X2;Y)=12H(Y)=0.459.160furtherinsightsfromimportancesyx1x2000111121Table7.2:Toyproblem.All3possiblesamplesareequiprobable.X1=0X1=1X1=2X2=0X2=1Figure7.6:TotallyrandomizedtreesbuiltfromTable7.2.Bothdecisiontreesareequiprobable.TheresultingvariableimportancesindicatethatbothX1andX2areasimportant.X1≤1X1>1X1≤0X1>0X1≤1X1>1X2=0X2=1X1≤0X1>0X2=0X2=1Figure7.7:Extremelyrandomizedtrees(K=1)builtfromTable7.2.Fromlefttoright,toptobottom,decisiontreesarerespectivelygen-eratedwithprobability18,18,14and12.TheresultingvariableimportancesindicatethatX2isnowmoreimportantthanX1.7.2biasinvariableimportances161Bycontrast,usingbinarysplitsandETs(forK=1)resultsin4differentdecisiontrees,asrepresentedinFigure7.7.WhensplittingonX1attherootnode,twobinarysplitsarenowpossiblewithequalprobability:tL=X160,tR=X1>0ortL=X161,tR=X1>1.Intheformercase,theresultingchildnodesarepure,hencehaltingtheconstructionprocess.Inthelattercase,therightchild(correspondingtoX1>1)ispure,whiletheleftchildisnot.Forthisnode,recursivepartitioningproceedsandasecondbinarysplitcanbemadeeitheronX1oronX2.Overall,themeasuredvariableimportancesinthesebinarytrees,inasymptoticconditions,areImp(X1)=28I(X161;Y)+18P(X161)I(X160;Y|X161)+14I(X160;Y)=0.375Imp(X2)=12I(X2;Y)+18P(X161)I(X2;Y|X161)=0.541,whichmakesthemstrictlydifferentfromtheimportancescollectedfrommultiwaytotallyrandomizedtrees.Inparticular,duetothebi-narizationofthesplitvariables,importancesnowaccountforcondi-tioningsetsthatmayincludeseveralvaluesofasamevariable.Forinstance,theimportanceofX2includesI(X2;Y|X161),whichmea-suresthemutualinformationbetweenX2andYwhenX1iseitherequalto0or1.Withmultiwayexhaustivesplits,theseconditioningsetsarenotconsideredbecausebranchescorrespondtosinglevaluesonly.Similarly,importancesalsoaccountforbinarizedmutualinfor-mationtermssuchasI(X161;Y).Again,thesearenotevaluatedintotallyrandomizedtreesbecauseofthemultiwaysplits.Accordingly,thresholdselectioninbinarysplitshasadominanteffectonvariableimportancessinceitcontrolshowtheoriginalvari-ablesarebinarized.InETs,allintermediatethresholdsvarepossible,resultinginacombinatorialnumberofadditionalimpuritytermsI(Xj6v;Y|·)andI(·;Y|Xj6v,·).InRF,onlythebestthresholdisselectedlocallyateachnode,resultinginfeweradditionalimpuritytermsI(Xj<v∗;Y|·)andI(·;Y|Xj<v∗,·)(andmaskingallothers).Asalastexample,Figure7.8illustratesvariableimportancesforX1andX2whenincreasingthecardinalityL=|X1|ofX1ontheprevi-oustoyproblem.Thatis,letusredeﬁnetheoutputasY=X1<L2,forX1={0,...,L−1},whilekeepingX2asabinaryvariabledeﬁnedasacopyofY.Assumingthatallinputsamplesareequiprobable,theimportancesyieldedbytotallyrandomizedtreeswithmultiwaysplitsremainthesameasbefore.ForETshowever,increasingLin-ducesevenmorenewimpuritytermsthatarenowaccountedforintheimportances.Astheﬁgureshows,increasingthecardinalityofX1makesitsimportancedecrease,butalsosimultaneouslymakestheimportanceofX2increase.Indeed,splittingonX2alwaysyield162furtherinsightsfromimportances200.00.20.40.60.81.0X1ETsRF200.00.20.40.60.81.0X2Figure7.8:VariableimportancesofX1andX2whenincreasingthecardinal-ityofX1.childnodesthatarepure,whichisunlikelytobethecasewhensplit-tingrandomlyonX1.ForRF,onlythebestthresholdsareselected,yieldinginthiscasechildnodesthatarealwayspure,asfortotallyrandomizedtrees.Assuch,theirimportancesrespectivelyappearasequalastheﬁgureconﬁrms.Overall,theseadditionaleffectsduetobinarysplitsmakevariableimportancescomputedfromclassicalrandomforestsverydifﬁculttointerpretandunderstand,assoonasdataincludemanyvariablesofdifferentnumberofcategories.Whiletheycanstillbeusedtoiden-tifythemostrelevantvariables,cautionshouldbetakenwheninter-pretingtheamplitudeofimportances.Asourlastexampleillustrates,theymaybemisleadinglyloworhighbecauseofcombinatorialef-fects,solelyduetothepossiblewaysvariablesarebinarizedthroughtheimplementedthresholdselectionmechanisms.EncodingL-aryvariablesintobinaryvariablesPartitioningnodesampleswithbinarysplitsonL-aryinputvariablesisequivalenttoindividuallytransformingeachinputvariableXjintoasetofLj−1binaryinputvariables{Xlj|l=1,...,Lj−1},eachencod-ingforonethepossiblesplits,andthenpartitioningnodesamplesusingofonethesenewvariables.Ifweconsiderthebinarizedlearn-ingsetL0,forwhichallptheinputvariableshavebeentransformedintoPj(Lj−1)binaryvariables,thenourtheoreticalframeworkfortotallyrandomizedtreesandexhaustivesplitscanbeappliedandTheorem6.1couldpossiblybeadapted.Theonlydifferenceliesinthewaybinaryvariablesaredrawnatrandom:insteadofsplittingrandomlyononeofthePj(Lj−1)variables,ﬁrst,oneoftheporigi-nalvariablesisdrawnuniformlyatrandom;second,oneofitsLj−1binaryvariablesisselectedforsplittingthecurrentnode.Inthisset-ting,theimportanceofXjthereforeamountstothesumofimpor-tancesPlImp(Xlj)ofitsbinaryvariables.7.3applications1637.3applicationsInspiteofthevariousconcurrenteffectsdiscussedearlier,variableimportancemeasureshavebeenusedwithsuccessinawiderangeofscientiﬁcapplications.Whiletheyhaveproventobeagoodproxyforassessingtherelevanceofinputvariables,providinghelpfulin-sights,toooftenvariableimportancesareusedasablack-boxmetric,henceunder-exploitingtheinformationtheyoffer.Assuch,examplespresentedinthissectionalldemonstratethatanyprogresstowardsabettertheoreticalunderstandingofvariableimportancesmayhelptofurtheradvanceawiderangeofresearchdomains.7.3.1FeatureselectionWithinthepast10or20years,typicalmachinelearningproblemshavegrownfromafewtensofinputvariablestodomainsexplor-inghundredsofthousandsofvariables,oftencomprisingnoisy,ir-relevantorredundantpredictors,mixingbothnumericalandcate-goricalvariablesandinvolvingcomplexinteractioneffects.Inthiscontext,thefeatureselectionproblemconsistsinidentifyingasub-setoftheoriginalinputvariablesthatareusefulforbuildingagoodmodel[GuyonandElisseeff,2003;LiuandYu,2005].Theadvantagesandbeneﬁtsofreducingthedimensionalityoftheprobleminclude:speedingupmachinelearningalgorithms,reducingmeasurementandstoragerequirements,improvingtheaccuracyofthemodelsorfacilitatingdatavisualizationandunderstanding.Becauseofthepropertiesofrandomforests(goodpredictionper-formance,robustnesstonoisyvariables,supportofnumericalandcat-egoricalvariablesandabilitytomodelcomplexinteractions),variableimportancesoftenprovideaneffectivesolutionforthefeatureselec-tionproblem.Themoststraightforwardsolutionconsistsinrankingvariablesaccordingtotheirimportancescoresandtoonlykeepthemostimportantones.Dependingontheobjective,thebestsubsetofvariablescanbeidentiﬁedinseveralways:-Whenthegoalissimplytoreducedimensionalitybecauseofspeedandstoragerequirements,thesimplestsolutionistokeeponlythosevariableswhoseimportancesImp(Xj)isgreaterthansomemanuallydeﬁnedthresholdα.-Ifthegoalistoimproveaccuracy,agoodsubsetofvariablescantypicallybefoundbytuningthethresholdαsoastominimizesomeuser-deﬁnedcriterion(e.g.,thezero-onelossinclassiﬁca-tionorthesquarederrorlossinregression)forthemodelbuiltonthesubset{Xj|Imp(Xj)>α}.Atthepriceofmorecomputationalefforts,evenbetterper-formancecanusuallybereachedbyembeddingvariableim-164furtherinsightsfromimportancesportancesintoadedicatediterativefeatureselectionprocedure,suchasthosedescribedin[Guyonetal.,2002;Tuvetal.,2009].-Insomeotherapplications,theobjectiveistoidentifyvariablesthatarerelevant,inordertobetterunderstandtheunderlyingrelationswiththeoutputY.Inasymptoticconditions,thiscouldbedonebydiscardingallvariableswhoseimportancesisnull,asshownbyTheorem6.5.Inaﬁnitesettinghowever,biasduetomaskingeffectsorimpuritymisestimations(aspreviouslydiscussedinSection7.2)makesitmoredifﬁculttoidentifyvari-ablesthataretrulyrelevantsincetheirimportancesmightap-peartobelowerthanthoseofirrelevantvariables.Yet,severaloptionsareavailableforcontrollingandlimitingfalsepositives,suchasstoppingtheconstructionprocesswhenimpurityesti-mationsbecomestatisticallyunreliable(Section7.2.2),compar-ingtheimportancesoftheoriginalinputvariablestoartiﬁcialcontrasts[Tuvetal.,2006]orrobustlycontrollingthecondi-tionalerrorratethroughpermutationtests[Huynh-Thuetal.,2012].7.3.2BiomarkeridentiﬁcationWiththeriseof-omicsdata,randomforestshavebecomeoneofthemostpopulartoolsinlifesciences,providingpractitionerswithbothhigh-predictionaccuracyandhelpfulinsightsabouttheimportancesofvariables.Inmanycases,variableimportancemeasures(eitherMDIorthepermutationimportance)isexploitedtobetterunder-standcomplexinteractioneffectsbetweentheinputsandtheout-put.Examplesofsuccessfulapplicationsincludetheidentiﬁcationofdisease-associatedSNPsingenome-wideassociationstudies[Lunettaetal.,2004;Mengetal.,2009;Bottaetal.,2014],thediscoveryofim-portantgenesandpathwaysfrommicro-arraygene-expressiondata[Pangetal.,2006;Changetal.,2008]ortheidentiﬁcationoffactorsforpredictingprotein-proteininteractions[Qietal.,2006].Theseex-amplesarenotisolatedandtensoffurtherstudiesbasedonrandomforestscouldinfactbecitedfromtheﬁeldsofgenomics,metabolomics,proteomicsortranscriptomics.Someofthemarereviewedin[Geurtsetal.,2009;Touwetal.,2013;Boulesteixetal.,2012].Inlightofourstudyanddiscussionofvariableimportances,rec-ommendationsforbiomarkeridentiﬁcationdependontheexactob-jectiveoftheapplication.Ifthegoalistoidentifyallrelevantvari-ables,thentotallyrandomizedtreeswithmultiwaysplitsshouldbepreferred.Theyindeedconstitutetheonlymethodforwhichvariableimportancesareunbiased,takingintoaccountallpossibleinteractiontermsinafairandexhaustiveway.Theonlycaveatisthata(very)largenumberoftreesmayberequiredbeforevariableimportancesconverge,makingthemcomputationallyintensivetocompute,even7.3applications165Figure7.9:GeneregulatorynetworkinStaphylococcusaureus.Imagefrom[Marbachetal.,2012].ifthefullrandomizationoftheinductionprocedureactuallymakeindividualdecisiontreestobequitefasttogenerate.Bycontrast,iftheobjectiveisonlytoidentifyasubsetofgoodpredictorsforpre-dictingtheoutput(hencepossiblyomittingrelevantbutredundantvariables),thennon-totallyrandomizedtrees(e.g.,standardRForETs)withKchosentomaximizeaccuracyshouldbepreferred.Evenifsomeinformativevariablesmaybemaskedbecauseofvariableselec-tion,agoodsubsetofinputvariablesshouldstillbeidentiﬁablefromimportancescores.Fromacomputationalpointofview,convergenceshouldalsobefaster,makingthisapproachmoreappealingwhenresourcesarelimited.Inallcases,impuritymisestimationsshouldbecontrolledbystoppingtheconstructionprocessearlyorcollect-ingimportancesonlyforthosenodeswhereimpurityreductionscanbeconsideredasreliable.Finally,wheneverpractical,variableimpor-tancesshouldalsobedecomposedinordertobetterunderstandwhysomevariablesappearasmoreimportantthanothers.Inparticular,studyingthedecompositionmighthelpidentifyredundancyeffects.7.3.3NetworkinferenceGivenasetofinputvariablesV={X1,...,Xp},thenetworkinferenceproblemconsistsintheidentiﬁcationofconditionaldependenciesbe-tweenvariables.Ingenomicsforexample,regulatorynetworkinfer-enceconsistsintheidentiﬁcationofinteractionsbetweengenesortranscriptionfactorsonthebasisoftheirexpressionlevel,inordertoreconstructaglobalnetworkofinteractions(asillustratedinFig-ure7.9forStaphylococcusaureus).AsproposedintheGENIE3method[Huynh-Thuetal.,2010],thenetworkinferenceproblemcanbesolvedgenericallybyremarkingthatitcandecomposedintopindependentsupervisedlearningprob-lems.Formally,foreachinputvariableXj(forj=1,...,p),GENIE3considersthesupervisedsub-problemconsistinginthepredictionof166furtherinsightsfromimportancesthetargetvariableXjfromtheremainingp−1variablesV−j.Usingrandomforestsforsolvingeachofthesepproblems,variableim-portancescanbederivedandusedasanindicationofthe(directed)putativelinkbetweenthepredictorvariablesXi(fori6=j)andthetargetXj.Intuitively,thelargertheimportance,themorelikelytheconditionaldependencywithXj.Onceallpproblemsaresolved,pu-tativelinksareaggregatedoverallpvariablestoprovidearankingofinteractionsfromwhichthenetworkcanﬁnallybereconstructed.Again,ourprevioustheoreticalanalysiscallsforcautionwhenpluggingvariableimportancesintonetworkinferenceprocedures.In-deed,sincethegoalistoretrievealldirectinteractions,importancesmightinfactnotbeasappropriateasdesiredsincetheyalsoaccountforindirectorcombinedeffects.Inthiscase,agoodheuristicistointentionallyinducemaskingeffects(i.e.,bysettingK>1)inordertorecoveronlythestrongest(andassuminglydirect)interactions.Al-ternatively,apromisingstrategymightbetodirectlylookforstronglyrelevantvariables,thatisforvariablesXisuchthatI(Xi;Xj|B)>0forallB.Inbothcases,impuritymisestimationseffectsshouldbemitigatedbyusinganadequatestoppingcriterion.Wheninputvari-ablesareofdifferentscaleofmeasurementsorvaryinthenumberofcategories,careshouldﬁnallybetakenwhenaggregatingvariableimportancesintoasinglerankingofinteractions.AsshownbyTheo-rem6.2,variableimportancesareinthiscaseupperboundedbytheentropyH(Xj)ofthetargetvariable,whichmaygreatlyvariesfromonetargettoanother.Assuch,variableimportancesarenotdirectlycomparableandshouldpreferablybenormalized(e.g.,byH(Xj))be-foretheiraggregation.PartIIISUBSAMPLINGDATA8ENSEMBLESONRANDOMPATCHESOutlineInthischapter,weconsidersupervisedlearningundertheassump-tionthattheavailablememoryissmallcomparedtothesizeofthedataset.Thisgeneralframeworkisrelevantinthecontextofbigdata,distributeddatabasesandembeddedsystems.InSection8.1,wepro-poseaverysimple,yeteffective,ensembleframeworkthatbuildseachindividualmodeloftheensemblefromarandompatchofdataobtainedbydrawingrandomsubsetsofbothsamplesandinputvari-ablesfromthewholedataset.Insections8.2and8.3,wecarryoutanextensiveandsystematicevaluationofthismethodon29datasets,us-ingdecisiontreesasbasemodels.Withrespecttopopularensemblemethods,theseexperimentsshowthattheproposedmethodprovidesonparperformanceintermsofaccuracywhilesimultaneouslylow-eringthememoryneeds,andattainssigniﬁcantlybetterperformancewhenmemoryisseverelyconstrained.Weconcludeanddiscussfu-tureworkdirectionsinSection8.4.Thischapterisbasedonpreviousworkpublishedin[LouppeandGeurts,2012].Withinthepastfewyears,bigdatahasbecomeapopulartrendamongmanyscientiﬁcﬁelds.Inlifesciences,computervision,In-ternetsearchorﬁnance,tociteafew,quantitiesofdatahavegrownsolargethatitisincreasinglydifﬁculttoprocess,analyzeorvisualize.Inmanycases,singlecomputersarenolongerﬁtforbigdataanddis-tributedenvironmentsneedtobeconsideredtohandleit.Althoughresearchisveryactiveinthisarea,machinelearningisnoexceptiontothisnewparadigm.Muchstillneedstobedoneandmethodsandalgorithmshavetobereinventedtotakethisconstraintintoaccount.Inthiscontext,weconsidersupervisedlearningproblemsforwhichthedatasetissolargethatitcannotbeloadedintomemory.Breiman[1999]proposedthePastingmethodtotacklethisproblembylearn-inganensembleofmodelsindividuallybuiltonrandomsubsetsofthetrainingexamples,hencealleviatingthememoryrequirementssincethebasemodelswouldbebuiltononlysmallpartsofthewholedataset.Earlier,Ho[1998]proposedtolearnanensembleofmodelsindividuallybuiltonrandomsubspaces,i.e.,onrandomsub-setsoftheinputvariables(orfeatures).WhiletheﬁrstmotivationoftheRandomSubspacemethodwastoincreasethediversitywithinthemodelsoftheensemble,itcanactuallyalsobeseenaswaytoreducethememoryrequirementsofbuildingindividualmodels.In169170ensemblesonrandompatchesthiswork,weproposetocombineandleveragebothapproachesatthesametime:learnanensembleofmodelsonrandompatches,i.e.,onrandomsubsetsofthesamplesandoftheinputvariables.Throughanextensiveempiricalstudy,weshowthatthisapproach(1)improvesorpreservescomparableaccuracywithrespecttootherensembleap-proacheswhichbuildbasemodelsonthewholedatasetwhile(2)drasticallyloweringthememoryrequirementsandhenceallowinganequivalentreductionoftheglobalcomputingtime.Inotherwords,thisanalysisshowsthatthereisusuallynoneedtobuildindividualmodelsonthewholedataset.Forthesameaccuracy,modelscanbelearnedindependentlyonsmallportionsofthedata,withinsigniﬁ-cantlylowercomputationalrequirements.8.1randompatchesTheRandomPatchesalgorithmproposedinthiswork(furtherre-ferredtoasRP)isawrapperensemblemethodthatcanbedescribedinthefollowingterms.LetR(αs,αf,L)bethesetofallrandompatchesofsizeαsN×αfpthancanbedrawnfromthedatasetL,whereN(resp.,p)isthenumberofsamplesinL(resp.,thenumberofinputvariablesinL)andwhereαs∈[0,1](resp.αf)isanhyper-parameterthatcontrolsthenumberofsamplesinapatch(resp.,thenumberofvariables).Thatis,R(αs,αf,L)isthesetofallpossiblesub-setscontainingαsNsamples(amongN)withαfpvariables(amongp).Themethodthenworksasfollows:Algorithm8.1.RandomPatchesalgorithm.1:form=1,...,Mdo2:Drawapatchr∼U(R(αs,αf,L))uniformlyatrandom3:Buildamodelontheselectedpatchr4:endfor5:AggregatethepredictionsoftheMmodelsinanensembleWhiletheRPalgorithmcanexploitanykindofbaseestimators,weconsiderinthisworkonlytree-basedestimators.Inparticular,weevaluatetheRPalgorithmusingstandardclassiﬁcationtrees(asde-scribedinChapter3)and(single)extremelyrandomizedtrees[Geurtsetal.,2006a].Unlessstatedotherwise,treesareunprunedandgrownusingGiniindexasimpuritycriterionfornodesplitting.Theparame-terKofextremelyrandomizedtreeswithinRPissettoitsmaximumvalueK=αfp(i.e.,correspondingtonofurtherrandomselectionofvariables).TheﬁrstbeneﬁtofRPisthatitgeneralizesboththePastingRvotes(P)method[Breiman,1999](anditsextensions[Chawlaetal.,2004;Basilicoetal.,2011])andtheRandomSubspace(RS)algorithm[Ho,1998].BothareindeedmerelyparticularcasesofRP:settingαs=1.0yieldsRSwhilesettingαf=1.0yieldsP.Assuch,itisexpectedthat8.2onaccuracy171whenbothhyper-parametersαsandαfaretunedsimultaneously,RPshouldbeatleastasgoodasthebestofthetwomethods,providedthereisnooverﬁttingassociatedwiththistuning.Whenthebaseestimatorsarestandarddecisiontrees(resp.,ex-tremelyrandomizedtreeswithK=αfp),interestingparallelscanalsobedrawnbetweenRPandtheRFalgorithm(resp.,ET).Forαs=1.0,thevalueofαfpisindeednearlyequivalenttothenumberKoffeaturesrandomlyconsideredwhensplittinganode.Amajordifferenceremainsthough.InRP,thesubsetoffeaturesisselectedgloballyonceandforall,priortotheconstructionofeachtree.Bycontrast,inRF(resp.,inET)subsetsoffeaturesaredrawnlocallyateachnode.Clearly,theformerapproachalreadyappearstobemoreattractivewhendealingwithlargedatabases.Non-selectedfeaturesindeeddonotneedtobeconsideredatall,henceloweringthemem-oryrequirementsforbuildingasingletree.Anotherinterestingparal-lelcanbemadewhenbootstrapsamplesareusedlikeinRF:itnearlyamountstosetαs=0.632,i.e.theaverageproportionofuniquesam-plesinabootstrapsample.Differencesarethatinabootstrapsample,thenumberofuniquetrainingsamplesvariesfromonetoanother(whileitwouldbeﬁxedto0.632NinRP),andthatsamplesarenotallequallyweighted.Inaddition,RPalsocloselyrelatestotheSubBagalgorithmwhichcombinesBaggingandRSforconstructingensembles.UsingNboot-strappedsamples(i.e.,nearlyequivalenttoαs=0.632)andsettingαf=0.75,PanovandDžeroski[2007]showedthatSubBaghascom-parableperformancetothatofRF.AnaddedadvantageofSubBag,andhenceofRP,isthatitisapplicabletoanybaseestimatorwithouttheneedtorandomizethelatter.8.2onaccuracyOurvalidationoftheRPalgorithmiscarriedoutintwosteps.Inthissection,weﬁrstinvestigatehowRPcompareswithotherpopulartree-basedensemblemethodsintermsofaccuracy.Inthenextsection,wethenfocusonitsmemoryrequirementsforachievingoptimalaccu-racyanditscapabilitytohandlestrongmemoryconstraints,againincomparisonwithotherensemblemethods.Consideringaccuracyonly,ourmainobjectiveistoinvestigatewhe-thertheadditionaldegreesoffreedombroughtbyαsandαfsignif-icantlyimprove,ordegrade,theperformanceofRP.Atﬁrstglance,onemightindeedthinkthatsincethebaseestimatorsare(intention-ally)builtonpartsofthedata,theaccuracyoftheensemblewillbelowerthaniftheywereallbuiltonthewholeset.Additionally,ourgoalisalsotoseewhethersamplingfeaturesonceglobally,insteadoflocallyateachnode,impairsperformance,asthisisthemaindiffer-encebetweenRPandstate-of-the-artmethodssuchasRForET.172ensemblesonrandompatches8.2.1ProtocolWecompareourmethodwithPandRS,aswellaswithRFandET.ForRP,PandRS,twovariantshavebeenconsidered,oneusingstan-darddecisiontrees(sufﬁxedbelowwith’-DT’)asbaseestimators,andtheotherusingextremelyrandomizedtrees(sufﬁxedbelowwith’-ET’)asbaseestimators.Overall,8methodsarecompared:RP-DT,RP-ET,P-DT,P-ET,RS-DT,RS-ET,RFandET.Weevaluatetheaccuracyofthemethodsonanextensivelistofbothartiﬁcialandrealclassiﬁcationproblems.Foreachdataset,threeran-dompartitionsweredrawn:theﬁrstandlarger(50%oftheoriginaldataset)tobeusedasthetrainingset,thesecond(25%)asvalida-tionsetandthethird(25%)astestset.Forallmethods,thehyper-parametersαsandαfweretunedonthevalidationsetwithagrid-searchprocedure,usingthegrid{0.01,0.1,...,0.9,1.0}forbothαsandαf.Allotherhyper-parametersweresettodefaultvalues.InRFandET,thenumberKoffeaturesrandomlyselectedateachnodewastunedusingthegridαfp.Forallensembles,250fullydevelopedtreesweregeneratedandthegeneralizationaccuracywasestimatedonthetestset.Unlessotherwisementioned,forallmethodsandforalldatasets,thatprocedurewasrepeated50times,usingthesame50randompartitionsbetweenallmethods,andallscoresreportedbelowareaveragesoverthose50runs.AllalgorithmsandexperimentshavebeenimplementedinPython,usingScikit-Learn[Pedregosaetal.,2011]asbaseframework.8.2.2SmalldatasetsBeforedivingintoheavilycomputationalexperiments,weﬁrstwantedtovalidateourapproachonsmalltomediumdatasets.Tothatend,experimentswerecarriedoutonasampleof16well-knownandpub-liclyavailabledatasets(seeTable8.1)fromtheUCImachinelearningrepository[FrankandAsuncion,2010],allchosenaprioriandinde-pendentlyoftheresultsobtained.Overall,thesedatasetscoverawiderangeofconditions,withthesamplesizesrangingfrom208to20000andthenumberoffeaturesvaryingfrom6to168.Detailedaverageperformancesofthe8methodsforall16datasetsusingtheprotocoldescribedabovearereportedinTable8.2.Below,weanalyzegeneraltrendsbyperformingvariousstatisticaltests.Followingrecommendationsin[Demsar,2006],weﬁrstperformedaFriedmantestthatrejectedthehypothesisthatallalgorithmsareequivalentatasigniﬁcancelevelα=0.05.Wethenproceededwithapost-hocNemenyitestforapairwisecomparisonoftheaverageranksofall8methods.Accordingtothistest,theperformanceoftwoclassiﬁersissigniﬁcantlydifferent(atα=0.05)iftheiraverageranksdifferbyatleastthecriticaldifferenceCD=2.6249(See[Demsar,8.2onaccuracy173DatasetNpdiabetes7688dig441800016ionosphere35134pendigits1099216letter2000016liver3456musk26598168ring-norm1000020satellite643536segment231019sonar20860spambase460157two-norm999920vehicle169218vowel99010waveform500021Table8.1:Smalldatasets.CD87654321ETRS-ETRP-ETP-ETP-DTRS-DTRFRP-DTFigure8.1:Averageranksofallmethodsonsmalldatasets.2006]forfurtherdetails).ThediagramofFigure8.1summarizesthesecomparisons.ThetoplineinthediagramistheaxisalongwhichtheaveragerankRmofeachmethodmisplotted,fromthehighestranks(worstmethods)onthelefttothelowestranks(bestmethods)ontheright.Groupsofmethodsthatarenotstatisticallydifferentfromeachotherareconnected.ThecriticaldifferenceCDisshownabovethegraph.Tofurthersupporttheserankcomparisons,wealsocomparethe50accuracyvaluesobtainedovereachdatasetsplitforeachpairofmethodsbyusingapairedt-test(withα=0.01).TheresultsofthesecomparisonsaresummarizedinTable8.3intermsof“Win-Draw-Loss”statusesofallpairsofmethods;thethreevaluesattheintersectionofrowiandcolumnjofthistablerespectivelyindicateonhowmanydatasetsmethodiissigniﬁcantlybetter/notsigniﬁcantlydifferent/signiﬁcantlyworsethanmethodj.174ensemblesonrandompatchesValidationRFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETdiabetes77.12(6)77.25(5)77.67(4)78.01(3)75.11(8)76.77(7)78.82(2)79.07(1)dig4494.99(7)95.78(1)91.86(8)95.46(4)95.07(6)95.69(3)95.13(5)95.72(2)ionosphere94.40(6)95.15(3)93.86(8)94.75(5)94.11(7)94.90(4)95.20(2)95.36(1)pendigits98.94(7)99.33(1)98.09(8)99.28(4)99.02(6)99.31(3)99.07(5)99.32(2)letter95.36(7)96.38(1)92.72(8)95.87(4)95.68(6)96.08(3)95.74(5)96.10(2)liver72.37(5)71.90(6)72.55(4)72.88(3)68.06(8)70.88(7)74.53(1)74.37(2)musk297.18(7)97.73(1)96.89(8)97.60(4)97.58(6)97.72(3)97.60(5)97.73(2)ring-norm97.44(6)98.10(5)96.41(8)97.28(7)98.25(4)98.41(3)98.50(2)98.54(1)satellite90.97(7)91.56(1)90.01(8)91.40(5)91.31(6)91.50(3)91.41(4)91.54(2)segment97.46(6)98.17(2)96.78(8)98.10(4)97.33(7)98.14(3)97.52(5)98.21(1)sonar82.92(7)86.92(3)80.03(8)84.73(5)83.07(6)87.07(2)85.42(4)88.15(1)spambase94.80(7)95.36(3)93.69(8)95.01(6)95.01(5)95.50(2)95.11(4)95.57(1)two-norm97.54(6)97.77(2)97.52(7)97.59(5)97.46(8)97.63(4)97.76(3)97.82(1)vehicle88.67(5)88.68(4)88.26(8)88.74(3)88.41(7)88.60(6)89.22(1)89.21(2)vowel92.04(5)95.12(1)85.19(8)93.49(4)89.76(7)94.34(3)91.10(6)94.48(2)waveform85.45(6)85.96(2)84.89(8)85.68(5)84.91(7)85.69(4)85.85(3)86.21(1)Averagerank6.252.56257.43754.43756.53.753.56261.5TestRFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETdiabetes75.62(4)75.38(5)75.67(3)76.34(1)73.03(8)74.63(7)75.32(6)75.82(2)dig4494.96(6)95.67(1)91.79(8)95.39(4)94.98(5)95.58(2)94.95(7)95.55(3)ionosphere92.20(6)93.22(1)92.09(7)92.40(4)92.02(8)93.22(2)92.34(5)92.68(3)pendigits98.84(7)99.23(1)97.97(8)99.21(3)98.95(5)99.21(2)98.93(6)99.20(4)letter95.27(7)96.29(1)92.57(8)95.89(4)95.61(5)96.03(2)95.61(6)95.99(3)liver69.95(3)68.22(6)70.43(1)69.58(5)63.17(8)67.35(7)70.20(2)69.67(4)musk297.08(7)97.61(1)96.69(8)97.54(4)97.47(5)97.58(2)97.42(6)97.56(3)ring-norm97.48(6)98.07(5)96.42(8)97.25(7)98.16(4)98.31(1)98.22(3)98.30(2)satellite90.67(7)91.22(2)89.66(8)91.20(3)91.15(5)91.28(1)91.04(6)91.20(4)segment97.02(5)97.93(1)96.44(8)97.86(3)96.86(7)97.90(2)96.88(6)97.84(4)sonar79.53(5)82.76(1)75.15(8)80.07(4)78.50(6)82.19(2)78.26(7)81.92(3)spambase94.76(7)95.17(3)93.51(8)94.84(5)94.88(4)95.22(2)94.80(6)95.22(1)two-norm97.22(7)97.50(1)97.26(6)97.29(4)97.20(8)97.33(2)97.33(3)97.28(5)vehicle87.47(7)87.85(3)87.01(8)87.98(2)87.50(6)87.68(5)87.73(4)88.08(1)vowel91.51(5)93.95(1)84.17(8)92.93(4)89.51(7)93.60(2)89.89(6)93.09(3)waveform85.23(5)85.77(1)84.68(8)85.40(3)84.74(7)85.38(4)85.16(6)85.56(2)Averagerank5.8752.1257.06253.756.1252.81255.31252.9375Table8.2:Accuracyonsmalldatasets(in%).8.2onaccuracy175RFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETRF—1/2/1312/4/01/7/84/7/52/2/121/10/50/4/12ET13/2/1—14/1/110/5/113/3/04/11/112/2/25/10/1P-DT0/4/121/1/14—0/4/122/3/112/1/130/4/120/4/12P-ET8/7/11/5/1012/4/0—9/6/12/6/89/6/10/11/5RS-DT5/7/40/3/1311/3/21/6/9—0/2/141/11/40/4/12RS-ET12/2/21/11/413/1/28/6/214/2/0—11/4/11/13/2RP-DT5/10/12/2/1212/4/01/6/94/11/11/4/11—0/6/10RP-ET12/4/01/10/512/4/05/11/012/4/02/13/110/6/0—Table8.3:Pairwiset-testcomparisonsonsmalldatasets.Sinceallmethodsarevariantsofensemblesofdecisiontrees,av-erageaccuraciesarenotstrikinglydifferentfromonemethodtoan-other(seeTable1ofthesupplementarymaterials).Yet,signiﬁcanttrendsappearwhenlookingatFigure8.1andTable8.3.First,allET-basedmethodsarerankedbeforeDT-basedmethods,includingthepopularRandomForestalgorithm.Overall,theoriginalETalgorithmisrankedﬁrst(RET=2.125),thencomeRS-ETandRP-ETatclosepositions(RRS−ET=2.8125andRRP−ET=2.9375)whileP-ETisabitbehind(RP−ET=3.75).AccordingtoFigure8.1,onlyETisrankedsigniﬁcantlyhigherthanallDT-basedmethodbutlookingatTable8.3,theworseET-basedvariant(P-ET)isstill9timessigniﬁcantlybetter(w.r.t.the50runsovereachset)andonly1timesigniﬁcantlyworsethanthebestDT-basedvariant(RP-DT).Theseparationbe-tweenthesetwofamiliesofalgorithmthusappearsquitesigniﬁcant.Thisobservationclearlysuggeststhatusingrandomsplitthresholds,insteadofoptimizedoneslikeindecisiontrees,paysoffintermsofgeneralization.AmongET-basedmethods,RP-ETisbetterthanP-ETbutitissu-persededbyETandRS-ETintermsofaveragerank.SinceRS-ETisaparticularcaseofRP-ET,thissuggeststhatweareslightlyoverﬁt-tingwhentuningtheadditionalparameterαs.AndindeedRP-ETisbetterrankedthanRS-ETinaverageonthevalidationset(resultsnotshown).Table8.3howeverindicatesotherwiseandmakesRP-ETap-pearasslightlybetterthanRS-ET(2/13/1).RegardingEToverRP-ET,thebetterperformanceoftheformer(5/10/1)isprobablyduetothefactthatinETsubsetsoffeaturesareredrawnlocallyateachnodewhenbuildingtreesandnotonceandforallpriortotheirconstruc-tion.Thisgiveslesschancestogenerateimpropertreesbecauseofabadinitialchoiceoffeaturesandthusleadstoalowerbiasandabetteraccuracy.AmongDT-basedmethods,RP-DTnowcomesﬁrst(meanrankof5.3125),thenRF(RRF=5.875),RS-DT(RRS−DT=6.125)andthenP-DTinlast(RP−DT=7.0625).RPisonlysigniﬁcantlyworsethananotherDT-basedvarianton1dataset.Theextra-randomization176ensemblesonrandompatchesbroughtbytherandomchoicesofbothsamplesandfeaturesseemstobebeneﬁcialwithdecisiontreesthatdonotbeneﬁtfromtherandom-izationofdiscretizationthresholds.ThefactthatRFsamplesfeatureslocallydoesnotappearhereanymoreasanadvantageoverRP(RFissigniﬁcantlyworseon5problemsandbetterononlyone),proba-blybecausethedecreaseofbiasthatitprovidesdoesnotexceedtheincreaseofvariancewithrespecttoglobalfeatureselection.8.2.3LargerdatasetsWhiletheformerexperimentsrevealedpromisingresults,itisfairtoaskwhethertheconclusionsthathavebeendrawnwouldholdonandgeneralizetolargerproblems,forexamplewhendealingwithafewrelevantfeaturesburiedintohundredsorthousandsofnotim-portantfeatures(e.g.,ingenomicdata),orwhendealingwithmanycorrelatedfeatures(e.g.,inimages).Toinvestigatethisquestion,asec-ondbenchofexperimentswascarriedouton13largerdatasets(seeTable8.4).Allbutmadelonarerealdata.Intermsofdimensions,thesedatasetsarefarbigger,rangingfromafewhundredsofsamplesandthousandsoffeatures,tothousandsofsamplesbuthundredsoffeatures.Assuch,thecomplexityoftheproblemsisexpectedtobegreater.Weadoptedtheexactsameprotocolasforsmallerdatasets.However,tolowercomputingtimes,fordatasetsmarkedwith∗,themethodswererunusing100treesinsteadof250andtheminimumnumberofsamplesrequiredinaninternalnodewassetto10inordertocontrolcomplexity.DetailedresultsareprovidedinTable8.5andaresummarizedinFigure8.2andTable8.6,respectivelyintermsofaveragerank(thecriticaldifferenceatα=0.05isnow2.9120)andWin/Draw/Lossstatusesobtainedwithpairedt-tests.AFriedmantest(atα=0.05)stillindicatesthatsomemethodsaresigniﬁcantlydifferentfromtheothers.AsitmaybeobservedfromFigure8.2,theaverageranksofthemethodsareclosertoeachotherthaninthepreviousexperiments,nowrangingfrom2.38to6.61,whiletheywerepreviouslyrangingfrom2.12to7.Methodsaremoreconnectedbycriticaldifferencebars.Thissuggeststhatoveralltheybehavemoresimilarlytoeachotherthanbefore.Generaltrendsareneverthelesscomparabletowhatweobservedearlier.ET-basedmethodsstillseemtobethefront-runners.FromFigure8.2,RS-ET,ETandRP-ETareinthetop4,whileP-DT,RFandRP-DTremaininthesecondhalfoftheranking.Surprisinglyhowever,RS-DTnowcomesrightafterRS-ETandETandjustbe-foreRP-ETwhereasitrankedpenultimateonthesmallerdatasets.Ta-ble8.6howeversuggeststhatRS-DTperformsactuallyalittleworseagainstRP-ET(1/10/2).Allinall,itthusstillseemsbeneﬁcialtoran-domizesplitthresholdsonthelargerdatasets.8.2onaccuracy177DatasetNpcifar10*600003072mnist3vs813966784mnist4vs913782784mnist*70000784isolet7797617arcene90010000breast229524496madelon4400500marti05001024reged0500999secom1567591tis13375927sido0*126784932Table8.4:Largedatasets.ComparingET-basedvariants,ETisnolongerthebestmethodonaverage,butRS-ETis(with4/9/0forRS-ETversusET).Thissug-geststhanonlargerdatasets,pickingfeaturesgloballyatrandompriortotheconstructionofthetreesisasgood,orevenbeatpickingthemlocallyateachnode.Duetothequantitativelylargernumberofsamplesinapatch,andalsotothelargernumberofredundantfeaturesexpectedinsomelargedatasets(e.g.,incifar10ormnist),itisindeedlesslikelytobuildimpropertreeswithstrongbiases.Asaresult,variancecanbefurtherdecreasedbysamplingglobally.Insupportofthisclaim,onafewproblemssuchasarcene,breast2,ormadelonthatcontainmanyirrelevantfeatures,ETremainsthebestmethod.Inthatcase,itisindeedmorelikelytosamplegloballyimproperrandompatches,andhencetobuildimpropertrees.TheaveragerankofRP-ETsuggeststhatitperformsworsethanRS-ETandthusthatthereissomepotentialoverﬁttingwhentuningαsinadditiontoαf.ThisdifferenceishowevernotconﬁrmedinTable8.6wheretheaccuraciesofthesetwomethodsareshowntobeneversigniﬁcantlydifferent(0/13/0).RP-ETisalsoonaperfectparwithET(1/11/1).AmongDT-basedvariants,RP-DT,whichwasthebestperformeronsmalldatasets,isstillrankedaboveRFandP-DT,butitisnowrankedbelowRS-DTwithawin/draw/lossof0/11/2.Thisisagainduetosomeoverﬁtting.Whilelessconclusivethanbefore,theresultsonlargerdatasetsareconsistentwithwhatweobservedearlier.Inparticular,theyindicatethattheRandomPatchesmethod(withET)remainscompetitivewiththebestperformers.178ensemblesonrandompatchesValidationRFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETcifar1045.16(6)46.17(1)44.92(7)44.88(8)45.83(5)46.09(3)45.89(4)46.13(2)mnist3v898.42(7)98.77(5)97.63(8)98.57(6)98.79(4)98.86(2)98.81(3)98.87(1)mnist4v998.47(7)98.82(3)97.39(8)98.47(6)98.77(5)98.89(2)98.80(4)98.91(1)mnist96.14(7)96.56(3)94.35(8)96.19(6)96.52(5)96.57(2)96.53(4)96.57(1)isolet93.96(7)95.07(3)90.90(8)94.23(6)94.38(5)95.15(2)94.47(4)95.20(1)arcene73.84(7)77.76(3)73.76(8)75.12(6)76.40(5)77.60(4)79.44(2)80.00(1)breast269.64(6)69.91(4)70.54(3)69.83(5)69.59(7)69.54(8)72.59(1)71.62(2)madelon76.12(8)81.41(1)78.48(7)81.06(5)80.68(6)81.29(3)81.18(4)81.36(2)marti87.66(8)87.92(6)88.08(4)88.09(3)87.77(7)88.00(5)88.19(2)88.20(1)reged98.00(6)98.46(2)97.08(8)98.24(5)98.00(7)98.41(3)98.40(4)98.57(1)secom93.37(5)93.36(6)93.34(8)93.42(2)93.35(7)93.40(4)93.41(3)93.45(1)tis91.81(5)91.53(7)91.59(6)91.50(8)92.04(3)91.97(4)92.26(1)92.06(2)sido97.46(5)97.44(6)97.36(8)97.36(7)97.47(3)97.46(4)97.52(1)97.52(2)Avg.rank6.46153.84617.05.61535.30763.53842.84611.3846TestRFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETcifar1044.87(7)45.95(2)44.75(8)44.95(6)45.86(4)46.02(1)45.74(5)45.93(3)mnist3v898.31(7)98.64(5)97.47(8)98.48(6)98.70(2)98.71(1)98.68(4)98.68(3)mnist4v998.33(6)98.68(2)97.16(8)98.32(7)98.59(4)98.69(1)98.59(5)98.67(3)mnist96.10(7)96.47(3)94.30(8)96.18(6)96.47(4)96.49(1)96.46(5)96.48(2)isolet93.87(7)94.95(1)90.71(8)94.15(6)94.33(4)94.94(2)94.29(5)94.88(3)arcene71.04(4)72.56(1)66.16(8)68.56(7)71.52(3)72.24(2)69.44(6)70.00(5)breast265.86(6)66.16(1)65.54(8)65.59(7)66.13(2)65.91(5)65.94(4)66.08(3)madelon75.33(8)80.83(1)77.86(7)80.78(2)80.06(6)80.59(3)80.06(5)80.42(4)marti87.74(8)87.85(6)88.24(1)88.17(2)87.82(7)88.06(4)88.08(3)88.01(5)reged97.60(5)98.20(1)96.40(8)97.92(3)97.39(6)98.00(2)97.32(7)97.82(4)secom93.30(7)93.22(8)93.38(1)93.30(6)93.37(2)93.31(4)93.33(3)93.31(5)tis91.68(5)91.42(7)91.49(6)91.40(8)92.05(1)91.91(3)92.05(2)91.90(4)sido97.33(4)97.33(3)97.26(7)97.26(8)97.35(1)97.34(2)97.33(5)97.32(6)Avg.rank6.23073.15386.61535.69233.53842.38464.53843.8461Table8.5:Accuracyonlargerdatasets(in%).CD87654321RS-ETETRS-DTRP-ETP-DTRFP-ETRP-DTFigure8.2:Averageranksofallmethodsonlargerdatasets.8.3onmemory179RFETP-DTP-ETRS-DTRS-ETRP-DTRP-ETRF—1/5/78/3/22/6/50/6/70/5/80/6/70/6/7ET7/5/1—9/2/27/6/03/7/30/9/45/6/21/11/1P-DT2/3/82/2/9—1/5/70/3/100/3/101/3/90/4/9P-ET5/6/20/6/77/5/1—0/6/70/5/82/5/61/5/7RS-DT7/6/03/7/310/3/07/6/0—1/8/42/11/01/10/2RS-ET8/5/04/9/010/3/08/5/04/8/1—4/8/10/13/0RP-DT7/6/02/6/59/3/16/5/20/11/21/8/4—1/9/3RP-ET7/6/01/11/19/4/07/5/12/10/10/13/03/9/1—Table8.6:Pairwiset-testcomparisonsonlargerdatasets.8.2.4ConclusionsOverall,thisextensiveexperimentalstudyrevealsmanyinterestingresults.Theﬁrstandforemostresultisthatensemblesofrandomizedtreesnearlyalwaysbeatensemblesofstandarddecisiontrees.Asoff-the-shelfmethods,weadvocatethatensemblesofsuchtreesshouldbepreferredtoensemblesofdecisiontrees.Inparticular,theseresultsshowthatthewell-knownRandomForestalgorithmdoesnotcom-petewiththebestperformers.Farmoreimportanttoourconcernthough,thisstudyvalidatesourRPapproach.Buildingensembles(ofET)onrandompatchesofdataiscompetitiveintermsofaccu-racy.Overall,thereisnostrongstatisticalevidencethatthemethodperformslesswell,butthereisalsonoconclusiveevidencethatitsig-niﬁcantlyimprovesperformance.Yet,resultsshowthatRPisoftenasgoodastheverybestmethods.Regardingtheshapeoftherandompatches,thestrategybehindPasting(i.e.,αsfreeandαf=1.0)provedtobe(very)ineffectiveonmanydatasetswhiletheRandomSubspacealgorithm(i.e.,αs=1.0andαffree)alwaysrankedamongtheverybestperformers.Onaverage,RSindeedcameinsecondonthesmalldatasetsandinﬁrstonthelargerdatasets,whichtendstoindicatethatsamplingfeaturesiscrucialintermsofaccuracy.Asforpatchesoffreelyadjustablesize(i.e.,usingRP),theyshowedtobeslightlysensitivetooverﬁttingbutprovedtoremaincloselycompetitivewiththeverybestmethods.Inaddition,theseresultsalsosuggestthatsam-plingfeaturesglobally,onceandforall,priortotheconstructionofa(randomized)decisiontree,doesnotactuallyimpairperformance.Forinstance,RS-ETorRP-ETareindeednotstronglyworse,norbet-ter,thanET,inwhichcandidatesfeaturesarere-sampledlocallyateachnode.8.3onmemorySection8.2revealsthatbuildinganensembleofbaseestimatorsonrandompatches,insteadofthewholedata,isacompetitivestrategy.180ensemblesonrandompatchesInthecontextofbigdata,thatiswhenthesizeofthedatasetisfarbiggerthantheavailablememory,thissuggeststhatusingrandompartsofthedataoftheappropriatesizetobuildeachbaseestimatorwouldlikelyresultinanensemblewhichisactuallyasgoodasifthewholedatacouldhavebeenloadedandused.Formally,weassumeageneralframeworkwherethenumberofdataunitsthatcanbeloadedatonceintomemoryisconstrainedtobelowerthanagiventhresholdµmax.Notconsideringon-linealgo-rithmswithinthescopeofthisstudy,µmaxcanhencebeviewedasthetotalunitsofdataallowedtobeusedtobuildasinglebaseestimator.Inthecontextofoursamplingmethods,theamountofmemoryre-quiredforapatchisgivenby(αsN)(αfp)andthusconstrainingmem-orybyµmaxisequivalenttoconstrainingtherelativepatchsizeαsαftobelowerthanµ0max=µmax/(Np).Whilesimplistic1,thisframeworkhastheadvantageofclearlyaddressingoneofthemaindifﬁcultiesbehindbigdata,thatisthelackoffastmemory.Yet,itisalsorelevantinothercontexts,forexamplewhendataiscostlytoaccess(e.g.,onremotelocations)orwhenalgorithmsarerunonembeddedsystemswithstrongmemoryconstraints.InSection8.3.1,weﬁrststudytheeffectsofαsandαfontheac-curacyoftheresultingensembleandshowthatitisproblemandbaseestimatordependent.Second,weshowthatthememoryrequire-ments,i.e.,therelativesizeαsαfoftherandompatches,canoftenbedrasticallyreducedwithoutsigniﬁcantlydegradingtheperformanceoftheensemble(Section8.3.2).Third,becausethesensitivityoftheensembletoαsandαfisproblemandbaseestimatorspeciﬁc,weshowthatunderverystrongmemoryconstraintsadjustingbothpa-rametersatthesametime,asRPdoes,isnolongermerelyasgoodbutactuallysigniﬁcantlybetterthanotherensemblemethods(Section8.3.3).8.3.1SensitivitytoαsandαfLetusﬁrstconsiderandanalyzethetriplets{(αs,αf,AccL(αs,αf))|∀αs,αf}(8.1)forvariousproblems,whereAccL(αs,αf)istheaveragetestaccuracyofanensemblebuiltonrandompatchesofsizeαsαf(usingthesameprotocolaspreviously)onthedatasetL.AsFigure8.3illustratesforsixdatasets,thesurfacesdeﬁnedbythesepointsvarysigniﬁcantlyfromoneproblemtoanother.Weob-servedfourmaintrends.InFigures8.3a,and8.3b(resp.,8.3c),accu-racyincreaseswithαs(resp.,αf)whileadjustingαf(resp.,αs)hasnoorlimitedimpact.InFigure8.3d,thebeststrategyistoincreasebothαsandαf.Finally,inFigures8.3eand8.3f,thesurfacefeatures1e.g.,thequantityofmemoryusedbytheestimatoritselfisnottakenintoaccount.8.3onmemory181% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.580.600.620.640.660.680.700.72(a)arcene(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.320.340.360.380.400.420.44(b)cifar10(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.760.780.800.820.840.860.880.90(c)tis(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.600.620.640.660.680.700.72(a)arcene(RP-DT)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.340.360.380.400.420.44(b)cifar10(RP-DT)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.800.850.90(c)tis(RP-DT)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.550.600.650.700.750.80(d)madelon(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.700.750.800.850.900.95(e)isolet(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.750.800.850.900.95(f)mnist3vs8(RP-ET)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.550.600.650.700.750.80(d)madelon(RP-DT)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.700.750.800.850.90(e)isolet(RP-DT)% features0.20.40.60.8% samples0.20.40.60.8Accuracy0.750.800.850.900.95(f)mnist3vs8(RP-DT)Figure8.3:Learningsurfaces.plateaus,whichmeansthatbeyondsomethreshold,increasingαsorαfdoesnotyieldanysigniﬁcantimprovement.Interestingly,inmostofthecases,theoptimumcorrespondstoavalueαsαfmuchsmallerthan1.Thechoiceofthebaseestimatorsdoesnothaveastrongimpactontheaspectofthecurves(comparethe1stand3rdrowsofsub-ﬁguresinFigure8.3withthoseinthe2ndand4throws).TheonlydifferenceisthedecreaseoftheaccuracyofRP-DTwhenαsandαfgrowtowards1.0.Indeed,sincetheonlysourceofrandomizationinRP-DTispatchselection,ityieldsinthiscaseensemblesofidenticaltreesandthereforeamountstobuildingasingletreeonthewholedataset.Bycontrast,becauseoftheextra-randomizationofthesplit182ensemblesonrandompatchesthresholdsinET,thereistypicallynodropofaccuracyforRP-ETwhenαsandαfgrowto1.0.Overall,thisanalysissuggeststhatnotonlythebestpairαsαfde-pendsontheproblem,butalsothatthesensitivityoftheensembletochangestothesizeofarandompatchisbothproblemandbaseesti-matorspeciﬁc.Asaresult,theseobservationsadvocateforamethodthatcouldfavorαs,αforboth,anddosoappropriatelygiventhebaseestimator.8.3.2Memoryreduction,withoutsigniﬁcantlossWeproceedtostudyinthissectiontheactualsizeoftherandompatcheswhenthevaluesofαsandαfaretunedusinganindependentvalidationset.OurresultsaresummarizedinFigure8.4a.Eachellipsecorrespondstooneofthe29datasetsofourbenchmark,whosecenterislocatedat(αs,αf)(i.e.,theaverageparametervaluesoverthe50runs)andwhosesemi-axescorrespondtothestandarddeviationsofαsandαf.Anypointintheplotcorrespondstoapair(αs,αf)andthustoarelativeconsumptionµ0=αsαfofmemory.Toeasereadability,levelcurvesareplottedforµ0=0.01,0.1,...,0.9.Intherightpartoftheﬁgure,thehistogramcountsthenumberofdatasetssuchthatαs·αffallsinthecorrespondinglevelset.Figure8.4acorroboratesourpreviousdiscussion.Onsomedatasets,itisbettertofavorαswhileonsomeotherincreasingαfisabetterstrategy.Thevarioussizesoftheellipsesalsoconﬁrmthatthesensi-tivitytovariationsofαsandαfisindeedproblem-speciﬁc.Theﬁgurealsoclearlyhighlightsthefactthat,evenundernomemoryconstraint,theoptimalpatchesrarelyconsumethewholememory.Amajorityofellipsesindeedliebelowthelevelsetµ0=0.5andonlyacoupleofthemareaboveµ0=0.75.WithrespecttoETorRFforwhichthebaseestimatorsareallbuiltonthewholedataset,thismeansthaten-semblesofpatchesarenotonlyascompetitivebutalsolessmemorygreedy.Inaddition,theﬁgurealsopointsoutthedifferencebetweenRP-ETandRP-DTasdiscussedintheprevioussection.Toensurediversity,RP-DTisconstrainedtousesmallerpatchesthanRP-ET,henceexplainingwhytheellipsesinredareonaveragebelowthoseinblue.WhileRP-DTprovedtobeabitlesscompetitiveintermsofaccuracy,thisindicatesontheotherhandthatRP-DTmayactuallybemoreinterestingfromamemoryconsumptionpointofview.InSection8.3.1,weobservedplateausorverygentleslopesaroundtheoptimalpair(αs,αf).Fromamemorypointofview,thissuggeststhattherandompatchesarelikelytobereduciblewithoutactuallydegradingtheaccuracyoftheresultingensemble.Putotherwise,ourinterestistoﬁndthesmallestsizeαsαfsuchthattheaccuracyoftheresultingensembleisnotsigniﬁcantlyworsethananensemblebuiltwithoutsuchconstraint.Tothatend,westudytheextentatwhichthe8.3onmemory1830.00.20.40.60.81.0p_s0.00.20.40.60.81.0p_fRP-ETRP-DT051015#datasets(a)Originalpatches0.00.20.40.60.81.0p_s0.00.20.40.60.81.0p_f051015#datasets(b)ReducedpatchesFigure8.4:Optimalsizesoftherandompatchesonourbenchmark.constraintαsαf<µ0maxcanbestrengthenedwithoutanysigniﬁcantdropinaccuracy.Ifµ0maxcanbereducedsigniﬁcantlythenitwouldindeedmeanthatevenwhenonlysmallpartsofthedataareactuallyusedtobuildsinglebaseestimators,competitiveperformancecanstillbeachieved.Figure8.4bsummarizesourresults.Foralldatasets,µ0maxwassettothelowestvaluesuchthatitcannotbestatisticallydetectedthattheaverageaccuracyoftheresultingensembleisdifferentfromtheaverageaccuracyofanensemblebuiltwithnomemoryconstraint(atα=0.05).WithregardtoFigure8.4a,theshiftofmostellipsestolowermemorylevelsetsconﬁrmourﬁrstintuition.Inmanycases,thesizeoftherandompatchescanindeedbereduced,oftendrastically,withoutsigniﬁcantdecreaseofaccuracy.Formorethanhalfofthedatasets,memorycanindeedbedecreasedtoµ0=0.1orµ0=0.2.Inotherwords,buildingtreesonsmallpartsofthedata(i.e.,10%or20%oftheoriginaldataset)is,formorethanhalfofthedatasets,enoughtoreachcompetitiveaccuracy.Also,thesensitivitytoαsandαfisnowevenmorepatent.Someensemblesuseveryfewsamples(αs<0.1)butwithmanyfeatures,whileotherusesmanysampleswithfewfea-tures(αf<0.1).Again,fromamemorypointofview,RP-DTappearstobemoreinterestingthanRP-ET.Thememoryreductionislarger,asthehistogramindicates.Optimizedsplitsinthedecisiontreesmayindeedleadtoabetterexploitationofthedata,hencetoapotentiallylargerreductionofmemory.Inconclusion,whilenotdetectingsig-niﬁcantdifferencesinaccuracydoesnotallowtoconcludethattheperformancesaretrulysimilar,theseﬁguresatleastillustratethatmemoryrequirementscanbedrasticallyreducedwithoutapparentlossinaccuracy.184ensemblesonrandompatches8.3.3Memoryreduction,withlossTheprevioussectionhasshownthatthememoryconsumptioncanbereduceduptosomethresholdµ0maxwithnosigniﬁcantlossinaccuracy.Inthissectionwenowlookattheaccuracyoftheresultingensemblewhenµ0maxisfurtherdecreased.Wearguethatwithsevereconstraints,andbecausedatasetshavealladifferentsensitivity,itisevenmorecrucialtobetterexploitdataandthustoﬁndtherighttrade-offbetweenbothαsandαf,asonlyRPcan.Toillustrateourpoint,Figure8.5comparesfor6representativedatasetstheaccuracyofthemethodswithrespecttothememoryconstraintαsαf<µ0max.Aplainlineindicatesthatthegeneralizationerrorofthebestresultingensembleundermemoryconstraintµ0maxissigniﬁcantly(atα=0.05)worseonthetestsetsthanwhenthereisnoconstraint(i.e.,µ0max=1).Adottedlineindicatesthatonaverage,onthetestset,theensembleisnotsigniﬁcantlylessaccurate.Astheﬁgureshows,whenµ0maxislow,RP-basedensemblesoftenachievethebestaccuracy.Onlyonarcene(Figure8.5a),RSseemstobeabetterstrategy,suggestingsomeoverﬁttinginsettingαsinRP.Onall5otherexampledatasets,RPisequivalentorbetterthanRSandPforlowvaluesofµ0max,withthelargestgapsappearingoniso-let(Figure8.5e)andmnist3vs8(Figure8.5f).Asalreadyobservedintheprevioussection,althoughRP-DTisnotthebeststrategywhenmemoryisunconstrained,itscurvedominatesthecurveofRP-ETforsmallvaluesofµ0maxinFigures8.5b,8.5c,and8.5d.BecausesplitthresholdsarenotrandomizedinRP-DT,thismethodismoreresis-tantthanRP-ETtothestrongrandomizationinducedbyaverylowµ0maxthreshold.Forcomparison,Figure8.5alsofeaturesthelearningcurvesofbothETandRF(withKoptimizedonthevalidationset),inwhichthetreeshaveallbeenbuiltonthesametrainingsampleofµ0maxNin-stances,withallfeatures.Theseresultsarerepresentativeoftheuseofastraightforwardsub-samplingoftheinstancestohandlethemem-oryconstraint.Onalldatasets,thissettingyieldsverypoorperfor-mancewhenµ0maxislow.Buildingbaseestimatorsonre-sampledran-dompatchesthusbringsaclearadvantagetoRP,RSandPandhenceconﬁrmstheconclusionsofBasilicoetal.[2011]whoshowedthatus-ingmoredataindeedproducesmoreaccuratemodelsthanlearningfromasinglesub-sample.ThislatterexperimentfurthermoreshowsthatthegoodperformancesofRPcannotbetriviallyattributedtothefactthatourdatasetscontainsomanyinstancesthatonlyprocess-ingasub-sampleofthemwouldbeenough.Onmostproblems,theslopesofthelearningcurvesofRFandETindeedsuggestthatcon-vergencehasnotyetbeenreachedonthesedatasets.Yet,importantimprovementaregainedbysub-samplingrandompatches.Contrarytointuition,italsodoesnotappearthatthebiggerthedatasets,the8.3onmemory1850.00.20.40.60.81.0Memoryconstraint0.30.40.50.60.70.80.9Accuracy(a)arcene0.00.10.20.30.40.5Memoryconstraint0.390.400.410.420.430.440.450.46Accuracy(b)cifar100.00.10.20.30.40.5Memoryconstraint0.840.850.860.870.880.890.900.910.92Accuracy(c)tis0.00.20.40.60.81.0Memoryconstraint0.450.500.550.600.650.700.750.800.85Accuracy(d)madelon0.00.10.20.30.40.5Memoryconstraint0.800.850.900.95Accuracy(e)isolet0.00.10.20.30.40.5Memoryconstraint0.9600.9650.9700.9750.9800.9850.990AccuracyRP-ETRP-DTRS-ETRS-DTP-ETP-DTETRF(f)mnist3vs8Figure8.5:Accuracyundermemoryconstraint.186ensemblesonrandompatcheslowerµ0maxcanbereducedwithoutlossofaccuracy.Indeed,wefoundnoconclusivecorrelationbetweenthesizeNpofthedatasetandtheminimumvalueofµ0maxtoreachgoodperformance2.Overall,theseresultsthusindicatethatbuildinganensembleonrandompatchesisnotonlyagoodstrategywhendataisabundantandredundantbutalsothatitworksevenforscarcedatasetswithlimitedinformationregardingtheproblem.8.3.4ConclusionsWehaveshowninthissectionthatthememoryrequirementsofsam-plingbasedensemblesareintrinsicallylow.Better,wehaveshownthattheycanoftenbedrasticallydecreasedwithoutsigniﬁcantlossinaccuracy.Whenthesizeofthedatasetisfarbiggerthantheavail-ablememory,wehavealsodemonstratedthatsamplingdataalongbothsamplesandfeatures,asRPdoes,notonlycompeteswithotherensemblealgorithmsbutalsosigniﬁcantlyimprovestheaccuracyoftheresultingensemble.Italsobringsasigniﬁcantimprovementoverastraightforwardsub-samplingoftheinstances.8.4overallconclusionsThemaincontributionofthisworkistoexploreanewframeworkforsupervisedlearninginthecontextofverystrongmemoryconstraintsor,equivalently,verylargedatasets.Toaddresssuchproblems,weproposedtheRandomPatchesensemblemethodthatbuildseachin-dividualmodeloftheensemblefromarandompatchofthedatasetobtainedbydrawingrandomsubsetsofbothsamplesandfeaturesfromthewholedataset.Throughextensiveexperimentswithtree-basedestimators,wehaveshownthatthisstrategyworksaswellasotherpopularrandomizationschemesintermsofaccuracy(Sec-tion8.2),atthesametimereducesverysigniﬁcantlythememoryre-quirementstobuildeachindividualmodel(Section8.3.2),and,givenitsﬂexibility,attainssigniﬁcantlybetteraccuracythanothermethodswhenmemoryisseverelyconstrained(Section8.3.3).Sinceallmod-elsarebuiltindependentlyofeachother,theapproachisfurthermoretrivialtoparallelize.Allinall,webelievethattheparadigmofourmethodhighlightsaverypromisingdirectionofresearchtoaddresssupervisedlearningonbigdata.Thereremainseveralopenquestionsandlimitationstoourap-proachthatwewouldliketoaddressinthefuture.First,thisstudymotivatesourinterestinexperimentingwithtrulylarge-scaleprob-lems(ofgiga-scaleandhigher).SinceRPalreadyappearsadvanta-geousforsmalltomediumdatasets,thepotentialbeneﬁtsonverylarge-scaledataindeedlookverypromising.2Spearman’srankcorrelationcoefﬁcientis-0.0354(p−value=0.8550).8.4overallconclusions187Second,theconclusionsdrawninsections8.2and8.3areallbasedontheoptimalvaluesoftheparametersαsandαftunedthroughanexhaustivegridsearchonthevalidationset.Ouranalysisdidnotaccountforthememoryandtimerequiredfortuningthesetwopa-rameters.Inpractice,hyper-parametertuningcannotbeavoidedaswehaveshownthattheoptimaltrade-offbetweenαfandαswasproblemdependent.Itwouldthereforebeinterestingtodesignanef-ﬁcientstrategytoautomaticallyﬁndandadjustthevaluesofαsandαf,takingintoaccounttheglobalmemoryconstraint.Oursimplis-ticframeworkalsoonlyaccountsforthememoryrequiredtostorethetrainingsetinmemoryandnotforthetotalmemoryrequiredtoactuallybuildtheensemble.Wehaveonlyexploreduniformsamplingofpatchesofﬁxedsizeinourexperiments.InthecontextofthePastingapproach,Breimanproposedaniterativeinstanceweightingschemethatprovedtobemoreefﬁcientthanuniformsampling[Breiman,1999].Itwouldbein-terestingtoextendthisapproachwhensamplingbothinstancesandfeatures.Yet,parallelizationwouldnotbetrivialanymore,althoughprobablystillpossibleinthelineoftheworkin[Chawlaetal.,2004].Finally,ouranalysisofRPismostlyempirical.Inthefuture,wewouldliketostrengthentheseresultswithamoretheoreticalanal-ysis.Astartingpointcouldbetheworkin[Zinkevichetal.,2010]thatstudiesaschemesimilartothePastingmethodappliedtolinearmodelstrainedthroughparallelstochasticgradientdescent.Theex-tensionofthisworktononparametrictree-basedestimatorsdoesnotappeartrivialhowever,sincetheselatterarenotwellcharacterizedtheoretically.Inretrospect,latestresults[Scornetetal.,2014]regard-ingtheconsistencyofrandomforestscouldcertainlyalsobeusedtomotivatetheuseofrandomsubsetsofsamples.Similarly,theoret-icalresultsfromChapter6(Section6.4.2)alsoindicatethattheuseofrandomsubsetsoffeaturesdoesnotsystematicallydegradeperfor-mance.9CONCLUSIONSByandlarge,machinelearningremainsanopenﬁeldofresearchforwhichmanyquestionsarestillleftunanswered,evenregardingwell-establishedmethods.Inthisdissertation,wehaverevisiteddecisiontreesandrandomforests,consistentlycallingintoquestioneachandeverypartofthesealgorithms,inordertoshednewlightontheirlearningcapabilities,innerworkingsandinterpretability.InPartiofthiswork,welaidoutthedecisiontreesandrandomforestsmethodologyinthecontextofclassiﬁcationandregressiontasks.Ourtreatmentﬁrstconsideredtheinductionofindividualdeci-siontreesandputthemintoauniﬁedandcomposableframework.Inparticular,ouranalysisreviewedassignmentrules,stoppingcriteriaandsplittingrules,theoreticallymotivatingtheirdesignandpurposewheneverpossible.Wethenproceededwithasystematicstudyofrandomizedensemblemethodswithinthebias-varianceframework.Weestablishedthatvariancedependsonthecorrelationbetweenin-dividualtreepredictions,therebyshowingwhyrandomizationactsasamechanismforreducingthegeneralizationerrorofanensem-ble.Randomforestanditsvariantswerethenpresentedwithintheframeworkpreviouslyintroduced,andtheirpropertiesandfeaturesdiscussedandreviewed.Ourcontributionsfollowedwithanoriginaltimeandspacecomplexityanalysisofrandomforests,henceshow-ingtheirgoodcomputationalperformanceandscalabilitytolargerproblems.Finally,theﬁrstpartofthisworkconcludedwithanin-depthdiscussionofimplementationdetailsofrandomforests,high-lightinganddiscussingconsiderationsthatarecritical,yeteasilyover-looked,forguaranteeinggoodcomputationalperformance.Whilenotdirectlyapparentwithinthismanuscript,thisdiscussionalsounder-linedourcontributionsintermsofsoftware,withintheopensourceSckit-Learnlibrary.Asopenscienceandreproducibilityconcernsaregainingmomentum,weindeedbelievethatgoodqualitysoftwareshouldbeanintegrativepart,acknowledgedforitsownvalueandimpact,ofanymodernscientiﬁcresearchactivity.Partiiofthisdissertationanalyzedanddiscussedtheinterpretabil-ityofrandomforestsintheeyesofvariableimportancemeasures.ThecoreofourcontributionsrestsinthetheoreticalcharacterizationoftheMeanDecreaseofImpurityvariableimportancemeasure,fromwhichwehavethenprovedandderivedsomeofitspropertiesinthecaseofmultiwaytotallyrandomizedtreesandinasymptoticcondi-tions.Inparticular,wehaveshownthatvariableimportancesofferathree-leveldecompositionoftheinformationjointlyprovidedbythe189190conclusionsinputvariablesabouttheoutput,accountingforallpossibleinterac-tiontermsinafairandexhaustiveway.Moreinterestingly,wehavealsoshownthatvariableimportancesonlydependonrelevantvari-ablesandthattheimportanceofirrelevantvariablesisstrictlyequaltozero,therebymakingimportancesasoundandappropriatecrite-rionforassessingtheusefulnessofvariables.Inconsequenceofthiswork,ouranalysisthendemonstratedthatvariableimportancesascomputedfromnon-totallyrandomizedtrees(e.g.,standardRandomForestorExtremelyRandomizedTrees)sufferfromacombinationofdefects,duetomaskingeffects,misestimationsofnodeimpurityorduetothebinarystructureofdecisiontrees.Overall,webelievethatouranalysisshouldbringhelpfulinsightsinawiderangeofappli-cations,bysheddingnewlightonvariableimportances.Inparticular,weadvisetocomplementtheirinterpretationandanalysiswithasys-tematicdecompositionoftheirterms,inordertobetterunderstandwhyvariablesare(orarenot)important.Thispreliminaryworkunveilsvariousdirectionsoffuturework,bothfromatheoreticalandpracticalpointofview.Toourbelief,themostinterestingtheoreticalopenquestionwouldbethecharacteriza-tionofthedistributionofvariableimportancesintheﬁnitesetting.Suchacharacterizationwouldindeedallowtomorereliablydistin-guishirrelevantvariables(whoseimportancesarepositiveintheﬁ-nitecase)fromrelevantvariables.Anotherinterestingdirectionoffutureworkwouldbetoderiveapropercharacterizationofvariableimportancesinthecaseofbinarytrees–evenifwebelieve,aspointedoutearlier,thatvariableimportancesderivedfromsuchensemblesmayinfactnotbeasappropriateasdesired.Fromamorepracticalpointofview,thisstudyalsocallsforare-analysisofpreviousempir-icalstudies.Weindeedbelievethatvariableimportancesalongwiththeirdecompositionshouldyieldnewinsightsinmanycases,pro-vidingabetterunderstandingoftheinteractionsbetweentheinputvariablesandtheoutput,butalsobetweentheinputvariablesthem-selves.Again,werecommendmultiwaytotallyrandomizedtreestomitigatesourcesofbiasasmuchaspossible.Finally,Partiiiaddressedlimitationsofrandomforestsinthecon-textoflargedatasets.Throughextensiveexperiments,wehaveshownthatsubsamplingeithersamples,featuresorbothsimultaneouslypro-videsonparperformancewhileloweringatthesametimethemem-oryrequirements.Overallthisparadigmhighlightsanintriguingprac-ticalfact:thereisoftennoneedtobuildsinglemodelsoverim-menselylargedatasets.Goodperformancecanoftenmoresimplybeachievedbybuildingmodelsonsmallrandompartsofthedataandthencombiningthemallinanensemble,therebyavoidingallpracti-calandcomputationalburdensofmakinglargedataﬁtintomemory.Again,thisworkraisesinterestingquestionsoffurtherwork.Fromatheoreticalpointofview,onewouldbetoidentifythestatisticalconclusions191propertiesinthelearningproblemthatarenecessaryforguarantee-ingsubsamplingstrategiestowork.Inparticular,inwhichcasesisitbettertosubsampleexamplesratherthanfeatures?Fromamorepracticalpointofview,otherdirectionsofresearchalsoincludethestudyofsmartersamplingstrategiesortheempiricalveriﬁcationthatconclusionsextendtonontree-basedmethods.Overall,thisthesiscallsforapermanentre-assessmentofmachinelearningmethodsandalgorithms.Itisonlythroughabetterunder-standingoftheirmechanismsthatalgorithmswilladvanceinacon-sistentandreliableway.Alwaysseekforthewhatandwhy.Inconclu-sion,machinelearningshouldnotbeconsideredasablack-boxtool,butasamethodology,witharationalthoughtprocessthatisentirelydependentontheproblemwearetryingtosolve.PartIVAPPENDIXANOTATIONSAAsupervisedlearningalgorithm.................12A(θ,L)ThemodelϕLproducedbyalgorithmAoverLandhyper-parametersθ..............................17αsTheproportionofsamplesinarandompatch...170αfTheproportionoffeaturesinarandompatch...170blThel-thvalueofacategoricalvariable...........39BAsubsetB⊆Vofvariables.....................128ckThek-thclass....................................11CkpThenumberofk-combinationsfromasetofpele-ments...........................................129C(N)ThetimecomplexityforsplittingNsamples.....88EExpectation.........................................E(ϕL,L0)TheaveragepredictionerrorofϕLoverL0.......13Err(ϕL)ThegeneralizationerrorofϕL................12,55H(X)TheShannonentropyofX......................126H(X|Y)TheShannonentropyofXconditionaltoY......126HThespaceofcandidatemodels...................16i(t)Theimpurityofnodet.......................30,40iR(t)Theimpurityofnodetbasedonthelocalresubstitu-tionestimate..................................41,46iH(t)Theentropyimpurityofnodet..................45iG(t)TheGiniimpurityofnodet......................45∆i(s,t)Theimpuritydecreaseofthesplitsatnodet....30I(X;Y)ThemutualinformationbetweenXandY.......126Imp(Xj)ThevariableimportanceofXj..............124,125JThenumberofclasses............................11KThenumberoffoldsincross-validation..........14Thenumberofinputvariablesdrawnateachnodeforﬁndingasplit................................71K(xi,xj)Thekernelofxiandxj.......................22,79LAlossfunction...................................12Thenumberofvaluesofacategoricalvariable...39LAlearningset(X,y)..............................10LmThem-thbootstrapreplicateofL................70195196notationsLtThesubsetofnodesamplesfallingintonodet...30MThenumberofbasemodelsinanensemble......62µL,θm(x)ThemeanpredictionatX=xofϕL,θm...........64NThenumberofinputsamples....................10NtThenumberofnodesamplesinnodet...........30NctThenumberofnodesamplesofclasscinnodet.32ΩTheuniverse,orpopulation,fromwhichcasesaresampled...........................................9pThenumberofinputvariables....................9pLTheproportionofnodesamplesgoingtotL......30pRTheproportionofnodesamplesgoingtotR.....30p(t)Theestimatedprobabilityp(X∈Xt)=NtN.......33p(c|t)Theempiricalprobabilityestimatep(Y=c|X∈Xt)=NctNtofclasscatnodet...........................33bpLAnempiricalprobabilityestimatecomputedfromthelearningsetL.....................................59P(X,Y)Thejointprobabilitydistributionoftheinputvari-ablesX=(X1,...,Xp)andtheoutputvariableY.11Pk(V)ThesetofsubsetsofVofsizek.................128ϕAmodelorfunctionX7→Y......................10Asingledecisiontree............................27eϕThesetofterminalnodesinϕ...................32ϕ(x)Thepredictionofϕforthesamplex.............10ϕLAmodelbuiltfromL............................12ϕL,θAmodelbuiltfromLwithrandomseedθ.......61ϕBABayesmodel...................................15ψL,θ1,...,θMAnensembleofMmodelsbuiltfromLandrandomseedsθ1,...,θM.................................62QAsetQ⊆Sofsplitsofrestrictedstructure....27,38Q(Xj)ThesetQ(Xj)⊆QofunivariatebinarysplitsthatcanbedeﬁnedonvariableXj.....................38,39ρ(x)ThecorrelationcoefﬁcientbetweenthepredictionsatX=xoftworandomizedmodels................65sAsplit........................................27,37s∗Thebestsplit.................................30,39s∗jThebestbinarysplitdeﬁnedonvariableXj...30,39svjThebinarysplit({x|xj6v},{x>v})deﬁnedonvari-ableXjwithdiscretizationthresholdv...........38stThesplitlabelingnodet.........................27˜sjtThebestsurrogatesplitforstdeﬁnedfromXj..124notations197SThesetofallpossiblesplitss.....................38σ2L,θm(x)ThepredictionvarianceatX=xofϕL,θm........64tAnodeinadecisiontree.........................27tLTheleftchildofnodet.......................30,37tRTherightchildofnodet......................30,37θAvectorofhyper-parametervalues..............17Arandomseed...................................62θ∗Theoptimalhyper-parameters...................17bθ∗Theapproximatelyoptimalhyper-parameters....17θmTheseedofthem-thmodelinanensemble......62vAdiscretizationthresholdinabinarysplit.......38vkThek-thvalueofanorderedvariable,whennodesamplesareinsortedorder......................48v0kThemid-cutpointbetweenvkandvk+1..........48VTheset{X1,...,Xp}ofinputvariables...........127V−jV\{Xj}..........................................128VVariance............................................xAcase,sampleorinputvector(x1,...,xp)........9xiThei-thinputsampleinL.......................10xjThevalueofvariableXjforthesamplex..........9XTheN×pmatrixrepresentingthevaluesofallNsamplesforallpinputvariables.................10XjThej-thinputvariableorfeature..............9,10XTherandomvector(X1,...,Xp)..................11XjThedomainorspaceofvariableXj................9XTheinputspaceX1×···×Xp.....................9XtThesubspaceXt⊆Xrepresentedbynodet......27yAvalueoftheoutputvariableY...................9bytThevaluelabellingnodet........................28by∗tTheoptimalvaluelabellingnodet...............32yTheoutputvalues(y1,...,yN)...................10YTheoutputorresponsevariableY.................9YThedomainorspaceofvariableY.................9BREFERENCESJ.Adamo.Fuzzydecisiontrees.Fuzzysetsandsystems,4(3):207–219,1980.Y.Amit,D.Geman,andK.Wilder.Jointinductionofshapefeaturesandtreeclassiﬁers.PatternAnalysisandMachineIntelligence,IEEETransactionson,19(11):1300–1305,1997.I.Arel,D.Rose,andT.Karnowski.Deepmachinelearning-anewfrontierinartiﬁcialintelligenceresearch[researchfrontier].Compu-tationalIntelligenceMagazine,IEEE,5(4):13–18,2010.S.ArlotandA.Celisse.Asurveyofcross-validationproceduresformodelselection.StatisticsSurveys,4:40–79,2010.J.Basilico,M.Munson,T.Kolda,K.Dixon,andW.Kegelmeyer.Comet:Arecipeforlearningandusinglargeensemblesonmassivedata.InDataMining(ICDM),2011IEEE11thInternationalConferenceon,pages41–50.IEEE,2011.S.Behnel,R.Bradshaw,C.Citro,L.Dalcin,D.S.Seljebotn,andK.Smith.Cython:thebestofbothworlds.CiSE,13(2):31–39,2011.Y.Bengio,A.Courville,andP.Vincent.Representationlearning:Areviewandnewperspectives.2013.J.L.BentleyandM.D.McIlroy.Engineeringasortfunction.Software:PracticeandExperience,23(11):1249–1265,1993.J.L.Bentley,D.Haken,andJ.B.Saxe.Ageneralmethodforsolvingdivide-and-conquerrecurrences.ACMSIGACTNews,12(3):36–44,1980.J.BergstraandY.Bengio.Randomsearchforhyper-parameteropti-mization.TheJournalofMachineLearningResearch,13:281–305,2012.G.Biau.Analysisofarandomforestsmodel.TheJournalofMachineLearningResearch,98888:1063–1095,2012.G.Biau,L.Devroye,andG.Lugosi.Consistencyofrandomforestsandotheraveragingclassiﬁers.TheJournalofMachineLearningRe-search,9:2015–2033,2008.C.BishopandN.Nasrabadi.Patternrecognitionandmachinelearning,volume1.springerNewYork,2006.199200H.Blockeel,L.DeRaedt,andJ.Ramon.Top-downinductionofclus-teringtrees.arXivpreprintcs/0011032,2000.A.Blumer,A.Ehrenfeucht,D.Haussler,andM.K.Warmuth.Occam’srazor.Informationprocessingletters,24(6):377–380,1987.B.E.Boser,I.M.Guyon,andV.N.Vapnik.Atrainingalgorithmforoptimalmarginclassiﬁers.InProceedingsoftheﬁfthannualworkshoponComputationallearningtheory,pages144–152.ACM,1992.V.Botta.Awalkintorandomforests:adaptationandapplicationtogenome-wideassociationstudies.2013.V.Botta,G.Louppe,P.Geurts,andL.Wehenkel.Exploitingsnpcorre-lationswithinrandomforestforgenome-wideassociationstudies.PloSone,9(4):e93379,2014.L.BottouandO.Bousquet.Thetradeoffsoflarge-scalelearning.Op-timizationforMachineLearning,page351,2011.A.-L.Boulesteix,S.Janitza,J.Kruppa,andI.R.König.Overviewofrandomforestmethodologyandpracticalguidancewithempha-sisoncomputationalbiologyandbioinformatics.WileyInterdisci-plinaryReviews:DataMiningandKnowledgeDiscovery,2(6):493–507,2012.G.BradskiandA.Kaehler.LearningOpenCV:ComputervisionwiththeOpenCVlibrary.O’ReillyMedia,Inc.,2008.L.Breiman.Parsimoniousbinaryclassiﬁcationtrees.Preliminaryre-port.SantaMonica,Calif.:TechnologyServiceCorporation,1978a.L.Breiman.Descriptionofchlorinetreedevelopmentanduse.Techni-calreport,TechnicalReport,TechnologyServiceCorporation,SantaMonica,CA,1978b.L.Breiman.Baggingpredictors.1994.L.Breiman.Bias,variance,andarcingclassiﬁers.1996.L.Breiman.Pastingsmallvotesforclassiﬁcationinlargedatabasesandon-line.MachineLearning,36(1-2):85–103,1999.L.Breiman.Someinﬁnitytheoryforpredictorensembles.Technicalreport,TechnicalReport579,StatisticsDept.UCB,2000.L.Breiman.RandomForests.Machinelearning,45(1):5–32,2001.L.Breiman.Manualonsettingup,using,andunderstandingrandomforestsv3.1.StatisticsDepartmentUniversityofCaliforniaBerkeley,CA,USA,2002.201L.Breiman.Consistencyforasimplemodelofrandomforests.Tech-nicalreport,UCBerkeley,2004.L.Breiman,J.H.Friedman,R.A.Olshen,andC.J.Stone.Classiﬁcationandregressiontrees.1984.A.E.Bryson.Appliedoptimalcontrol:optimization,estimationandcontrol.CRCPress,1975.L.Buitinck,G.Louppe,M.Blondel,F.Pedregosa,A.Mueller,O.Grisel,V.Niculae,P.Prettenhofer,A.Gramfort,J.Grobler,etal.APIdesignformachinelearningsoftware:experiencesfromthescikit-learnproject.arXivpreprintarXiv:1309.0238,2013.J.S.Chang,R.-F.Yeh,J.K.Wiencke,J.L.Wiemels,I.Smirnov,A.R.Pico,T.Tihan,J.Patoka,R.Miike,J.D.Sison,etal.Pathwayanaly-sisofsingle-nucleotidepolymorphismspotentiallyassociatedwithglioblastomamultiformesusceptibilityusingrandomforests.Can-cerEpidemiologyBiomarkers&Prevention,17(6):1368–1373,2008.S.Chatrchyan,V.Khachatryan,A.Sirunyan,A.Tumasyan,W.Adam,E.Aguilo,T.Bergauer,M.Dragicevic,J.Erö,C.Fabjan,etal.Obser-vationofanewbosonatamassof125GeVwiththeCMSexperi-mentattheLHC.PhysicsLettersB,2012.N.V.Chawla,L.O.Hall,K.W.Bowyer,andW.P.Kegelmeyer.Learn-ingensemblesfrombites:Ascalableandaccurateapproach.J.Mach.Learn.Res.,5:421–451,Dec.2004.ISSN1532-4435.T.H.Cormen,C.E.Leiserson,etal.Introductiontoalgorithms,vol-ume2.2001.C.CortesandV.Vapnik.Support-vectornetworks.Machinelearning,20(3):273–297,1995.T.CoverandP.Hart.Nearestneighborpatternclassiﬁcation.Informa-tionTheory,IEEETransactionson,13(1):21–27,1967.T.M.CoverandJ.A.Thomas.Elementsofinformationtheory.Wiley-interscience,2012.A.CriminisiandJ.Shotton.DecisionForestsforComputerVisionandMedicalImageAnalysis.Springer,2013.A.CutlerandG.Zhao.Pert-perfectrandomtreeensembles.Comput-ingScienceandStatistics,33:490–497,2001.R.L.DeMántaras.Adistance-basedattributeselectionmeasurefordecisiontreeinduction.Machinelearning,6(1):81–92,1991.J.Demsar.Statisticalcomparisonsofclassiﬁersovermultipledatasets.TheJournalofMachineLearningResearch,7:1–30,2006.202J.Demšar,T.Curk,A.Erjavec,ˇCrtGorup,T.Hoˇcevar,M.Miluti-noviˇc,M.Možina,M.Polajnar,M.Toplak,A.Stariˇc,M.Štajdohar,L.Umek,L.Žagar,J.Žbontar,M.Žitnik,andB.Zupan.Orange:Dataminingtoolboxinpython.JournalofMachineLearningResearch,14:2349–2353,2013.M.Denil,D.Matheson,andN.DeFreitas.Narrowingthegap:Ran-domforestsintheoryandinpractice.arXivpreprintarXiv:1310.1415,2013a.M.Denil,D.Matheson,andN.deFreitas.Consistencyofonlinerandomforests.arXivpreprintarXiv:1302.4853,2013b.L.Devroye,L.Gyorﬁ,andG.Lugosi.Aprobabilistictheoryofpatternrecognition,1996.T.G.Dietterich.Anexperimentalcomparisonofthreemethodsforconstructingensemblesofdecisiontrees:Bagging,boosting,andrandomization.Machinelearning,40(2):139–157,2000a.T.G.Dietterich.Ensemblemethodsinmachinelearning.InMultipleclassiﬁersystems,pages1–15.Springer,2000b.T.G.DietterichandE.B.Kong.Machinelearningbias,statisticalbias,andstatisticalvarianceofdecisiontreealgorithms.ML-95,255,1995.P.Domingos.Auniﬁedbias-variancedecompositionforzero-oneandsquaredloss.AAAI/IAAI,2000:564–569,2000.R.Duda,P.Hart,andD.Stork.Patternclassiﬁcation.JohnWiley&Sons,2012.B.Efron.Bootstrapmethods:anotherlookatthejackknife.TheannalsofStatistics,pages1–26,1979.D.Ferrucci,E.Brown,J.Chu-Carroll,J.Fan,D.Gondek,A.Kalyanpur,A.Lally,J.W.Murdock,E.Nyberg,J.Prager,etal.BuildingWatson:AnoverviewoftheDeepQAproject.AImagazine,31(3):59–79,2010.W.D.Fisher.Ongroupingformaximumhomogeneity.JournaloftheAmericanStatisticalAssociation,53(284):789–798,1958.E.FixandJ.L.Hodges.Disciminatoryanalysis—nonparametricdis-crimination;consistencyproperties.TechnicalReportProject21-49-004,ReportNo.4,USAFSchoolofAviationMedicine,1951.A.FrankandA.Asuncion.UCImachinelearningrepository,2010.URLhttp://archive.ics.uci.edu/ml.Y.FreundandR.E.Schapire.Adesicion-theoreticgeneralizationofon-linelearningandanapplicationtoboosting.InComputationallearningtheory,pages23–37.Springer,1995.203J.H.Friedman.Arecursivepartitioningdecisionrulefornonparamet-ricclassiﬁcation.Computers,IEEETransactionson,100(4):404–408,1977.J.H.Friedman.Atree-structuredapproachtononparametricmul-tipleregression.InSmoothingtechniquesforcurveestimation,pages5–22.Springer,1979.J.H.Friedman.Multivariateadaptiveregressionsplines.Theannalsofstatistics,pages1–67,1991.J.H.Friedman.Onbias,variance,0/1loss,andthecurse-of-dimensionality.Dataminingandknowledgediscovery,1(1):55–77,1997.J.H.Friedman.Greedyfunctionapproximation:agradientboostingmachine.AnnalsofStatistics,pages1189–1232,2001.J.Gama.Functionaltrees.MachineLearning,55(3):219–250,2004.S.Geman,E.Bienenstock,andR.Doursat.Neuralnetworksandthebias/variancedilemma.Neuralcomputation,4(1):1–58,1992.R.Genuer,J.-M.Poggi,andC.Tuleau-Malot.Variableselectionusingrandomforests.PatternRecognitionLetters,31(14):2225–2236,2010.P.Geurts.Contributionstodecisiontreeinduction:bias/variancetradeoffandtimeseriesclassiﬁcation.2002.P.Geurts.Biasvsvariancedecompositionforregressionandclassi-ﬁcation.InDataMiningandKnowledgeDiscoveryHandbook,pages749–763.Springer,2005.P.GeurtsandG.Louppe.Learningtorankwithextremelyrandom-izedtrees.InJMLR:WorkshopandConferenceProceedings,volume14,2011.P.GeurtsandL.Wehenkel.Investigationandreductionofdiscretiza-tionvarianceindecisiontreeinduction.InMachineLearning:ECML2000,pages162–170.Springer,2000.P.Geurts,D.Ernst,andL.Wehenkel.Extremelyrandomizedtrees.MachineLearning,63(1):3–42,2006a.P.Geurts,L.Wehenkel,andF.d’AlchéBuc.Kernelizingtheoutputoftree-basedmethods.InProceedingsofthe23rdinternationalconferenceonMachinelearning,pages345–352.Acm,2006b.P.Geurts,A.Irrthum,andL.Wehenkel.Supervisedlearningwithdecisiontree-basedmethodsincomputationalandsystemsbiology.MolecularBiosystems,5(12):1593–1605,2009.204M.Gillo.Maid:Ahoneywell600programforanautomatisedsurveyanalysis.BehavioralScience,17:251–252,1972.C.Gini.Variabilitàemutabilità.ReprintedinMemoriedimetodolog-icastatistica(Ed.PizettiE,Salvemini,T).Rome:LibreriaErediVirgilioVeschi,1,1912.B.Goebel,Z.Dawy,J.Hagenauer,andJ.C.Mueller.Anapproxima-tiontothedistributionofﬁnitesamplesizemutualinformationes-timates.InCommunications,2005.ICC2005.2005IEEEInternationalConferenceon,volume2,pages1102–1106.IEEE,2005.M.T.GoodrichandR.Tamassia.AlgorithmDesign:Foundation,Analy-sisandInternetExamples.JohnWiley&Sons,2006.I.Guyon.Ascalinglawforthevalidation-settraining-setsizeratio.AT&TBellLaboratories,1997.I.GuyonandA.Elisseeff.Anintroductiontovariableandfeaturese-lection.TheJournalofMachineLearningResearch,3:1157–1182,2003.I.Guyon,J.Weston,S.Barnhill,andV.Vapnik.Geneselectionforcan-cerclassiﬁcationusingsupportvectormachines.Machinelearning,46(1-3):389–422,2002.M.Hall,E.Frank,G.Holmes,B.Pfahringer,P.Reutemann,andI.H.Witten.TheWEKAdataminingsoftware:anupdate.ACMSIGKDDExplorationsNewsletter,11(1):10–18,2009.T.Hastie,R.Tibshirani,J.Friedman,andJ.Franklin.Theelementsofstatisticallearning:datamining,inferenceandprediction.TheMathematicalIntelligencer,27(2):83–85,2005.D.Heath,S.Kasif,andS.Salzberg.Inductionofobliquedecisiontrees.InIJCAI,pages1002–1007.Citeseer,1993.G.Hinton.Learningmultiplelayersofrepresentation.Trendsincog-nitivesciences,11(10):428–434,2007.T.K.Ho.Therandomsubspacemethodforconstructingdecisionforests.PatternAnalysisandMachineIntelligence,IEEETransactionson,20(8):832–844,1998.A.Hoecker,P.Speckmayer,J.Stelzer,J.Therhaag,E.vonToerne,H.Voss,M.Backes,T.Carli,O.Cohen,A.Christov,etal.Tmva-toolkitformultivariatedataanalysis.arXivpreprintphysics/0703039,2007.T.Hothorn,K.Hornik,andA.Zeileis.Unbiasedrecursivepartition-ing:Aconditionalinferenceframework.JournalofComputationalandGraphicalStatistics,15(3):651–674,2006.205J.D.Hunter.Matplotlib:A2dgraphicsenvironment.CiSE,pages90–95,2007.V.A.Huynh-Thu,A.Irrthum,L.Wehenkel,P.Geurts,etal.Inferringregulatorynetworksfromexpressiondatausingtree-basedmeth-ods.PloSone,5(9):e12776,2010.V.A.Huynh-Thu,Y.Saeys,L.Wehenkel,P.Geurts,etal.Statisticalinterpretationofmachinelearning-basedfeatureimportancescoresforbiomarkerdiscovery.Bioinformatics,28(13):1766–1774,2012.L.HyaﬁlandR.L.Rivest.Constructingoptimalbinarydecisiontreesisnp-complete.InformationProcessingLetters,5(1):15–17,1976.H.Ishwaran.Variableimportanceinbinaryregressiontreesandforests.ElectronicJournalofStatistics,1:519–537,2007.H.IshwaranandU.B.Kogalur.Consistencyofrandomsurvivalforests.Statistics&probabilityletters,80(13):1056–1064,2010.G.M.James.Varianceandbiasforgenerallossfunctions.MachineLearning,51(2):115–135,2003.H.KimandW.-Y.Loh.Classiﬁcationtreeswithunbiasedmultiwaysplits.JournaloftheAmericanStatisticalAssociation,96(454),2001.K.KiraandL.A.Rendell.Thefeatureselectionproblem:Traditionalmethodsandanewalgorithm.InAAAI,pages129–134,1992.D.Knuth.TheArtofComputerProgramming:Fundamentalalgorithms.TheArtofComputerProgramming.Addison-Wesley,1968.D.E.Knuth.Twonotesonnotation.TheAmericanMathematicalMonthly,99(5):403–422,1992.D.Kocev,C.Vens,J.Struyf,andS.Džeroski.Ensemblesofmulti-objectivedecisiontrees.Springer,2007.R.KohaviandG.H.John.Wrappersforfeaturesubsetselection.Artiﬁcialintelligence,97(1):273–324,1997.R.Kohavi,D.H.Wolpert,etal.Biasplusvariancedecompositionforzero-onelossfunctions.InICML,pages275–283,1996.R.Kohavietal.Astudyofcross-validationandbootstrapforaccuracyestimationandmodelselection.InIJCAI,volume14,pages1137–1145,1995.I.Kononenko.Onbiasesinestimatingmulti-valuedattributes.InIJCAI,volume95,pages1034–1040,1995.A.Krogh,J.Vedelsby,etal.Neuralnetworkensembles,crossvalida-tion,andactivelearning.Advancesinneuralinformationprocessingsystems,pages231–238,1995.206J.B.Kruskal.Multidimensionalscalingbyoptimizinggoodnessofﬁttoanonmetrichypothesis.Psychometrika,29(1):1–27,1964.R.Kufrin.Decisiontreesonparallelprocessors.MachineIntelligenceandPatternRecognition,20:279–306,1997.L.I.KunchevaandJ.J.Rodríguez.Anexperimentalstudyonrota-tionforestensembles.InMultipleClassiﬁerSystems,pages459–468.Springer,2007.S.W.KwokandC.Carter.Multipledecisiontrees.InProceedingsoftheFourthAnnualConferenceonUncertaintyinArtiﬁcialIntelligence,pages327–338.North-HollandPublishingCo.,1990.Y.Liao,A.Rubinsteyn,R.Power,andJ.Li.LearningRandomForestsontheGPU.2013.A.LiawandM.Wiener.Classiﬁcationandregressionbyrandomfor-est.RNews,2(3):18–22,2002.URLhttp://CRAN.R-project.org/doc/Rnews/.Y.LinandY.Jeon.Randomforestsandadaptivenearestneighbors.2002.H.LiuandL.Yu.Towardintegratingfeatureselectionalgorithmsforclassiﬁcationandclustering.KnowledgeandDataEngineering,IEEETransactionson,17(4):491–502,2005.G.LouppeandP.Geurts.Azealousparallelgradientdescentalgo-rithm.2010.G.LouppeandP.Geurts.Ensemblesonrandompatches.InMa-chineLearningandKnowledgeDiscoveryinDatabases,pages346–361.Springer,2012.G.Louppe,L.Wehenkel,A.Sutera,andP.Geurts.Understandingvariableimportancesinforestsofrandomizedtrees.InAdvancesinNeuralInformationProcessingSystems,pages431–439,2013.K.L.Lunetta,L.B.Hayward,J.Segal,andP.VanEerdewegh.Screen-inglarge-scaleassociationstudydata:exploitinginteractionsusingrandomforests.BMCgenetics,5(1):32,2004.P.MacCullaghandJ.Nelder.Generalizedlinearmodels,volume37.CRCpress,1989.O.Z.MaimonandL.Rokach.Dataminingandknowledgediscoveryhandbook,volume1.Springer,2005.D.Marbach,J.C.Costello,R.Küffner,N.M.Vega,R.J.Prill,D.M.Camacho,K.R.Allison,M.Kellis,J.J.Collins,G.Stolovitzky,etal.Wisdomofcrowdsforrobustgenenetworkinference.Naturemeth-ods,9(8):796–804,2012.207R.Marée,L.Wehenkel,andP.Geurts.Extremelyrandomizedtreesandrandomsubwindowsforimageclassiﬁcation,annotation,andretrieval.InDecisionForestsforComputerVisionandMedicalImageAnalysis,pages125–141.Springer,2013.R.Marée,L.Rollus,B.Stevens,G.Louppe,O.Caubo,N.Rocks,S.Bekaert,D.Cataldo,andL.Wehenkel.Ahybridhuman-computerapproachforlarge-scaleimage-basedmeasurementsus-ingwebservicesandmachinelearning.ProceedingsIEEEInterna-tionalSymposiumonBiomedicalImaging,2014.A.McGovern,D.JohnGagneII,L.Eustaquio,G.Titericz,B.La-zorthes,O.Zhang,G.Louppe,P.Prettenhofer,J.Basara,T.Hamill,andD.Margolin.Solarenergyprediction:Aninternationalcontesttoinitiateinterdisciplinaryresearchoncompellingmeteorologicalproblems.2014.N.Meinshausen.Quantileregressionforests.TheJournalofMachineLearningResearch,7:983–999,2006.Y.A.Meng,Y.Yu,L.A.Cupples,L.A.Farrer,andK.L.Lunetta.Performanceofrandomforestwhensnpsareinlinkagedisequilib-rium.BMCbioinformatics,10(1):78,2009.R.MessengerandL.Mandell.Amodalsearchtechniqueforpre-dictivenominalscalemultivariateanalysis.JournaloftheAmericanstatisticalassociation,67(340):768–772,1972.J.Mingers.Anempiricalcomparisonofpruningmethodsfordecisiontreeinduction.Machinelearning,4(2):227–243,1989a.J.Mingers.Anempiricalcomparisonofselectionmeasuresfordecision-treeinduction.Machinelearning,3(4):319–342,1989b.L.Mitchell,T.M.Sloan,M.Mewissen,P.Ghazal,T.Forster,M.Pi-otrowski,andA.S.Trew.Aparallelrandomforestclassiﬁerforr.InProceedingsofthesecondinternationalworkshoponEmergingcompu-tationalmethodsforthelifesciences,pages1–6.ACM,2011.T.Mitchell.Machinelearning.McGraw-Hill,NewYork,1997.M.Miyakawa.Criteriaforselectingavariableintheconstructionofefﬁcientdecisiontrees.Computers,IEEETransactionson,38(1):130–141,1989.F.Moosmann,B.Triggs,F.Jurie,etal.Fastdiscriminativevisualcodebooksusingrandomizedclusteringforests.InNIPS,volume2,page4,2006.J.MorganandR.Messenger.Thaid:asequentialsearchprogramfortheanalysisofnominalscaledependentvariables.SurveyResearchCenter,InstituteforSocialResearch,UniversityofMichigan.[251],1973.208J.N.MorganandJ.A.Sonquist.Problemsintheanalysisofsurveydata,andaproposal.JournaloftheAmericanStatisticalAssociation,58(302):415–434,1963.K.V.S.MurthyandS.L.Salzberg.Ongrowingbetterdecisiontreesfromdata.PhDthesis,Citeseer,1995.D.R.Musser.Introspectivesortingandselectionalgorithms.Softw.,Pract.Exper.,27(8):983–993,1997.C.NadeauandY.Bengio.Inferenceforthegeneralizationerror.Ma-chineLearning,52(3):239–281,2003.R.Narayanan,D.Honbo,G.Memik,A.Choudhary,andJ.Zambreno.Interactivepresentation:Anfpgaimplementationofdecisiontreeclassiﬁcation.InProceedingsoftheconferenceonDesign,automationandtestinEurope,pages189–194.EDAConsortium,2007.C.OlaruandL.Wehenkel.Acompletefuzzydecisiontreetechnique.Fuzzysetsandsystems,138(2):221–254,2003.T.E.Oliphant.Pythonforscientiﬁccomputing.CiSE,9(3):10–20,2007.H.Pang,A.Lin,M.Holford,B.E.Enerson,B.Lu,M.P.Lawton,E.Floyd,andH.Zhao.Pathwayanalysisusingrandomforestsclassiﬁcationandregression.Bioinformatics,22(16):2028–2036,2006.P.PanovandS.Džeroski.Combiningbaggingandrandomsubspacestocreatebetterensembles.AdvancesinintelligentdataanalysisVII,pages118–129,2007.F.Pedregosa,G.Varoquaux,A.Gramfort,V.Michel,B.Thirion,O.Grisel,M.Blondel,P.Prettenhofer,R.Weiss,V.Dubourg,etal.Scikit-learn:Machinelearninginpython.TheJournalofMachineLearningResearch,12:2825–2830,2011.URLhttp://scikit-learn.org.F.PerezandB.E.Granger.IPython:asystemforinteractivescientiﬁccomputing.CiSE,9(3):21–29,2007.Y.Qi,Z.Bar-Joseph,andJ.Klein-Seetharaman.Evaluationofdifferentbiologicaldataandcomputationalclassiﬁcationmethodsforuseinproteininteractionprediction.Proteins:Structure,Function,andBioinformatics,63(3):490–500,2006.J.R.Quinlan.Discoveringrulesbyinductionfromlargecollectionsofexamples.Expertsystemsinthemicroelectronicage.EdinburghUniversityPress,1979.J.R.Quinlan.Inductionofdecisiontrees.Machinelearning,1(1):81–106,1986.209J.R.Quinlan.C4.5:programsformachinelearning,volume1.Morgankaufmann,1993.J.J.Rodriguez,L.I.Kuncheva,andC.J.Alonso.Rotationforest:Anewclassiﬁerensemblemethod.PatternAnalysisandMachineIntelligence,IEEETransactionson,28(10):1619–1630,2006.B.ScholkopfandA.J.Smola.Learningwithkernels:supportvectormachines,regularization,optimization,andbeyond.MITpress,2001.D.F.Schwarz,I.R.König,andA.Ziegler.Onsafaritorandomjungle:afastimplementationofrandomforestsforhigh-dimensionaldata.Bioinformatics,26(14):1752–1758,2010.E.Scornet,G.Biau,andJ.-P.Vert.Consistencyofrandomforests.arXivpreprintarXiv:1405.2881,2014.R.SedgewickandP.Flajolet.AnIntroductiontotheAnalysisofAlgo-rithms.PearsonEducation,2013.R.SedgewickandK.Wayne.Algorithms.PearsonEducation,2011.C.E.ShannonandW.Weaver.Themathematicaltheoryofcommunica-tion.TheUniversityofIllinoisPress,1949.T.Sharp.Implementingdecisiontreesandforestsonagpu.InCom-puterVision–ECCV2008,pages595–608.Springer,2008.J.A.Sonquist.Multivariatemodelbuilding:Thevalidationofasearchstrategy.SurveyResearchCenter,UniversityofMichigan,1970.J.A.Sonquist,E.L.Baker,andJ.N.Morgan.Searchingforstructure:Anapproachtoanalysisofsubstantialbodiesofmicro-dataanddocumen-tationforacomputerprogram.SurveyResearchCenter,UniversityofMichiganAnnArbor,MI,1974.A.Srivastava,E.-H.Han,V.Kumar,andV.Singh.Parallelformulationsofdecision-treeclassiﬁcationalgorithms.Springer,2002.D.J.StekhovenandP.Bühlmann.Missforest-non-parametricmiss-ingvalueimputationformixed-typedata.Bioinformatics,28(1):112–118,2012.M.Stone.Cross-validation:areview.Statistics:AJournalofTheoreticalandAppliedStatistics,9(1):127–139,1978.C.Strobl,A.-L.Boulesteix,andT.Augustin.Unbiasedsplitselectionforclassiﬁcationtreesbasedontheginiindex.ComputationalStatis-tics&DataAnalysis,52(1):483–501,2007a.C.Strobl,A.-L.Boulesteix,A.Zeileis,andT.Hothorn.Biasinrandomforestvariableimportancemeasures:Illustrations,sourcesandasolution.BMCbioinformatics,8(1):25,2007b.210C.Strobl,A.-L.Boulesteix,T.Kneib,T.Augustin,andA.Zeileis.Con-ditionalvariableimportanceforrandomforests.BMCbioinformatics,9(1):307,2008.A.Sutera,A.Joly,F.-L.Vincent,A.Qiu,G.Louppe,D.Ernest,andP.Geurts.Simpleconnectomeinferencefrompartialcorrelationstatisticsincalciumimaging.2014.R.Tibshirani.Bias,varianceandpredictionerrorforclassiﬁcationrules.Citeseer,1996.G.Toussaint.Bibliographyonestimationofmisclassiﬁcation.Infor-mationTheory,IEEETransactionson,20(4):472–479,1974.W.G.Touw,J.R.Bayjanov,L.Overmars,L.Backus,J.Boekhorst,M.Wels,andS.A.vanHijum.Datamininginthelifescienceswithrandomforest:awalkintheparkorlostinthejungle?Brief-ingsinbioinformatics,14(3):315–326,2013.G.TsoumakasandI.Katakis.Multi-labelclassiﬁcation:Anoverview.InternationalJournalofDataWarehousingandMining(IJDWM),3(3):1–13,2007.E.Tuv,A.Borisov,andK.Torkkola.Featureselectionusingensemblebasedrankingagainstartiﬁcialcontrasts.InNeuralNetworks,2006.IJCNN’06.InternationalJointConferenceon,pages2181–2186.IEEE,2006.E.Tuv,A.Borisov,G.Runger,andK.Torkkola.Featureselectionwithensembles,artiﬁcialvariables,andredundancyelimination.TheJournalofMachineLearningResearch,10:1341–1366,2009.S.VanderWalt,S.C.Colbert,andG.Varoquaux.TheNumPyarray:astructureforefﬁcientnumericalcomputation.CiSE,13(2):22–30,2011.J.Vitek.HowtogrowDistributedRandomForests.2013.L.Wehenkel.Onuncertaintymeasuresusedfordecisiontreein-duction.InInformationProcessingandManagementofUncertaintyinKnowledge-BasedSystems,1996.L.Wehenkel.Discretizationofcontinuousattributesforsupervisedlearning.varianceevaluationandvariancereduction.1997.L.A.Wehenkel.Automaticlearningtechniquesinpowersystems.Num-ber429.Springer,1998.A.P.WhiteandW.Z.Liu.Technicalnote:Biasininformation-basedmeasuresindecisiontreeinduction.MachineLearning,15(3):321–329,1994.211D.H.WolpertandW.G.Macready.Anefﬁcientmethodtoestimatebagging’sgeneralizationerror.MachineLearning,35(1):41–55,1999.Y.YuanandM.J.Shaw.Inductionoffuzzydecisiontrees.FuzzySetsandsystems,69(2):125–139,1995.D.Zhang,M.M.Islam,andG.Lu.Areviewonautomaticimageannotationtechniques.PatternRecognition,45(1):346–362,2012.G.Zhao.Anewperspectiveonclassiﬁcation.PhDthesis,UtahStateUniversity,DepartmentofMathematicsandStatistics,2000.Z.-H.Zhou.Ensemblemethods:foundationsandalgorithms.CRCPress,2012.D.A.ZighedandR.Rakotomalala.Graphesd’induction:apprentissageetdatamining.HermesParis,2000.M.Zinkevich,M.Weimer,A.Smola,andL.Li.Parallelizedstochasticgradientdescent.InJ.Lafferty,C.K.I.Williams,J.Shawe-Taylor,R.Zemel,andA.Culotta,editors,AdvancesinNeuralInformationProcessingSystems23,pages2595–2603,2010.