AbstractTrainer.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Abstract Trainer Interface.
6 *
7 *
8 * \file
9 * \author O. Krause, T.Glasmachers
10 * \date 2010-2011
11 *
12 *
13 * \par Copyright 1995-2017 Shark Development Team
14 *
15 * <BR><HR>
16 * This file is part of Shark.
17 * <https://shark-ml.github.io/Shark/>
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#ifndef SHARK_ALGORITHMS_TRAINERS_ABSTRACTTRAINER_H
35#define SHARK_ALGORITHMS_TRAINERS_ABSTRACTTRAINER_H
36
39#include <shark/Data/Dataset.h>
41
42namespace shark {
43
44
45/// \defgroup supervised_trainer Supervised Trainers
46/// \brief Optimized algorithms to solve specialized supervised optimization problems
47///
48/// A supervised problem consists of data with inputs and labels. Typical tasks are regression, ranking, or classification.
49
50/// \defgroup unsupervised_trainer Unsupervised Trainers
51/// \brief Optimized algorithms to solve specialized unsupervised optimization problems
52///
53/// A supervised problem consists only of input data. Typical tasks are normalization distribution learning
54
55
56///
57/// \brief Superclass of supervised learning algorithms
58///
59/// \par
60/// AbstractTrainer is the super class of all trainers,
61/// i.e., procedures for training or learning model
62/// parameters. It provides a single virtual function to
63/// train the model.
64///
65/// \par
66/// Note: Most learning algorithms of this type operate on
67/// a special model type, such as a linear model, a kernel
68/// expansion, etc. Thus, these algorithms should provide
69/// a specialized train method accepting only this model
70/// type. The virtual train method should be overriden
71/// with a method that checks the type of the model and
72/// calls the specialized train method.
73/// \ingroup supervised_trainer
74template <class Model, class LabelTypeT = typename Model::OutputType>
76{
77public:
78 typedef Model ModelType;
79 typedef typename ModelType::InputType InputType;
80 typedef LabelTypeT LabelType;
82 /// Core of the Trainer interface
83 virtual void train(ModelType& model, DatasetType const& dataset) = 0;
84};
85
86
87///
88/// \brief Superclass of unsupervised learning algorithms
89///
90/// \par
91/// AbstractUnsupervisedTrainer is the superclass of all
92/// unsupervised learning algorithms. It consists of a
93/// single virtual function to train the model.
94///
95/// \par
96/// Note: Most learning algorithms of this type operate on
97/// a special model type, such as a linear model, a kernel
98/// expansion, or a nearest neighbor model. Thus, these
99/// algorithms should provide a specialized train method
100/// that accepts only this model type. The virtual train
101/// method should be overriden with a method that checks
102/// the type of the model and calls the specialized train
103/// method.
104/// \ingroup unsupervised_trainer
105template <class Model>
107{
108public:
109 typedef Model ModelType;
110 typedef typename Model::InputType InputType;
112 /// Core of the Trainer interface
113 virtual void train(ModelType& model, DatasetType const& inputset) = 0;
114};
115
116
117}
118#endif