SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 */
15 
16 #include <shogun/loss/HingeLoss.h>
17 
18 using namespace shogun;
19 
21 {
22  float64_t e = 1 - label * prediction;
23 
24  return (e > 0) ? e : 0;
25 }
26 
28 {
29  return (label * prediction >= label * label) ? 0 : -label;
30 }
31 
33 {
34  return 0.;
35 }
36 
38 {
39  if (label * prediction >= label * label)
40  return 0;
41  float64_t err = (label*label - label*prediction)/(label * label);
42  float64_t normal = eta_t;
43  return label * (normal < err ? normal : err)/norm;
44 }
45 
47 {
48  return first_derivative(prediction, label);
49 }

SHOGUN Machine Learning Toolbox - Documentation