Vowpal Wabbit
Public Member Functions | Public Attributes | List of all members
quantileloss Class Reference
Inheritance diagram for quantileloss:
loss_function

Public Member Functions

 quantileloss (float &tau_)
 
std::string getType ()
 
float getLoss (shared_data *, float prediction, float label)
 
float getUpdate (float prediction, float label, float update_scale, float pred_per_update)
 
float getUnsafeUpdate (float prediction, float label, float update_scale)
 
float getRevertingWeight (shared_data *sd, float prediction, float eta_t)
 
float first_derivative (shared_data *, float prediction, float label)
 
float getSquareGrad (float prediction, float label)
 
float second_derivative (shared_data *, float, float)
 
- Public Member Functions inherited from loss_function
virtual ~loss_function ()
 

Public Attributes

float tau
 

Detailed Description

Definition at line 231 of file loss_functions.cc.

Constructor & Destructor Documentation

◆ quantileloss()

quantileloss::quantileloss ( float &  tau_)
inline

Definition at line 234 of file loss_functions.cc.

234 : tau(tau_) {}

Member Function Documentation

◆ first_derivative()

float quantileloss::first_derivative ( shared_data ,
float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 286 of file loss_functions.cc.

287  {
288  float e = label - prediction;
289  if (e == 0)
290  return 0;
291  return e > 0 ? -tau : (1 - tau);
292  }

◆ getLoss()

float quantileloss::getLoss ( shared_data ,
float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 238 of file loss_functions.cc.

239  {
240  float e = label - prediction;
241  if (e > 0)
242  return tau * e;
243  else
244  return -(1 - tau) * e;
245  }

◆ getRevertingWeight()

float quantileloss::getRevertingWeight ( shared_data sd,
float  prediction,
float  eta_t 
)
inlinevirtual

Implements loss_function.

Definition at line 275 of file loss_functions.cc.

References shared_data::max_label, and shared_data::min_label.

276  {
277  float v, t;
278  t = 0.5f * (sd->min_label + sd->max_label);
279  if (prediction > t)
280  v = -(1 - tau);
281  else
282  v = tau;
283  return (t - prediction) / (eta_t * v);
284  }
float min_label
Definition: global_data.h:150
float max_label
Definition: global_data.h:151

◆ getSquareGrad()

float quantileloss::getSquareGrad ( float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 294 of file loss_functions.cc.

References squaredloss::first_derivative().

295  {
296  float fd = first_derivative(nullptr, prediction, label);
297  return fd * fd;
298  }
float first_derivative(shared_data *, float prediction, float label)

◆ getType()

std::string quantileloss::getType ( )
inlinevirtual

Implements loss_function.

Definition at line 236 of file loss_functions.cc.

236 { return "quantile"; }

◆ getUnsafeUpdate()

float quantileloss::getUnsafeUpdate ( float  prediction,
float  label,
float  update_scale 
)
inlinevirtual

Implements loss_function.

Definition at line 265 of file loss_functions.cc.

266  {
267  float err = label - prediction;
268  if (err == 0)
269  return 0;
270  if (err > 0)
271  return tau * update_scale;
272  return -(1 - tau) * update_scale;
273  }

◆ getUpdate()

float quantileloss::getUpdate ( float  prediction,
float  label,
float  update_scale,
float  pred_per_update 
)
inlinevirtual

Implements loss_function.

Definition at line 247 of file loss_functions.cc.

248  {
249  float err = label - prediction;
250  if (err == 0)
251  return 0;
252  float normal = update_scale * pred_per_update; // base update size
253  if (err > 0)
254  {
255  normal = tau * normal;
256  return (normal < err ? tau * update_scale : err / pred_per_update);
257  }
258  else
259  {
260  normal = -(1 - tau) * normal;
261  return (normal > err ? (tau - 1) * update_scale : err / pred_per_update);
262  }
263  }

◆ second_derivative()

float quantileloss::second_derivative ( shared_data ,
float  ,
float   
)
inlinevirtual

Implements loss_function.

Definition at line 300 of file loss_functions.cc.

300 { return 0.; }

Member Data Documentation

◆ tau

float quantileloss::tau

Definition at line 302 of file loss_functions.cc.


The documentation for this class was generated from the following file: