SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  Modifications (w) 2012 Fernando José Iglesias García
15 */
16 
19 
20 using namespace shogun;
21 
23 {
24  return (prediction - label) * (prediction - label);
25 }
26 
28 {
29  return z*z;
30 }
31 
33 {
34  return 2. * (prediction - label);
35 }
36 
38 {
39  return 2. * z;
40 }
41 
43 {
44  return 2;
45 }
46 
48 {
49  return 2;
50 }
51 
53 {
54  if (eta_t < 1e-6)
55  {
56  /* When exp(-eta_t)~= 1 we replace 1-exp(-eta_t)
57  * with its first order Taylor expansion around 0
58  * to avoid catastrophic cancellation.
59  */
60  return (label - prediction)*eta_t/norm;
61  }
62  return (label - prediction)*(1-exp(-eta_t))/norm;
63 }
64 
66 {
67  return (prediction - label) * (prediction - label);
68 }

SHOGUN Machine Learning Toolbox - Documentation