Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
include
shark
Models
Clustering
ClusteringModel.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Super class for clustering models.
6
* \file
7
*
8
*
9
* \author T. Glasmachers
10
* \date 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
35
#ifndef SHARK_MODELS_CLUSTERING_CLUSTERINGMODEL_H
36
#define SHARK_MODELS_CLUSTERING_CLUSTERINGMODEL_H
37
38
39
#include <
shark/Models/Clustering/AbstractClustering.h
>
40
#include <
shark/Models/AbstractModel.h
>
41
42
43
namespace
shark
{
44
45
/// \brief Abstract model with associated clustering object.
46
///
47
/// See HardClusteringModel and SoftClusteringModel for details and \ref clustering for possible clusterings
48
///
49
/// \ingroup clustering
50
template
<
class
InputT,
class
OutputT>
51
class
ClusteringModel
:
public
AbstractModel
<InputT, OutputT>
52
{
53
public
:
54
typedef
AbstractModel<InputT, OutputT>
base_type
;
55
typedef
AbstractClustering<InputT>
ClusteringType
;
56
typedef
typename
base_type::BatchInputType
BatchInputType
;
57
typedef
typename
base_type::BatchOutputType
BatchOutputType
;
58
59
/// Constructor.
60
ClusteringModel
(
ClusteringType
* clustering)
61
:
mep_clustering
(clustering)
62
{
SHARK_RUNTIME_CHECK
(clustering,
"[ClusteringModel] Clustering must not be NULL"
); }
63
64
65
/// Redirect parameter access to the clustering object
66
RealVector
parameterVector
()
const
67
{
return
mep_clustering
->
parameterVector
(); }
68
69
/// Redirect parameter access to the clustering object
70
void
setParameterVector
(RealVector
const
& newParameters)
71
{
mep_clustering
->
setParameterVector
(newParameters); }
72
73
/// Redirect parameter access to the clustering object
74
std::size_t
numberOfParameters
()
const
75
{
return
mep_clustering
->
numberOfParameters
(); }
76
77
/// From ISerializable, reads a model from an archive.
78
void
read
(
InArchive
& archive)
79
{ archive & *
mep_clustering
; }
80
81
/// From ISerializable, writes a model to an archive.
82
void
write
(
OutArchive
& archive)
const
83
{ archive & *
mep_clustering
; }
84
85
using
base_type::eval
;
86
void
eval
(
BatchInputType
const
& patterns,
BatchOutputType
& outputs,
State
& state)
const
{
87
eval
(patterns,outputs);
88
}
89
90
protected
:
91
/// Clustering object, see class AbstractClustering
92
ClusteringType
*
mep_clustering
;
93
};
94
95
96
}
97
#endif