SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SquaredLoss.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3  embodied in the content of this file are licensed under the BSD
4  (revised) open source license.
5 
6  Copyright (c) 2011 Berlin Institute of Technology and Max-Planck-Society.
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  Modifications (w) 2011 Shashwat Lal Das
14 */
15 
18 
19 using namespace shogun;
20 
22 {
23  float64_t example_loss = (prediction - label) * (prediction - label);
24 
25  return example_loss;
26 }
27 
29 {
30  return 2. * (prediction - label);
31 }
32 
34 {
35  return 2;
36 }
37 
39 {
40  if (eta_t < 1e-6)
41  {
42  /* When exp(-eta_t)~= 1 we replace 1-exp(-eta_t)
43  * with its first order Taylor expansion around 0
44  * to avoid catastrophic cancellation.
45  */
46  return (label - prediction)*eta_t/norm;
47  }
48  return (label - prediction)*(1-exp(-eta_t))/norm;
49 }
50 
52 {
53  return (prediction - label) * (prediction - label);
54 }

SHOGUN Machine Learning Toolbox - Documentation