google-rules-of-machine-learning

我要开发同款
匿名用户2021年11月11日
149阅读

技术信息

授权协议
MIT License

作品详情

Google's43RulesofMachieLearig

GithubmirrorofM.Zikevich'sgreat"RulesofMachieLearig"styleguide,withextragoodess.

Youcafidthetermiologyforthisguideitermiology.md.

Youcafidtheoverviewforthisguideioverview.md.

StructureBeforeMachieLearigMLPhase1:YourFirstPipelieMLPhase2:FeatureEgieerigMLPhase3:SlowGrowth,OptimatioRefiemet,adComplexModelsRelatedWorkAckowledgemets&Appedix

Note: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).

YourFirstPipelie

Focusoyoursystemifrastructureforyourfirstpipelie.Whileitisfutothikaboutalltheimagiativemachielearigyouaregoigtodo,itwillbehardtofigureoutwhatishappeigifyoudo’tfirsttrustyourpipelie.

Rule4-Keepthefirstmodelsimpleadgettheifrastructureright.

Thefirstmodelprovidesthebiggestboosttoyourproduct,soitdoes'teedtobefacy.Butyouwillruitomaymoreifrastructureissuesthayouexpect.Beforeayoecauseyourfacyewmachielearigsystem,youhavetodetermie:

Howtogetexamplestoyourlearigalgorithm.Afirstcutastowhat“good”ad“bad”meatoyoursystem.Howtoitegrateyourmodelitoyourapplicatio.Youcaeitherapplythemodellive,orpre­computethemodeloexamplesofflieadstoretheresultsiatable.Forexample,youmightwattopre­classifywebpagesadstoretheresultsiatable,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.Moitorig

Igeeral,practicegoodalertighygiee,suchasmakigalertsactioableadhavigadashboardpage.

Rule8-Kowthefreshessrequiremetsofyoursystem

Howmuchdoesperformacedegradeifyouhaveamodelthatisadayold?Aweekold?Aquarterold?Thisiformatiocahelpyoutouderstadtheprioritiesofyourmoitorig.Ifyoulose10%ofyourreveueifthemodelisotupdatedforaday,itmakessesetohaveaegieerwatchigitcotiuously.Mostadservigsystemshaveewadvertisemetstohadleeveryday,admustupdatedaily.Foristace,iftheMLmodelforGooglePlaySearchisotupdated,itcahaveaimpactoreveueiuderamoth.SomemodelsforWhat’sHotiGooglePlushaveopostidetifieritheirmodelsotheycaexportthesemodelsifrequetly.Othermodelsthathavepostidetifiersareupdatedmuchmorefrequetly.Alsooticethatfreshesscachageovertime,especiallywhefeaturecolumsareaddedorremovedfromyourmodel.

Rule9-Detectproblemsbeforeexportigmodels.

Maymachielearigsystemshaveastagewhereyouexportthemodeltoservig.Ifthereisaissuewithaexportedmodel,itisauser­facigissue.Ifthereisaissuebefore,theitisatraiigissue,aduserswillototice.Dosaitychecksrightbeforeyouexportthemodel.Specifically,makesurethatthemodel’sperformaceisreasoableoheldoutdata.Or,ifyouhaveligerigcocerswiththedata,do’texportamodel.MayteamscotiuouslydeployigmodelschecktheareaudertheROCcurve(orAUC)beforeexportig.Issuesaboutmodelsthathave’tbeeexportedrequireae­mailalert,butissuesoauser­facigmodelmayrequireapage.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.

YourFirstObjective

Youhavemaymetrics,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/e­mailed?Wasthisrakedobjectrated?Wasthisshowobjectmarkedasspam/porography/offesive?

Avoidmodeligidirecteffectsatfirst:

Didtheuservisittheextday?Howlogdidtheuservisitthesite?Whatwerethedailyactiveusers?Idirecteffectsmakegreatmetrics,adcabeuseddurigA/Btestigadduriglauchdecisios.

Fially,do’ttrytogetthemachielearigtofigureout:

Istheuserhappyusigtheproduct?Istheusersatisfiedwiththeexperiece?Istheproductimprovigtheuser’soverallwell­beig?Howwillthisaffectthecompay’soverallhealth?

Theseareallimportat,butalsoicrediblyhard.Istead,useproxies:iftheuserishappy,theywillstayothesiteloger.Iftheuserissatisfied,theywillvisitagaitomorrow.Isofaraswell­beigadcompayhealthiscocered,humajudgemetisrequiredtocoectaymachielearedobjectivetotheatureoftheproductyouareselligadyourbusiesspla,sowedo’teduphere.

Rule14-Startigwithaiterpretablemodelmakesdebuggigeasier.

Liearregressio,logisticregressio,adPoissoregressioaredirectlymotivatedbyaprobabilisticmodel.Eachpredictioisiterpretableasaprobabilityoraexpectedvalue.Thismakesthemeasiertodebugthamodelsthatuseobjectives(zero­oeloss,varioushigelosses,etcetera)thattrytodirectlyoptimizeclassificatioaccuracyorrakigperformace.Forexample,ifprobabilitiesitraiigdeviatefromprobabilitiespredictediside­-by-­sidesorbyispectigtheproductiosystem,thisdeviatiocouldrevealaproblem.

Forexample,iliear,logistic,orPoissoregressio,therearesubsetsofthedatawheretheaveragepredictedexpectatioequalstheaveragelabel(1­mometcalibrated,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

Featureegieerig

Ithefirstphaseofthelifecycleofamachielearigsystem,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.MachielearigsystemssuchasTesorFlowallowyoutopre­processyourdatathroughtrasformatios.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.

HumaAalysisoftheSystem

Beforegoigotothethirdphaseofmachielearig,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-Measurethedeltabetweemodels

Oeoftheeasiest,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.

Theolywaytouderstadhowsuchasystemwouldworklog­termistohaveittraiolyodataacquiredwhethemodelwaslive.Thisisverydifficult.

Traiig-ServigSkew

Traiig­-servigskewisadifferecebetweeperformacedurigtraiigadperformacedurigservig.Thisskewcabecausedby:

adiscrepacybetweehowyouhadledataithetraiigadservigpipelies,orachageithedatabetweewheyoutraiadwheyouserve,orafeedbackloopbetweeyourmodeladyouralgorithm.

WehaveobservedproductiomachielearigsystemsatGooglewithtraiig-­servigskewthategativelyimpactsperformace.Thebestsolutioistoexplicitlymoitoritsothatsystemaddatachagesdo’titroduceskewuoticed.

功能介绍

Google's 43 Rules of Machine Learning Github mirror of M. Zinkevich's great "Rules of Machine Lea...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论