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
Models
Clustering
HardClusteringModel.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Model for "hard" clustering.
6
*
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
* <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
#ifndef SHARK_MODELS_CLUSTERING_HARDCLUSTERINGMODEL_H
36
#define SHARK_MODELS_CLUSTERING_HARDCLUSTERINGMODEL_H
37
38
#include <
shark/Models/Clustering/ClusteringModel.h
>
39
40
namespace
shark
{
41
42
43
///
44
/// \brief Model for "hard" clustering.
45
///
46
/// \par
47
/// The HardClusteringModel is based on an AbstractClustering
48
/// object. Given an input, the model outputs the index of the
49
/// best matching cluster.
50
///
51
/// \par
52
/// See also SoftClusteringModel for general cluster membership.
53
///
54
template
<
class
InputT>
55
class
HardClusteringModel
:
public
ClusteringModel
<InputT, unsigned int>
56
{
57
typedef
ClusteringModel<InputT, unsigned int>
base_type
;
58
typedef
AbstractClustering<InputT>
ClusteringType
;
59
public
:
60
typedef
typename
base_type::BatchInputType
BatchInputType
;
61
typedef
typename
base_type::BatchOutputType
BatchOutputType
;
62
typedef
typename
base_type::InputType
InputType
;
63
typedef
typename
base_type::OutputType
OutputType
;
64
65
66
/// Constructor
67
HardClusteringModel
(ClusteringType* clustering)
68
: base_type(clustering){
69
}
70
71
/// \brief From INameable: return the class name.
72
std::string
name
()
const
73
{
return
"HardClusteringModel"
; }
74
75
using
ClusteringModel<InputT, unsigned int>::eval
;
76
77
Shape
inputShape
()
const
{
78
return
this->
mep_clustering
->
inputShape
();
79
}
80
Shape
outputShape
()
const
{
81
return
this->
mep_clustering
->
numberOfClusters
();
82
}
83
84
/// \brief Compute best matching cluster.
85
///
86
/// \par
87
/// The actual computation is redirected to the clustering object.
88
void
eval
(InputType
const
& pattern, OutputType& output)
const
{
89
output = this->
mep_clustering
->
hardMembership
(pattern);
90
}
91
92
/// \brief Compute best matching cluster for a batch of inputs.
93
///
94
/// \par
95
/// The actual computation is redirected to the clustering object.
96
void
eval
(BatchInputType
const
& patterns, BatchOutputType& outputs)
const
{
97
outputs = this->
mep_clustering
->
hardMembership
(patterns);
98
}
99
};
100
101
102
}
103
#endif