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

Public Member Functions

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 *, float, float)
 
float getSquareGrad (float prediction, float label)
 
float first_derivative (shared_data *, float prediction, float label)
 
float second_derivative (shared_data *, float prediction, float)
 
- Public Member Functions inherited from loss_function
virtual ~loss_function ()
 

Detailed Description

Definition at line 305 of file loss_functions.cc.

Member Function Documentation

◆ first_derivative()

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

Implements loss_function.

Definition at line 350 of file loss_functions.cc.

351  {
352  float exp_prediction = expf(prediction);
353  return (exp_prediction - label);
354  }

◆ getLoss()

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

Implements loss_function.

Definition at line 310 of file loss_functions.cc.

References f.

311  {
312  if (label < 0.f)
313  std::cout << "You are using label " << label << " but loss function expects label >= 0!" << std::endl;
314  float exp_prediction = expf(prediction);
315  // deviance is used instead of log-likelihood
316  return 2 * (label * (logf(label + 1e-6f) - prediction) - (label - exp_prediction));
317  }
float f
Definition: cache.cc:40

◆ getRevertingWeight()

float poisson_loss::getRevertingWeight ( shared_data ,
float  ,
float   
)
inlinevirtual

Implements loss_function.

Definition at line 339 of file loss_functions.cc.

References THROW.

340  {
341  THROW("Active learning not supported by poisson loss");
342  }
#define THROW(args)
Definition: vw_exception.h:181

◆ getSquareGrad()

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

Implements loss_function.

Definition at line 344 of file loss_functions.cc.

345  {
346  float exp_prediction = expf(prediction);
347  return (exp_prediction - label) * (exp_prediction - label);
348  }

◆ getType()

std::string poisson_loss::getType ( )
inlinevirtual

Implements loss_function.

Definition at line 308 of file loss_functions.cc.

308 { return "poisson"; }

◆ getUnsafeUpdate()

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

Implements loss_function.

Definition at line 333 of file loss_functions.cc.

334  {
335  float exp_prediction = expf(prediction);
336  return (label - exp_prediction) * update_scale;
337  }

◆ getUpdate()

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

Implements loss_function.

Definition at line 319 of file loss_functions.cc.

320  {
321  float exp_prediction = expf(prediction);
322  if (label > 0)
323  {
324  return label * update_scale -
325  log1p(exp_prediction * expm1(label * update_scale * pred_per_update) / label) / pred_per_update;
326  }
327  else
328  {
329  return -log1p(exp_prediction * update_scale * pred_per_update) / pred_per_update;
330  }
331  }

◆ second_derivative()

float poisson_loss::second_derivative ( shared_data ,
float  prediction,
float   
)
inlinevirtual

Implements loss_function.

Definition at line 356 of file loss_functions.cc.

357  {
358  float exp_prediction = expf(prediction);
359  return exp_prediction;
360  }

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