Blog: Quantile loss function for machine learning
文章推薦指數: 80 %
This post introduces the powerful quantile loss regression, gives an intuitive explanation of why it works and solves an example in Keras. Skiptocontent TechBlog Quantilelossfunctionformachinelearning Quantilelossfunctionformachinelearning Motivation Itisnotalwayssufficientforamachinelearningmodeltomakeaccuratepredictions.Formanycommericalapplications,itisequallyimportanttohaveameasureofthepredictionuncertainty.Werecentlyworkedonaprojectwherepredictionsweresubjecttohighuncertainty.Theclientrequiredfortheirdecisiontobedrivenbyboththepredictedmachinelearningoutputandameasureofthepotentialpredictionerror.Thequantileregressionlossfunctionsolvesthisandsimilarproblemsbyreplacingasinglevaluepredictionbypredictionintervals.Thispostintroducesthepowerfulquantilelossregression,givesanintuitiveexplanationofwhyitworksandsolvesanexampleinKeras. Thequantileregressionlossfunction Machinelearningmodelsworkbyminimizing(ormaximizing)anobjectivefunction.Anobjectivefunctiontranslatestheproblemwearetryingtosolveintoamathematicalformulatobeminimizedbythemodel.Asthenamesuggests,thequantileregressionlossfunctionisappliedtopredictquantiles.Aquantileisthevaluebelowwhichafractionofobservationsinagroupfalls.Forexample,apredictionforquantile0.9shouldover-predict90%ofthetimes.Givenapredictionyipandoutcomeyi,theregressionlossforaquantileqisL(yip, yi) = max[q(yi − yip), (q − 1)(yi − yip)]Forasetofpredictions,thelosswillbetheaverage.AmathematicalderivationoftheaboveformulacanbefoundinQuantileRegressionarticleinWikiWand.Ifyouareinterestedinanintuitiveexplanation,readthefollowingsection.Ifyouarejustlookingtoapplythequantilelossfunctiontoadeepneuralnetwork,skiptotheexamplesectionbelow. Intuitiveexplanation Let’sstarttheintuitiveexplanationbyconsideringthemostcommonlyusedquantile,themedian.Ifqissubstitutedwith0.5intheequationabove,themeanabsoluteerrorfunctionisobtainedwhichpredictsthemedian.Thisisequivalenttosayingthatthemeanabsoluteerrorlossfunctionhasitsminimumatthemedian.Asimpleexampleisprobablytheeasiestapproachtoexplainwhythisisthecase.Considerthreepointsonaverticallineatdifferentdistancesfromeachother:upperpoint,middlepointandlowerpoint.Inthisone-dimensionalexample,theabsoluteerroristhesameasthedistance.Thehypothesistobeconfirmedisthatthemeanabsoluteerrorisminimumatthemedian(middlepoint).Tocheckourhypothesis,wewillstartatthemiddlepointandmoveupwardgettingclosertotheupperpointbutfurther,bythesamedistance,toboththemiddleandlowerpoints.Thiswillobviouslyincreasethemeanabsoluteerror(i.e.meandistancetothethreepoints).Thesameappliesifmovingdownwards.Ourhypothesisisconfirmedasthemiddlepointisboththemedianandtheminimumofthemeanabsolutelossfunction.Ifinsteadofhavingasingleupperpointandasinglelowerpoint,wehadonehundredpointsaboveandbelow,oranyotherarbitrarynumber,theresultstillstands.Intheregressionlossequationabove,asqhasavaluebetween0and1,thefirsttermwillbepositiveanddominatewhenunder-predicting,yi > yip,andthesecondtermwilldominatewhenover-predicting,yi
延伸文章資訊
- 1Quantile Regression — Part 2 - Medium
PyTorch. The loss function is implemented as a class: class QuantileLoss(nn.Module): def __init__...
- 2Quantile Regression Explained in 5 Minutes - SDS Club
- 3Prediction Intervals in Forecasting: Quantile Loss Function - Medium
- 4tfa.losses.PinballLoss | TensorFlow Addons
Computes the pinball loss between y_true and y_pred. ... this loss yields an estimator of the tau...
- 5Deep Quantile Regression | by Sachin Abeywardana
This loss function consistently estimates the median (50th percentile), instead of the mean. Mode...