STK++ 0.9.13
STK_KmmBridge.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._DOT_I..._AT_stkpp.org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Clustering
27 * created on: 23 oct. 2014
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
36#ifndef STK_KMMBRIDGE_H
37#define STK_KMMBRIDGE_H
38
39#include "STK_Kmm_s.h"
40#include "STK_Kmm_sk.h"
41#include "../STK_IMixtureBridge.h"
42
43namespace STK
44{
45// forward declaration
46template<int Id, class Data> class KmmBridge;
47
48namespace hidden
49{
53template<class Data_>
54struct MixtureBridgeTraits< KmmBridge< Clust::Kmm_sk_, Data_> >
55{
56 typedef Data_ Data;
58 typedef typename Data_::Type Type;
60 typedef Kmm_sk Mixture;
64 typedef std::vector<std::pair<int,int> > MissingIndexes;
66 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
67 // class of mixture
68 enum
69 {
70 idMixtureClass_ = Clust::Kmm_
71 };
72};
73
77template<class Data_>
78struct MixtureBridgeTraits< KmmBridge< Clust::Kmm_s_, Data_> >
79{
80 typedef Data_ Data;
82 typedef typename Data_::Type Type;
84 typedef Kmm_s Mixture;
88 typedef std::vector<std::pair<int,int> > MissingIndexes;
90 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
91 // class of mixture
92 enum
93 {
94 idMixtureClass_ = Clust::Kmm_
95 };
96};
97
98} // namespace hidden
99
100} // namespace STK
101
102namespace STK
103{
116template<int Id, class Data>
117class KmmBridge: public IMixtureBridge< KmmBridge<Id,Data> >
118{
119 public:
123 typedef typename Data::Type Type;
124
125 // parameters type to get
126 using Base::mixture_;
127 using Base::p_tik;
128 using Base::p_tk;
129
141 virtual ~KmmBridge() {}
148 virtual KmmBridge* clone() const { return new KmmBridge(*this);}
154 virtual KmmBridge* create() const
155 {
156 KmmBridge* p_bridge = new KmmBridge( mixture_, this->idData(), this->nbCluster());
157 p_bridge->setDim(mixture_.param().dim_);
158 p_bridge->setKernel(mixture_.p_kernel());
159 return p_bridge;
160 }
162 inline void setDim(Real const& dim) { mixture_.setDim(dim);}
164 template<class Vector>
165 inline void setDim(ExprBase<Vector> const& dim)
166 {
168 mixture_.setDim(dim.asDerived());
169 }
171 inline void setKernel(Kernel::IKernel const* p_kernel) { mixture_.setKernel(p_kernel);}
172
174 virtual void imputationStep() {}
176 virtual void samplingStep() {}
177
180 Type safeValue( int j) const { return Type();}
181
182 private:
198 {}
199};
200
201} // namespace STK
202
203#endif /* STK_KMMBRIDGE_H */
In this file we define the Kmm_s class.
In this file we define the Kmm_sk class.
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
Interface base class for the bridges of the STK++ mixture.
hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Data Data
Mixture mixture_
The Mixture to bridge with the composer.
CPointX const * p_tk() const
This function can be used in derived classes to get proportions from the framework.
CArrayXX const * p_tik() const
This function can be used in derived classes to get posterior probabilities from the framework.
String const & idData() const
int nbCluster() const
This function can be used in derived classes to get number of classes.
Interface class for the kernels classes.
template implementation of the IMixture interface allowing to bridge a STK++ kernel mixture with the ...
virtual ~KmmBridge()
destructor
virtual void imputationStep()
do nothing for kernel mixture models
void setDim(Real const &dim)
set the dimension of the kernel mixture model
Type safeValue(int j) const
KmmBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Parameters Parameters
void setDim(ExprBase< Vector > const &dim)
set the dimension of the kernel mixture model using row vector
virtual KmmBridge * clone() const
This is a standard clone function in usual sense.
IMixtureBridge< KmmBridge< Id, Data > > Base
void setKernel(Kernel::IKernel const *p_kernel)
set the kernel
void initializeBridge()
This function will be used in order to initialize the mixture model using informations stored by the ...
KmmBridge(KmmBridge const &bridge)
copy constructor
Data::Type Type
virtual KmmBridge * create() const
This is a standard create function in usual sense.
virtual void samplingStep()
do nothing for kernel mixture models
KmmBridge(Data *p_dataij, String const &idData, int nbCluster)
default constructor.
hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Mixture Mixture
The Gaussian mixture model Kmm_s is an isotrope Gaussian mixture model on a kernel space.
Definition STK_Kmm_s.h:74
The Gaussian mixture model Kmm_sk is an isotrope Gaussian mixture model on a kernel space.
Definition STK_Kmm_sk.h:76
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
std::basic_string< Char > String
STK fundamental type of a String.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
ModelParameters< Clust::Kmm_s_ > Parameters
Type of the structure storing the mixture parameters.
std::vector< std::pair< std::pair< int, int >, Type > > MissingValues
Type of the array storing missing values.
std::vector< std::pair< int, int > > MissingIndexes
Type of the array storing missing values indexes.
ModelParameters< Clust::Kmm_sk_ > Parameters
Type of the structure storing the mixture parameters.
std::vector< std::pair< int, int > > MissingIndexes
Type of the array storing missing values indexes.
std::vector< std::pair< std::pair< int, int >, Type > > MissingValues
Type of the array storing missing values.
MixtureBridgeTraits struct for bridged mixtures The traits struct MixtureBridgeTraits must be special...