diff options
author | John Langford <jl@hunch.net> | 2010-09-25 20:11:55 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2010-09-25 20:11:55 +0400 |
commit | 45d7ce790279f3d1f5f20d7cecdefbbdbe48ac4e (patch) | |
tree | b7de3b140b3fe027de2544d6483acabf4fb94eee /loss_functions.cc | |
parent | c4ffedff066dab399b9c031d1d907022e9fd0d93 (diff) |
initial per-feature learning rate from Nikos
Diffstat (limited to 'loss_functions.cc')
-rw-r--r-- | loss_functions.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/loss_functions.cc b/loss_functions.cc index 5ce20b2a..f9d8885a 100644 --- a/loss_functions.cc +++ b/loss_functions.cc @@ -37,6 +37,11 @@ public: float alternative = (prediction > 0.5) ? 0 : 1; return log((alternative-prediction)/(alternative-0.5))/eta_t; } + + float getSquareGrad(float prediction, float label) { + return (prediction - label) * (prediction - label); + } + }; class classic_squaredloss : public loss_function { @@ -58,6 +63,11 @@ public: float alternative = (prediction > 0.5) ? 0 : 1; return log((alternative-prediction)/(alternative-0.5))/eta_t; } + + float getSquareGrad(float prediction, float label) { + return (prediction - label) * (prediction - label); + } + }; @@ -82,6 +92,10 @@ public: float getRevertingWeight(float prediction, float eta_t){ return fabs(prediction)/eta_t; } + + float getSquareGrad(float prediction, float label) { + return (label*prediction >= label*label) ? 0 : 1; + } }; class logloss : public loss_function { @@ -138,6 +152,12 @@ public: float z = -fabs(prediction); return (1-z-exp(z))/eta_t; } + + float getSquareGrad(float prediction, float label) { + float d = 1./(1+exp(label * prediction)); + return d*d; + } + }; class quantileloss : public loss_function { @@ -180,6 +200,12 @@ public: } return (alternative - prediction)/(eta_t*v); } + + float getSquareGrad(float prediction, float label) { + float e = label - prediction; + if(e == 0) return 0; + return e > 0 ? tau*tau : (1-tau)*(1-tau); + } double tau; }; |