Shark machine learning library
About Shark
News!
Contribute
Credits and copyright
Downloads
Getting Started
Installation
Using the docs
Documentation
Tutorials
Quick references
Class list
Global functions
FAQ
Showroom
include
shark
Algorithms
Trainers
SigmoidFit.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Optimization of the SigmoidModel according to Platt, 1999.
6
*
7
*
8
*
9
* \author T. Glasmachers, O.Krause
10
* \date 2010
11
*
12
*
13
* \par Copyright 1995-2017 Shark Development Team
14
*
15
* <BR><HR>
16
* This file is part of Shark.
17
* <http://shark-ml.org/>
18
*
19
* Shark is free software: you can redistribute it and/or modify
20
* it under the terms of the GNU Lesser General Public License as published
21
* by the Free Software Foundation, either version 3 of the License, or
22
* (at your option) any later version.
23
*
24
* Shark is distributed in the hope that it will be useful,
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
* GNU Lesser General Public License for more details.
28
*
29
* You should have received a copy of the GNU Lesser General Public License
30
* along with Shark. If not, see <http://www.gnu.org/licenses/>.
31
*
32
*/
33
//===========================================================================
34
35
36
#ifndef SHARK_ALGORITHMS_TRAINERS_SIGMOIDFIT_H
37
#define SHARK_ALGORITHMS_TRAINERS_SIGMOIDFIT_H
38
39
#include <
shark/Core/DLLSupport.h
>
40
#include <
shark/Algorithms/Trainers//AbstractTrainer.h
>
41
#include <
shark/Models/SigmoidModel.h
>
42
43
namespace
shark
{
44
45
46
//! \brief Optimizes the parameters of a sigmoid to fit a validation dataset via backpropagation on the negative log-likelihood.
47
//!
48
//! \par
49
//! The SigmoidFitPlatt class implements a non-iterative optimizer,
50
//! despite the optimization task and optimizer being iterative in nature.
51
//! This class simply relies on a user-definable number of Rprop optimization steps
52
//! to adapt the sigmoid parameters.
53
//!
54
class
SigmoidFitRpropNLL
:
public
AbstractTrainer
<SigmoidModel, unsigned int>
55
{
56
public
:
57
SHARK_EXPORT_SYMBOL
SigmoidFitRpropNLL
(
unsigned
int
iters = 100 );
58
59
/// \brief From INameable: return the class name.
60
std::string
name
()
const
61
{
return
"SigmoidFitRpropNLL"
; }
62
63
SHARK_EXPORT_SYMBOL
void
train
(
SigmoidModel
& model,
LabeledData<RealVector, unsigned int>
const
& dataset);
64
65
private
:
66
unsigned
int
m_iterations;
67
};
68
69
70
//!
71
//! \brief Optimizes the parameters of a sigmoid to fit a validation dataset via Platt's method.
72
//!
73
//! \par
74
//! The SigmoidFitPlatt class implements a non-iterative optimizer,
75
//! despite the optimization task and optimizer being iterative in nature.
76
//! The algorithm corresponds to the one suggested by John Platt in
77
//! 1999, and is almost literally taken from <br> <i>Probabilistic Outputs for
78
//! Support Vector Machines and Comparisons to Regularized Likelihood Methods,
79
//! Advances in Large Margin Classifiers, pp. 61-74,
80
//! MIT Press, (1999).</i><br>
81
//! The full paper can be downloaded from<br>
82
//! <i>http://www.research.microsoft.com/~jplatt</i><br>
83
//! --- pseudo-code is given in the paper.
84
//!
85
class
SigmoidFitPlatt
:
public
AbstractTrainer
<SigmoidModel, unsigned int>
86
{
87
public
:
88
SHARK_EXPORT_SYMBOL
void
train
(
SigmoidModel
& model,
LabeledData<RealVector, unsigned int>
const
& dataset);
89
90
/// \brief From INameable: return the class name.
91
std::string
name
()
const
92
{
return
"SigmoidFitPlatt"
; }
93
};
94
95
96
}
97
#endif