Google's43RulesofMachieLearig
GithubmirrorofM.Zikevich'sgreat"RulesofMachieLearig"styleguide,withextragoodess.
Youcafidthetermiologyforthisguideitermiology.md.
Youcafidtheoverviewforthisguideioverview.md.
StructureBeforeMachieLearigMLPhase1:YourFirstPipelieMLPhase2:FeatureEgieerigMLPhase3:SlowGrowth,OptimatioRefiemet,adComplexModelsRelatedWorkAckowledgemets&AppedixNote:Asterisk(*)foototesaremyow.NumberedfoototesareMarti's.
BeforeMachieLearigRule1-Do'tbeafraidtolauchaproductwithoutmachielearig.*Machielearigiscool,butitrequiresdata.Theoretically,youcatakedatafromadifferetproblemadthetweakthemodelforaewproduct,butthiswilllikelyuderperformbasicheuristics.Ifyouthikthatmachielearigwillgiveyoua100%boost,theaheuristicwillgetyou50%ofthewaythere.Foristace,ifyouarerakigappsiaappmarketplace,youcouldusetheistallrateorumberofistalls.Ifyouaredetectigspam,filteroutpublishersthathavesetspambefore.Do’tbeafraidtousehumaeditigeither.Ifyoueedtorakcotacts,rakthemostrecetlyusedhighest(oreverakalphabetically).Ifmachielearigisotabsolutelyrequiredforyourproduct,do'tuseitutilyouhavedata.
GoogleResearchBlog-The280-Year-OldAlgorithmIsideGoogleTrips
Rule2-First,desigadimplemetmetrics.Beforeformalizigwhatyourmachielearigsystemwilldo,trackasmuchaspossibleiyourcurretsystem.Dothisforthefollowigreasos:
Itiseasiertogaipermissiofromthesystem’susersearliero.Ifyouthikthatsomethigmightbeacocerithefuture,itisbettertogethistoricaldataow.Ifyoudesigyoursystemwithmetricistrumetatioimid,thigswillgobetterforyouithefuture.Specifically,youdo’twattofidyourselfgreppigforstrigsilogstoistrumetyourmetrics!Youwilloticewhatthigschageadwhatstaysthesame.Foristace,supposeyouwattodirectlyoptimizeoe-dayactiveusers.However,durigyourearlymaipulatiosofthesystem,youmayoticethatdramaticalteratiosoftheuserexperiecedo’toticeablychagethismetric.GooglePlusteammeasuresexpadsperread,resharesperread,plus-oesperread,commets/read,commetsperuser,resharesperuser,etc.whichtheyuseicomputigthegoodessofapostatservigtime.Also,otethataexperimetframework,whereyoucagroupusersitobucketsadaggregatestatisticsbyexperimet,isimportat.SeeRule#12.
Bybeigmoreliberalaboutgatherigmetrics,youcagaiabroaderpictureofyoursystem.Noticeaproblem?Addametrictotrackit!Excitedaboutsomequatitativechageothelastrelease?Addametrictotrackit!
Rule3-Choosemachielearigovercomplexheuristic.Asimpleheuristiccagetyourproductoutthedoor.Acomplexheuristicisumaitaiable.Oceyouhavedataadabasicideaofwhatyouaretryigtoaccomplish,moveotomachielearig.Asimostsoftwareegieerigtasks,youwillwattobecostatlyupdatigyourapproach,whetheritisaheuristicoramachie-learedmodel,adyouwillfidthatthemachie-learedmodeliseasiertoupdateadmaitai(seeRule#16).
YourFirstPipelieFocusoyoursystemifrastructureforyourfirstpipelie.Whileitisfutothikaboutalltheimagiativemachielearigyouaregoigtodo,itwillbehardtofigureoutwhatishappeigifyoudo’tfirsttrustyourpipelie.
Rule4-Keepthefirstmodelsimpleadgettheifrastructureright.Thefirstmodelprovidesthebiggestboosttoyourproduct,soitdoes'teedtobefacy.Butyouwillruitomaymoreifrastructureissuesthayouexpect.Beforeayoecauseyourfacyewmachielearigsystem,youhavetodetermie:
Howtogetexamplestoyourlearigalgorithm.Afirstcutastowhat“good”ad“bad”meatoyoursystem.Howtoitegrateyourmodelitoyourapplicatio.Youcaeitherapplythemodellive,orprecomputethemodeloexamplesofflieadstoretheresultsiatable.Forexample,youmightwattopreclassifywebpagesadstoretheresultsiatable,butyoumightwattoclassifychatmessageslive.Choosigsimplefeaturesmakesiteasiertoesurethat:
Thefeaturesreachyourlearigalgorithmcorrectly.Themodellearsreasoableweights.Thefeaturesreachyourmodelitheservercorrectly.Oceyouhaveasystemthatdoesthesethreethigsreliably,youhavedoemostofthework.Yoursimplemodelprovidesyouwithbaseliemetricsadabaseliebehaviorthatyoucausetotestmorecomplexmodels.Someteamsaimfora“eutral”firstlauch:afirstlauchthatexplicitlyde-prioritizesmachieleariggais,toavoidgettigdistracted.
Rule5-Testtheifrastructureidepedetlyfromthemachielearig.Makesurethattheifrastructureistestable,adthatthelearigpartsofthesystemareecapsulatedsothatyoucatesteverythigaroudit.Specifically:
Testgettigdataitothealgorithm.Checkthatfeaturecolumsthatshouldbepopulatedarepopulated.Whereprivacypermits,mauallyispecttheiputtoyourtraiigalgorithm.Ifpossible,checkstatisticsiyourpipelieicomparisotoelsewhere,suchasRASTA.
Testgettigmodelsoutofthetraiigalgorithm.Makesurethatthemodeliyourtraiigevirometgivesthesamescoreasthemodeliyourservigeviromet(seeRule#37).Machielearighasaelemetofupredictability,somakesurethatyouhavetestsforthecodeforcreatigexamplesitraiigadservig,adthatyoucaloadaduseafixedmodeldurigservig.Also,itisimportattouderstadyourdata:seePracticalAdviceforAalysisofLarge,ComplexDataSets.
Rule6-Becarefulaboutdroppeddatawhecopyigpipelies.Oftewecreateapipeliebycopyigaexistigpipelie(i.e.cargocultprogrammig),adtheoldpipeliedropsdatathatweeedfortheewpipelie.Forexample,thepipelieforGooglePlusWhat’sHotdropsolderposts(becauseitistryigtorakfreshposts).ThispipeliewascopiedtouseforGooglePlusStream,whereolderpostsarestillmeaigful,butthepipeliewasstilldroppigoldposts.Aothercommopatteristoolylogdatathatwasseebytheuser.Thus,thisdataisuselessifwewattomodelwhyaparticularpostwasotseebytheuser,becausealltheegativeexampleshavebeedropped.AsimilarissueoccurrediPlay.WhileworkigoPlayAppsHome,aewpipeliewascreatedthatalsocotaiedexamplesfromtwootherladigpages(PlayGamesHomeadPlayHomeHome)withoutayfeaturetodisambiguatewhereeachexamplecamefrom.
Rule7-Turheuristicsitofeatures,orhadlethemexterally.Usuallytheproblemsthatmachielearigistryigtosolveareotcompletelyew.Thereisaexistigsystemforrakig,orclassifyig,orwhateverproblemyouaretryigtosolve.Thismeasthatthereareabuchofrulesadheuristics.Thesesameheuristicscagiveyoualiftwhetweakedwithmachielearig.Yourheuristicsshouldbemiedforwhateveriformatiotheyhave,fortworeasos.First,thetrasitiotoamachielearedsystemwillbesmoother.Secod,usuallythoserulescotaialotoftheituitioaboutthesystemyoudo’twattothrowaway.Therearefourwaysyoucauseaexistigheuristic:
Preprocessusigtheheuristic.Ifthefeatureisicrediblyawesome,thethisisaoptio.Forexample,if,iaspamfilter,thesederhasalreadybeeblacklisted,do’ttrytorelearwhat“blacklisted”meas.Blockthemessage.Thisapproachmakesthemostseseibiaryclassificatiotasks.Createafeature.Directlycreatigafeaturefromtheheuristicisgreat.Forexample,ifyouuseaheuristictocomputearelevacescoreforaqueryresult,youcaicludethescoreasthevalueofafeature.Lateroyoumaywattousemachielearigtechiquestomassagethevalue(forexample,covertigthevalueitooeofafiitesetofdiscretevalues,orcombiigitwithotherfeatures)butstartbyusigtherawvalueproducedbytheheuristic.Mietherawiputsoftheheuristic.Ifthereisaheuristicforappsthatcombiestheumberofistalls,theumberofcharactersithetext,adthedayoftheweek,thecosiderpulligthesepiecesapart,adfeedigtheseiputsitothelearigseparately.Sometechiquesthatapplytoesemblesapplyhere(seeRule#40).Modifythelabel.Thisisaoptiowheyoufeelthattheheuristiccapturesiformatiootcurretlycotaiedithelabel.Forexample,ifyouaretryigtomaximizetheumberofdowloads,butyoualsowatqualitycotet,themaybethesolutioistomultiplythelabelbytheaverageumberofstarstheappreceived.Thereisalotofspacehereforleeway.Seethesectioo“YourFirstObjective”.DobemidfuloftheaddedcomplexitywheusigheuristicsiaMLsystem.Usigoldheuristicsiyourewmachielearigalgorithmcahelptocreateasmoothtrasitio,butthikaboutwhetherthereisasimplerwaytoaccomplishthesameeffect.MoitorigIgeeral,practicegoodalertighygiee,suchasmakigalertsactioableadhavigadashboardpage.
Rule8-KowthefreshessrequiremetsofyoursystemHowmuchdoesperformacedegradeifyouhaveamodelthatisadayold?Aweekold?Aquarterold?Thisiformatiocahelpyoutouderstadtheprioritiesofyourmoitorig.Ifyoulose10%ofyourreveueifthemodelisotupdatedforaday,itmakessesetohaveaegieerwatchigitcotiuously.Mostadservigsystemshaveewadvertisemetstohadleeveryday,admustupdatedaily.Foristace,iftheMLmodelforGooglePlaySearchisotupdated,itcahaveaimpactoreveueiuderamoth.SomemodelsforWhat’sHotiGooglePlushaveopostidetifieritheirmodelsotheycaexportthesemodelsifrequetly.Othermodelsthathavepostidetifiersareupdatedmuchmorefrequetly.Alsooticethatfreshesscachageovertime,especiallywhefeaturecolumsareaddedorremovedfromyourmodel.
Rule9-Detectproblemsbeforeexportigmodels.Maymachielearigsystemshaveastagewhereyouexportthemodeltoservig.Ifthereisaissuewithaexportedmodel,itisauserfacigissue.Ifthereisaissuebefore,theitisatraiigissue,aduserswillototice.Dosaitychecksrightbeforeyouexportthemodel.Specifically,makesurethatthemodel’sperformaceisreasoableoheldoutdata.Or,ifyouhaveligerigcocerswiththedata,do’texportamodel.MayteamscotiuouslydeployigmodelschecktheareaudertheROCcurve(orAUC)beforeexportig.Issuesaboutmodelsthathave’tbeeexportedrequireaemailalert,butissuesoauserfacigmodelmayrequireapage.Sobettertowaitadbesurebeforeimpactigusers.
Rule10-Watchforsiletfailures.Thisisaproblemthatoccursmoreformachielearigsystemsthaforotherkidsofsystems.Supposethataparticulartablethatisbeigjoiedisologerbeigupdated.Themachielearigsystemwilladjust,adbehaviorwillcotiuetobereasoablygood,decayiggradually.Sometimestablesarefoudthatweremothsoutofdate,adasimplerefreshimprovedperformacemorethaayotherlauchthatquarter!Forexample,thecoverageofafeaturemaychageduetoimplemetatiochages:forexampleafeaturecolumcouldbepopulatedi90%oftheexamples,adsuddelydropto60%oftheexamples.Playocehadatablethatwasstalefor6moths,adrefreshigthetablealoegaveaboostof2%iistallrate.Ifyoutrackstatisticsofthedata,aswellasmauallyispectthedataooccasio,youcareducethesekidsoffailures.*
AFrameworkforAalysisofDataFreshess-Bouzeghoub&PeraltaRule11-Givefeaturecolumsowersaddocumetatio.Ifthesystemislarge,adtherearemayfeaturecolums,kowwhocreatedorismaitaiigeachfeaturecolum.Ifyoufidthatthepersowhouderstadsafeaturecolumisleavig,makesurethatsomeoehastheiformatio.Althoughmayfeaturecolumshavedescriptiveames,it'sgoodtohaveamoredetaileddescriptioofwhatthefeatureis,whereitcamefrom,adhowitisexpectedtohelp.
YourFirstObjectiveYouhavemaymetrics,ormeasuremetsaboutthesystemthatyoucareabout,butyourmachielearigalgorithmwillofterequireasigleobjective,aumberthatyouralgorithmis“tryig”tooptimize.Idistiguishherebetweeobjectivesadmetrics:ametricisayumberthatyoursystemreports,whichmayormayotbeimportat.SeealsoRule#2.
Rule12-Do'toverthikwhichobjectiveyouchoosetodirectlyoptimize.Youwattomakemoey,makeyourusershappy,admaketheworldabetterplace.Therearetosofmetricsthatyoucareabout,adyoushouldmeasurethemall(seeRule#2).However,earlyithemachielearigprocess,youwilloticethemallgoigup,evethosethatyoudootdirectlyoptimize.Foristace,supposeyoucareaboutumberofclicks,timespetothesite,addailyactiveusers.Ifyouoptimizeforumberofclicks,youarelikelytoseethetimespeticrease.So,keepitsimpleaddo’tthiktoohardaboutbalacigdifferetmetricswheyoucastilleasilyicreaseallthemetrics.Do’ttakethisruletoofarthough:dootcofuseyourobjectivewiththeultimatehealthofthesystem(seeRule#39).Ad,ifyoufidyourselficreasigthedirectlyoptimizedmetric,butdecidigottolauch,someobjectiverevisiomayberequired.
Rule13-Chooseasimple,observableadattributablemetricforyourfirstobjective.Ofteyoudo'tkowwhatthetrueobjectiveis.Youthikyoudobuttheyouasyoustareatthedataadside-by-sideaalysisofyouroldsystemadewMLsystem,yourealizeyouwattotweakit.Further,differetteammembersofteca'tagreeothetrueobjective.TheMLobjectiveshouldbesomethigthatiseasytomeasureadisaproxyforthe“true”objective.SotraiothesimpleMLobjective,adcosiderhaviga"policylayer"otopthatallowsyoutoaddadditioallogic(hopefullyverysimplelogic)todothefialrakig.
Theeasiestthigtomodelisauserbehaviorthatisdirectlyobservedadattributabletoaactioofthesystem:
Wasthisrakedlikclicked?Wasthisrakedobjectdowloaded?Wasthisrakedobjectforwarded/repliedto/emailed?Wasthisrakedobjectrated?Wasthisshowobjectmarkedasspam/porography/offesive?Avoidmodeligidirecteffectsatfirst:
Didtheuservisittheextday?Howlogdidtheuservisitthesite?Whatwerethedailyactiveusers?Idirecteffectsmakegreatmetrics,adcabeuseddurigA/Btestigadduriglauchdecisios.Fially,do’ttrytogetthemachielearigtofigureout:
Istheuserhappyusigtheproduct?Istheusersatisfiedwiththeexperiece?Istheproductimprovigtheuser’soverallwellbeig?Howwillthisaffectthecompay’soverallhealth?Theseareallimportat,butalsoicrediblyhard.Istead,useproxies:iftheuserishappy,theywillstayothesiteloger.Iftheuserissatisfied,theywillvisitagaitomorrow.Isofaraswellbeigadcompayhealthiscocered,humajudgemetisrequiredtocoectaymachielearedobjectivetotheatureoftheproductyouareselligadyourbusiesspla,sowedo’teduphere.
Rule14-Startigwithaiterpretablemodelmakesdebuggigeasier.Liearregressio,logisticregressio,adPoissoregressioaredirectlymotivatedbyaprobabilisticmodel.Eachpredictioisiterpretableasaprobabilityoraexpectedvalue.Thismakesthemeasiertodebugthamodelsthatuseobjectives(zerooeloss,varioushigelosses,etcetera)thattrytodirectlyoptimizeclassificatioaccuracyorrakigperformace.Forexample,ifprobabilitiesitraiigdeviatefromprobabilitiespredictediside-by-sidesorbyispectigtheproductiosystem,thisdeviatiocouldrevealaproblem.
Forexample,iliear,logistic,orPoissoregressio,therearesubsetsofthedatawheretheaveragepredictedexpectatioequalstheaveragelabel(1mometcalibrated,orjustcalibrated)3.Ifyouhaveafeaturewhichiseither1or0foreachexample,thethesetofexampleswherethatfeatureis1iscalibrated.Also,ifyouhaveafeaturethatis1foreveryexample,thethesetofallexamplesiscalibrated.
Withsimplemodels,itiseasiertodealwithfeedbackloops(seeRule#36&).Ofte,weusetheseprobabilisticpredictiostomakeadecisio:e.g.rakpostsidecreasigexpectedvalue(i.e.probabilityofclick/dowload/etc.).However,rememberwheitcomestimetochoosewhichmodeltouse,thedecisiomattersmorethathelikelihoodofthedatagivethemodel(seeRule#27).
Rule15-SeparateSpamFilterigadQualityRakigiaPolicyLayer.Qualityrakigisafieart,butspamfilterigisawar.*Thesigalsthatyouusetodetermiehighqualitypostswillbecomeobvioustothosewhouseyoursystem,adtheywilltweaktheirpoststohavetheseproperties.Thus,yourqualityrakigshouldfocusorakigcotetthatispostedigoodfaith.Youshouldotdiscoutthequalityrakiglearerforrakigspamhighly.Similarly,“racy”cotetshouldbehadledseparatelyfromQualityRakig.Spamfilterigisadifferetstory.Youhavetoexpectthatthefeaturesthatyoueedtogeeratewillbecostatlychagig.Ofte,therewillbeobviousrulesthatyouputitothesystem(ifaposthasmorethathreespamvotes,do’tretrieveit,etcetera).Aylearedmodelwillhavetobeupdateddaily,ifotfaster.Thereputatioofthecreatorofthecotetwillplayagreatrole.
Atsomelevel,theoutputofthesetwosystemswillhavetobeitegrated.Keepimid,filterigspamisearchresultsshouldprobablybemoreaggressivethafilterigspamiemailmessages.Also,itisastadardpracticetoremovespamfromthetraiigdataforthequalityclassifier.
GoogleResearchBlog-LessoslearedwhileprotectigGmail
FeatureegieerigIthefirstphaseofthelifecycleofamachielearigsystem,theimportatissueistogetthetraiigdataitothelearigsystem,getaymetricsofiterestistrumeted,adcreateaservigifrastructure.Afteryouhaveaworkigedtoedsystemwithuitadsystemtestsistrumeted,PhaseIIbegis.
Rule16-Platolauchaditerate.Do’texpectthatthemodelyouareworkigoowwillbethelastoethatyouwilllauch,orevethatyouwilleverstoplauchigmodels.Thuscosiderwhetherthecomplexityyouareaddigwiththislauchwillslowdowfuturelauches.Mayteamshavelauchedamodelperquarterormoreforyears.Therearethreebasicreasostolauchewmodels:
youarecomigupwithewfeatures,youaretuigregularizatioadcombiigoldfeaturesiewways,ad/oryouaretuigtheobjective.Regardless,givigamodelabitoflovecabegood:lookigoverthedatafeedigitotheexamplecahelpfidewsigalsaswellasold,brokeoes.So,asyoubuildyourmodel,thikabouthoweasyitistoaddorremoveorrecombiefeatures.Thikabouthoweasyitistocreateafreshcopyofthepipelieadverifyitscorrectess.Thikaboutwhetheritispossibletohavetwoorthreecopiesruigiparallel.Fially,do’tworryaboutwhetherfeature16of35makesititothisversioofthepipelie.You’llgetitextquarter.
Rule17-Startwithdirectlyobservedadreportedfeaturesasopposedtolearedfeatures.Thismightbeacotroversialpoit,butitavoidsalotofpitfalls.Firstofall,let’sdescribewhatalearedfeatureis.Alearedfeatureisafeaturegeeratedeitherbyaexteralsystem(suchasausupervisedclusterigsystem)orbytheleareritself(e.g.viaafactoredmodelordeeplearig).Bothofthesecabeuseful,buttheycahavealotofissues,sotheyshouldotbeithefirstmodel.Ifyouuseaexteralsystemtocreateafeature,rememberthatthesystemhasitsowobjective.Theexteralsystem'sobjectivemaybeolyweaklycorrelatedwithyourcurretobjective.Ifyougrabasapshotoftheexteralsystem,theitcabecomeoutofdate.Ifyouupdatethefeaturesfromtheexteralsystem,thethemeaigsmaychage.Ifyouuseaexteralsystemtoprovideafeature,beawarethattheyrequireagreatdealofcare.Theprimaryissuewithfactoredmodelsaddeepmodelsisthattheyareo-covex.Thus,thereisoguarateethataoptimalsolutiocabeapproximatedorfoud,adthelocalmiimafoudoeachiteratiocabedifferet.Thisvariatiomakesithardtojudgewhethertheimpactofachagetoyoursystemismeaigfulorradom.Bycreatigamodelwithoutdeepfeatures,youcagetaexcelletbaselieperformace.Afterthisbaselieisachieved,youcatrymoreesotericapproaches.
Rule18-Explorewithfeaturesofcotetthatgeeralizeacrosscotexts.Ofteamachielearigsystemisasmallpartofamuchbiggerpicture.Forexample,ifyouimagieapostthatmightbeusediWhat’sHot,maypeoplewillplus-oe,re-share,orcommetoapostbeforeitisevershowiWhat’sHot.Ifyouprovidethosestatisticstothelearer,itcapromoteewpoststhatithasodataforithecotextitisoptimizig.YouTubeWatchNextcoulduseumberofwatches,orco-watches(coutsofhowmaytimesoevideowaswatchedafteraotherwaswatched)fromYouTubesearch.Youcaalsouseexplicituserratigs.Fially,ifyouhaveauseractiothatyouareusigasalabel,seeigthatactioothedocumetiadifferetcotextcabeagreatfeature.Allofthesefeaturesallowyoutobrigewcotetitothecotext.Notethatthisisotaboutpersoalizatio:figureoutifsomeoelikesthecotetithiscotextfirst,thefigureoutwholikesitmoreorless.
Rule19-Useveryspecificfeatureswheyouca.Withtosofdata,itissimplertolearmilliosofsimplefeaturesthaafewcomplexfeatures.Idetifiersofdocumetsbeigretrievedadcaoicalizedqueriesdootprovidemuchgeeralizatio,butaligyourrakigwithyourlabelsoheadqueries..Thus,do’tbeafraidofgroupsoffeatureswhereeachfeatureappliestoaverysmallfractioofyourdata,butoverallcoverageisabove90%.Youcauseregularizatiotoelimiatethefeaturesthatapplytotoofewexamples.
Rule20-Combieadmodifyexistigfeaturestocreateewfeaturesihuma-uderstadableways.Thereareavarietyofwaystocombieadmodifyfeatures.MachielearigsystemssuchasTesorFlowallowyoutopreprocessyourdatathroughtrasformatios.Thetwomoststadardapproachesare“discretizatios”ad“crosses”.
Discretizatiocosistsoftakigacotiuousfeatureadcreatigmaydiscretefeaturesfromit.Cosideracotiuousfeaturesuchasage.Youcacreateafeaturewhichis1wheageislesstha18,aotherfeaturewhichis1wheageisbetwee18ad35,etcetera.Do’toverthiktheboudariesofthesehistograms:basicquatileswillgiveyoumostoftheimpact.Crossescombietwoormorefeaturecolums.Afeaturecolum,iTesorFlow'stermiology,isasetofhomogeousfeatures,(e.g.{male,female},{US,Caada,Mexico},etcetera).Acrossisaewfeaturecolumwithfeaturesi,forexample,{male,female}×{US,Caada,Mexico}.Thisewfeaturecolumwillcotaithefeature(male,Caada).IfyouareusigTesorFlowadyoutellTesorFlowtocreatethiscrossforyou,this(male,Caada)featurewillbepresetiexamplesrepresetigmaleCaadias.Notethatittakesmassiveamoutsofdatatolearmodelswithcrossesofthree,four,ormorebasefeaturecolums.
Crossesthatproduceverylargefeaturecolumsmayoverfit.Foristace,imagiethatyouaredoigsomesortofsearch,adyouhaveafeaturecolumwithwordsithequery,adyouhaveafeaturecolumwithwordsithedocumet.Youcacombiethesewithacross,butyouwilledupwithalotoffeatures(seeRule#21).Wheworkigwithtexttherearetwoalteratives.Themostdracoiaisadotproduct.Adotproductiitssimplestformsimplycoutstheumberofcommowordsbetweethequeryadthedocumet.Thisfeaturecathebediscretized.Aotherapproachisaitersectio:thus,wewillhaveafeaturewhichispresetifadolyiftheword“poy”isithedocumetadthequery,adaotherfeaturewhichispresetifadolyiftheword“the”isithedocumetadthequery.
Rule21-Theumberoffeatureweightsyoucalearialiearmodelisroughlyproportioaltotheamoutofdatayouhave.Therearefasciatigstatisticallearigtheoryresultscocerigtheappropriatelevelofcomplexityforamodel,butthisruleisbasicallyallyoueedtokow.Ihavehadcoversatiosiwhichpeopleweredoubtfulthataythigcabelearedfromoethousadexamples,orthatyouwouldevereedmoretha1millioexamples,becausetheygetstuckiacertaimethodoflearig.Thekeyistoscaleyourlearigtothesizeofyourdata:
Ifyouareworkigoasearchrakigsystem,adtherearemilliosofdifferetwordsithedocumetsadthequeryadyouhave1000labeledexamples,theyoushoulduseadotproductbetweedocumetadqueryfeatures,TF-IDF,adahalf-dozeotherhighlyhuma-egieeredfeatures.1000examples,adozefeatures.Ifyouhaveamillioexamples,theitersectthedocumetadqueryfeaturecolums,usigregularizatioadpossiblyfeatureselectio.Thiswillgiveyoumilliosoffeatures,butwithregularizatioyouwillhavefewer.Temillioexamples,maybeahudredthousadfeatures.Ifyouhavebilliosorhudredsofbilliosofexamples,youcacrossthefeaturecolumswithdocumetadquerytokes,usigfeatureselectioadregularizatio.Youwillhaveabillioexamples,ad10milliofeatures.Statisticallearigtheoryrarelygivestightbouds,butgivesgreatguidaceforastartigpoit.Itheed,useRule#28todecidewhatfeaturestouse.
Rule22-Cleaupfeaturesyouareologerusig.Uusedfeaturescreatetechicaldebt.Ifyoufidthatyouareotusigafeature,adthatcombiigitwithotherfeaturesisotworkig,thedropitoutofyourifrastructure.Youwattokeepyourifrastructurecleasothatthemostpromisigfeaturescabetriedasfastaspossible.Ifecessary,someoecaalwaysaddbackyourfeature.Keepcoverageimidwhecosiderigwhatfeaturestoaddorkeep.Howmayexamplesarecoveredbythefeature?Forexample,ifyouhavesomepersoalizatiofeatures,butoly8%ofyourusershaveaypersoalizatiofeatures,itisotgoigtobeveryeffective.Atthesametime,somefeaturesmaypuchabovetheirweight.Forexample,ifyouhaveafeaturewhichcoversoly1%ofthedata,but90%oftheexamplesthathavethefeaturearepositive,theitwillbeagreatfeaturetoadd.
HumaAalysisoftheSystemBeforegoigotothethirdphaseofmachielearig,itisimportattofocusosomethigthatisottaughtiaymachielearigclass:howtolookataexistigmodel,adimproveit.Thisismoreofaartthaasciece,adyetthereareseveralati-pattersthatithelpstoavoid.
Rule23-Youareotatypicaleduser.*Thisisperhapstheeasiestwayforateamtogetboggeddow.Whiletherearealotofbeefitstofish-foodig(usigaprototypewithiyourteam)addog-foodig(usigaprototypewithiyourcompay),employeesshouldlookatwhethertheperformaceiscorrect.Whileachagewhichisobviouslybadshouldotbeused,aythigthatlooksreasoablyearproductioshouldbetestedfurther,eitherbypayiglaypeopletoaswerquestiosoacrowdsourcigplatform,orthroughaliveexperimetorealusers.Therearetworeasosforthis.Thefirstisthatyouaretooclosetothecode.Youmaybelookigforaparticularaspectoftheposts,oryouaresimplytooemotioallyivolved(e.g.cofirmatiobias).Thesecodisthatyourtimeistoovaluable.Cosiderthecostof9egieerssittigiaoehourmeetig,adthikofhowmaycotractedhumalabelsthatbuysoacrowdsourcigplatform.
Ifyoureallywattohaveuserfeedback,useuserexperiecemethodologies.Createuserpersoas(oedescriptioisiBillBuxto’sDesigigSketchigUserExperieces)earlyiaprocessaddousabilitytestig(oedescriptioisiSteveKrug’sDo’tMakeMeThik)later.Userpersoasivolvecreatigahypotheticaluser.Foristace,ifyourteamisallmale,itmighthelptodesiga35-yearoldfemaleuserpersoa(completewithuserfeatures),adlookattheresultsitgeeratesrathertha10resultsfor25-40yearoldmales.Brigigiactualpeopletowatchtheirreactiotoyoursite(locallyorremotely)iusabilitytestigcaalsogetyouafreshperspective.
GoogleResearchBlog-Howtomeasuretraslatioqualityiyouruseriterfaces
Rule24-MeasurethedeltabetweemodelsOeoftheeasiest,adsometimesmostusefulmeasuremetsyoucamakebeforeayusershavelookedatyourewmodelistocalculatejusthowdifferettheewresultsarefromproductio.Foristace,ifyouhavearakigproblem,rubothmodelsoasampleofqueriesthroughtheetiresystem,adlookatthesizeofthesymmetricdiffereceoftheresults(weightedbyrakigpositio).Ifthediffereceisverysmall,theyoucatellwithoutruigaexperimetthattherewillbelittlechage.Ifthediffereceisverylarge,theyouwattomakesurethatthechageisgood.Lookigoverquerieswherethesymmetricdiffereceishighcahelpyoutouderstadqualitativelywhatthechagewaslike.Makesure,however,thatthesystemisstable.Makesurethatamodelwhecomparedwithitselfhasalow(ideallyzero)symmetricdifferece.
Rule25-Whechoosigmodels,utilitariaperformacetrumpspredictivepower.Yourmodelmaytrytopredictclick-through-rate.However,itheed,thekeyquestioiswhatyoudowiththatpredictio.Ifyouareusigittorakdocumets,thethequalityofthefialrakigmattersmorethathepredictioitself.Ifyoupredicttheprobabilitythatadocumetisspamadthehaveacutoffowhatisblocked,thetheprecisioofwhatisallowedthroughmattersmore.Mostofthetime,thesetwothigsshouldbeiagreemet:whetheydootagree,itwilllikelybeoasmallgai.Thus,ifthereissomechagethatimprovesloglossbutdegradestheperformaceofthesystem,lookforaotherfeature.Whethisstartshappeigmoreofte,itistimetorevisittheobjectiveofyourmodel.
Rule26-Lookforpattersithemeasurederrors,adcreateewfeatures.Supposethatyouseeatraiigexamplethatthemodelgot“wrog”.Iaclassificatiotask,thiscouldbeafalsepositiveorafalseegative.Iarakigtask,itcouldbeapairwhereapositivewasrakedlowerthaaegative.Themostimportatpoitisthatthisisaexamplethatthemachielearigsystemkowsitgotwrogadwouldliketofixifgivetheopportuity.Ifyougivethemodelafeaturethatallowsittofixtheerror,themodelwilltrytouseit.Otheotherhad,ifyoutrytocreateafeaturebasedupoexamplesthesystemdoes’tseeasmistakes,thefeaturewillbeigored.Foristace,supposethatiPlayAppsSearch,someoesearchesfor“freegames”.Supposeoeofthetopresultsisalessrelevatgagapp.Soyoucreateafeaturefor“gagapps”.However,ifyouaremaximizigumberofistalls,adpeopleistallagagappwhetheysearchforfreegames,the“gagapps”featurewo’thavetheeffectyouwat.
Oceyouhaveexamplesthatthemodelgotwrog,lookfortredsthatareoutsideyourcurretfeatureset.Foristace,ifthesystemseemstobedemotiglogerposts,theaddpostlegth.Do’tbetoospecificaboutthefeaturesyouadd.Ifyouaregoigtoaddpostlegth,do’ttrytoguesswhatlogmeas,justaddadozefeaturesadtheletmodelfigureoutwhattodowiththem(seeRule#21).Thatistheeasiestwaytogetwhatyouwat.
Rule27-Trytoquatifyobservedudesirablebehavior.Somemembersofyourteamwillstarttobefrustratedwithpropertiesofthesystemtheydo’tlikewhichare’tcapturedbytheexistiglossfuctio.Atthispoit,theyshoulddowhateverittakestoturtheirgripesitosolidumbers.Forexample,iftheythikthattoomay“gagapps”arebeigshowiPlaySearch,theycouldhavehumaratersidetifygagapps.(Youcafeasiblyusehuma-labelleddataithiscasebecausearelativelysmallfractioofthequeriesaccoutforalargefractioofthetraffic.)Ifyourissuesaremeasurable,theyoucastartusigthemasfeatures,objectives,ormetrics.Thegeeralruleis“measurefirst,optimizesecod”.
Rule28-Beawarethatideticalshort-termbehaviordoesotimplyideticallog-termbehavior.Imagiethatyouhaveaewsystemthatlooksateverydoc_idadexact_query,adthecalculatestheprobabilityofclickforeverydocforeveryquery.YoufidthatitsbehaviorisearlyideticaltoyourcurretsystemibothsidebysidesadA/Btestig,sogiveitssimplicity,youlauchit.However,youoticethatoewappsarebeigshow.Why?Well,siceyoursystemolyshowsadocbasedoitsowhistorywiththatquery,thereisowaytolearthataewdocshouldbeshow.
Theolywaytouderstadhowsuchasystemwouldworklogtermistohaveittraiolyodataacquiredwhethemodelwaslive.Thisisverydifficult.
Traiig-ServigSkewTraiig-servigskewisadifferecebetweeperformacedurigtraiigadperformacedurigservig.Thisskewcabecausedby:
adiscrepacybetweehowyouhadledataithetraiigadservigpipelies,orachageithedatabetweewheyoutraiadwheyouserve,orafeedbackloopbetweeyourmodeladyouralgorithm.WehaveobservedproductiomachielearigsystemsatGooglewithtraiig-servigskewthategativelyimpactsperformace.Thebestsolutioistoexplicitlymoitoritsothatsystemaddatachagesdo’titroduceskewuoticed.







评论