SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 }
float64_t loss(float64_t prediction, float64_t label)
Definition: HingeLoss.cpp:22
virtual float64_t get_update(float64_t prediction, float64_t label, float64_t eta_t, float64_t norm)
Definition: HingeLoss.cpp:54
double float64_t
Definition: common.h:50
static T max(T a, T b)
Definition: Math.h:168
virtual float64_t second_derivative(float64_t prediction, float64_t label)
Definition: HingeLoss.cpp:44
virtual float64_t first_derivative(float64_t prediction, float64_t label)
Definition: HingeLoss.cpp:34
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t get_square_grad(float64_t prediction, float64_t label)
Definition: HingeLoss.cpp:63

SHOGUN Machine Learning Toolbox - Documentation