Learning Curve to identify Overfitting and Underfitting in ...
文章推薦指數: 80 %
Learning curves plot the training and validation loss of a sample of training examples by incrementally adding new training examples. Learning curves help us in ... OpeninappHomeNotificationsListsStoriesWritePublishedinTowardsDataScienceLearningCurvetoidentifyOverfittingandUnderfittinginMachineLearningThisarticlediscussesoverfittingandunderfittinginmachinelearningalongwiththeuseoflearningcurvestoeffectivelyidentifyoverfittingandunderfittinginmachinelearningmodels.ImagebyChrisRiedonUnsplashOverfittingandunderfittingOverfitting(akavariance):Amodelissaidtobeoverfitifitisovertrainedonthedatasuchthat,itevenlearnsthenoisefromit.Anoverfitmodellearnseachandeveryexamplesoperfectlythatitmisclassifiesanunseen/newexample.Foramodelthat’soverfit,wehaveaperfect/closetoperfecttrainingsetscorewhileapoortest/validationscore.Reasonsbehindoverfitting:Usingacomplexmodelforasimpleproblemwhichpicksupthenoisefromthedata.Example:FittinganeuralnetworktotheIrisdataset.Smalldatasets,asthetrainingsetmaynotbearightrepresentationoftheuniverse.Underfitting(akabias):Amodelissaidtobeunderfitifitisunabletolearnthepatternsinthedataproperly.Anunderfitmodeldoesn’tfullylearneachandeveryexampleinthedataset.Insuchcases,weseealowscoreonboththetrainingsetandtest/validationset.Reasonsbehindunderfitting:Usingasimplemodelforacomplexproblemwhichdoesn’tlearnallthepatternsinthedata.Example:UsingalogisticregressionforimageclassificationTheunderlyingdatahasnoinherentpattern.Example,tryingtopredictastudent’smarkswithhisfather’sweight.IntroductiontolearningcurveLearningcurvesplotthetrainingandvalidationlossofasampleoftrainingexamplesbyincrementallyaddingnewtrainingexamples.Learningcurveshelpusinidentifyingwhetheraddingadditionaltrainingexampleswouldimprovethevalidationscore(scoreonunseendata).Ifamodelisoverfit,thenaddingadditionaltrainingexamplesmightimprovethemodelperformanceonunseendata.Similarly,ifamodelisunderfit,thenaddingtrainingexamplesdoesn’thelp.‘learning_curve’methodcanbeimportedfromScikit-Learn’s‘model_selection’moduleasshownbelow.Inthisarticle,we’lluseLogisticRegressiontopredictthe‘species’ofthe‘Irisdata’.We’llcreateafunctionnamed‘learn_curve’thatfitsaLogisticRegressionmodeltotheIrisdataandreturnscrossvalidationscores,trainscoreandlearningcurvedata.LearningcurveofagoodfitmodelWe’llusethe‘learn_curve’functiontogetagoodfitmodelbysettingtheinverseregularizationvariable/parameter‘c’to1(i.e.wearenotperforminganyregularization).ImagebyauthorIntheaboveresults,crossvalidationaccuracyandtrainingaccuracyareclosetoeachother.ImagebyauthorInterpretingthetraininglossLearningcurveofagoodfitmodelhasamoderatelyhightraininglossatthebeginningwhichgraduallydecreasesuponaddingtrainingexamplesandflattensgradually,indicatingadditionofmoretrainingexamplesdoesn’timprovethemodelperformanceontrainingdata.InterpretingthevalidationlossLearningcurveofagoodfitmodelhasahighvalidationlossatthebeginningwhichgraduallydecreasesuponaddingtrainingexamplesandflattensgradually,indicatingadditionofmoretrainingexamplesdoesn’timprovethemodelperformanceonunseendata.Wecanalsoseethatuponaddingareasonablenumberoftrainingexamples,boththetrainingandvalidationlossmovedclosetoeachother.TypicalfeaturesofthelearningcurveofagoodfitmodelTraininglossandValidationlossareclosetoeachotherwithvalidationlossbeingslightlygreaterthanthetrainingloss.Initiallydecreasingtrainingandvalidationlossandaprettyflattrainingandvalidationlossaftersomepointtilltheend.LearningcurveofanoverfitmodelWe’llusethe‘learn_curve’functiontogetanoverfitmodelbysettingtheinverseregularizationvariable/parameter‘c’to10000(highvalueof‘c’causesoverfitting).ImagebyauthorThestandarddeviationofcrossvalidationaccuraciesishighcomparedtounderfitandgoodfitmodel.Trainingaccuracyishigherthancrossvalidationaccuracy,typicaltoanoverfitmodel,butnottoohightodetectoverfitting.Butoverfittingcanbedetectedfromthelearningcurve.ImagebyauthorInterpretingthetraininglossLearningcurveofanoverfitmodelhasaverylowtraininglossatthebeginningwhichgraduallyincreasesveryslightlyuponaddingtrainingexamplesanddoesn’tflatten.InterpretingthevalidationlossLearningcurveofanoverfitmodelhasahighvalidationlossatthebeginningwhichgraduallydecreasesuponaddingtrainingexamplesanddoesn’tflatten,indicatingadditionofmoretrainingexamplescanimprovethemodelperformanceonunseendata.Wecanalsoseethatthetrainingandvalidationlossesarefarawayfromeachother,whichmaycomeclosetoeachotheruponaddingadditionaltrainingdata.TypicalfeaturesofthelearningcurveofanoverfitmodelTraininglossandValidationlossarefarawayfromeachother.Graduallydecreasingvalidationloss(withoutflattening)uponaddingtrainingexamples.Verylowtraininglossthat’sveryslightlyincreasinguponaddingtrainingexamples.LearningcurveofanunderfitmodelWe’llusethe‘learn_curve’functiontogetanunderfitmodelbysettingtheinverseregularizationvariable/parameter‘c’to1/10000(lowvalueof‘c’causesunderfitting).ImagebyauthorThestandarddeviationofcrossvalidationaccuraciesislowcomparedtooverfitandgoodfitmodel.However,underfittingcanbedetectedfromthelearningcurve.ImagebyauthorInterpretingthetraininglossLearningcurveofanunderfitmodelhasalowtraininglossatthebeginningwhichgraduallyincreasesuponaddingtrainingexamplesandsuddenlyfallstoanarbitraryminimumpoint(minimumdoesn’tmeanzeroloss)attheend.Thissuddenfallattheendmaynotalwayshappen.Theimagebelowalsoshowsunderfitting.ImagebyauthorInterpretingthevalidationlossLearningcurveofanunderfitmodelhasahighvalidationlossatthebeginningwhichgraduallylowersuponaddingtrainingexamplesandsuddenlyfallstoanarbitraryminimumattheend(thissuddenfallattheendmaynotalwayshappen,butitmaystayflat),indicatingadditionofmoretrainingexamplescan’timprovethemodelperformanceonunseendata.TypicalfeaturesofthelearningcurveofanunderfitmodelIncreasingtraininglossuponaddingtrainingexamples.Traininglossandvalidationlossareclosetoeachotherattheend.Suddendipinthetraininglossandvalidationlossattheend(notalways).Theaboveillustrationmakesitclearthatlearningcurvesareanefficientwayofidentifyingoverfittingandunderfittingproblems,evenifthecrossvalidationmetricsmayfailtoidentifythem.MorefromTowardsDataScienceFollowYourhomefordatascience.AMediumpublicationsharingconcepts,ideasandcodes.ReadmorefromTowardsDataScienceRecommendedfromMediumActZeroinActZero.aiRecall&Precision:NottheWholeStoryonCybersecurityMachineLearningModelsRenaudBauvininCriteoR&DBlogAurélienGéronDeepLearningcrash-course&bonusinterview(part2/3)MonaFaceRecognitiononlivevideofromwebcamVandanaRajanAboutEigenValuesandVectors:Part1JellysmackLabsProjectTopicFinderDharmarajWhatisComputerVision?&ItsApplicationsJudyShihDeepLearning—ConvolutionalNeuralNetworksBasic101ShamaneSiriwardhanaPolicyGradients—PaperNoteAboutHelpTermsPrivacyGettheMediumappGetstartedKSVMuralidhar167FollowersDataScience|ML|Webscraping|Kaggler|Perpetuallearner|Out-of-the-boxThinker|Python|SQL|ExcelVBA|Tableau|LinkedIn:https://bit.ly/2VexKQuFollowMorefromMediumNimaBeheshtiinTowardsDataScienceCrossValidationandGridSearchabhinayarajaraminCodeXBeginnersGuidetoClassificationModels(CatchCreditCardFraud)EashanKaushikinRandomForestTheTrade-OffthatPlaguesallofMachineLearningRaheelHussaininDataDrivenInvestorDataTransformationinMachineLearningPart-IIHelpStatusWritersBlogCareersPrivacyTermsAboutKnowable
延伸文章資訊
- 1Why you should be plotting learning curves in your next ...
Learning curves show the relationship between training set size and your chosen evaluation metric...
- 2Learning Curves in Machine Learning - SpringerLink
A learning curve shows a measure of predictive performance on a given domain as a function of som...
- 3Learning Curves in Machine Learning - Baeldung
A learning curve is just a plot showing the progress over the experience of a specific metric rel...
- 4Machine Learning學習日記— Coursera篇(Week 6.2 ... - Medium
大綱. Diagnosing Bias vs. Variance; Regularization and Bias/Variance; Learning Curves; Deciding Wha...
- 5Learning curve (machine learning) - Wikipedia
In machine learning, a learning curve (or training curve) plots the optimal value of a model's lo...