SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HingeLoss.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 
17 #include <shogun/loss/HingeLoss.h>
19 
20 using namespace shogun;
21 
23 {
24  float64_t e = 1 - label * prediction;
25 
26  return (e > 0) ? e : 0;
27 }
28 
30 {
31  return CMath::max(0.0, z);
32 }
33 
35 {
36  return (label * prediction >= label * label) ? 0 : -label;
37 }
38 
40 {
41  return z > 0.0 ? 1.0 : 0.0;
42 }
43 
45 {
46  return 0.;
47 }
48 
50 {
51  return 0;
52 }
53 
55 {
56  if (label * prediction >= label * label)
57  return 0;
58  float64_t err = (label*label - label*prediction)/(label * label);
59  float64_t normal = eta_t;
60  return label * (normal < err ? normal : err)/norm;
61 }
62 
64 {
65  return first_derivative(prediction, label);
66 }

SHOGUN Machine Learning Toolbox - Documentation