STK++ 0.9.13
STK_GammaBridge.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: 15 nov. 2013
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 * Originally created by Parmeet Bhatia <b..._DOT_p..._AT_gmail_Dot_com>
30 **/
31
37#ifndef STK_GAMMABRIDGE_H
38#define STK_GAMMABRIDGE_H
39
40#include "STK_Gamma_a_bjk.h"
41#include "STK_Gamma_a_bk.h"
42#include "STK_Gamma_aj_bjk.h"
43#include "STK_Gamma_aj_bk.h"
44#include "STK_Gamma_ajk_b.h"
45#include "STK_Gamma_ajk_bj.h"
46#include "STK_Gamma_ajk_bjk.h"
47#include "STK_Gamma_ajk_bk.h"
48#include "STK_Gamma_ak_b.h"
49#include "STK_Gamma_ak_bj.h"
50#include "STK_Gamma_ak_bjk.h"
51#include "STK_Gamma_ak_bk.h"
52#include "../STK_IMixtureBridge.h"
53
54namespace STK
55{
56
57// forward declaration
58template<int Id, class Data> class GammaBridge;
59
60namespace hidden
61{
65template<class Data_>
66struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ajk_bjk_, Data_> >
67{
68 typedef Data_ Data;
70 typedef typename Data_::Type Type;
76 typedef std::vector<std::pair<int,int> > MissingIndexes;
78 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
79 enum
80 {
81 idMixtureClass_ = Clust::Gamma_
82 };
83};
87template<class Data_>
88struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ajk_bk_, Data_> >
89{
90 typedef Data_ Data;
92 typedef typename Data_::Type Type;
98 typedef std::vector<std::pair<int,int> > MissingIndexes;
100 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
101 enum
102 {
103 idMixtureClass_ = Clust::Gamma_
104 };
105};
109template<class Data_>
110struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ajk_bj_, Data_> >
111{
112 typedef Data_ Data;
114 typedef typename Data_::Type Type;
120 typedef std::vector<std::pair<int,int> > MissingIndexes;
122 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
123 enum
124 {
125 idMixtureClass_ = Clust::Gamma_
126 };
127};
131template<class Data_>
132struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ajk_b_, Data_> >
133{
134 typedef Data_ Data;
136 typedef typename Data_::Type Type;
142 typedef std::vector<std::pair<int,int> > MissingIndexes;
144 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
145 enum
146 {
147 idMixtureClass_ = Clust::Gamma_
148 };
149};
153template<class Data_>
154struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ak_bjk_, Data_> >
155{
156 typedef Data_ Data;
158 typedef typename Data_::Type Type;
164 typedef std::vector<std::pair<int,int> > MissingIndexes;
166 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
167 enum
168 {
169 idMixtureClass_ = Clust::Gamma_
170 };
171};
175template<class Data_>
176struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ak_bk_, Data_> >
177{
178 typedef Data_ Data;
180 typedef typename Data_::Type Type;
186 typedef std::vector<std::pair<int,int> > MissingIndexes;
188 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
189 enum
190 {
191 idMixtureClass_ = Clust::Gamma_
192 };
193};
197template<class Data_>
198struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ak_bj_, Data_> >
199{
200 typedef Data_ Data;
202 typedef typename Data_::Type Type;
208 typedef std::vector<std::pair<int,int> > MissingIndexes;
210 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
211 enum
212 {
213 idMixtureClass_ = Clust::Gamma_
214 };
215};
219template<class Data_>
220struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_ak_b_, Data_> >
221{
222 typedef Data_ Data;
224 typedef typename Data_::Type Type;
230 typedef std::vector<std::pair<int,int> > MissingIndexes;
232 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
233 enum
234 {
235 idMixtureClass_ = Clust::Gamma_
236 };
237};
241template<class Data_>
242struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_aj_bjk_, Data_> >
243{
244 typedef Data_ Data;
246 typedef typename Data_::Type Type;
252 typedef std::vector<std::pair<int,int> > MissingIndexes;
254 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
255 enum
256 {
257 idMixtureClass_ = Clust::Gamma_
258 };
259};
263template<class Data_>
264struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_aj_bk_, Data_> >
265{
266 typedef Data_ Data;
268 typedef typename Data_::Type Type;
274 typedef std::vector<std::pair<int,int> > MissingIndexes;
276 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
277 enum
278 {
279 idMixtureClass_ = Clust::Gamma_
280 };
281};
285template<class Data_>
286struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_a_bjk_, Data_> >
287{
288 typedef Data_ Data;
290 typedef typename Data_::Type Type;
296 typedef std::vector<std::pair<int,int> > MissingIndexes;
298 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
299 enum
300 {
301 idMixtureClass_ = Clust::Gamma_
302 };
303};
307template<class Data_>
308struct MixtureBridgeTraits< GammaBridge< Clust::Gamma_a_bk_, Data_> >
309{
310 typedef Data_ Data;
312 typedef typename Data_::Type Type;
318 typedef std::vector<std::pair<int,int> > MissingIndexes;
320 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
321 enum
322 {
323 idMixtureClass_ = Clust::Gamma_
324 };
325};
326
327} // namespace hidden
328
339template<int Id, class Data>
340class GammaBridge: public IMixtureBridge< GammaBridge<Id,Data> >
341{
342 public:
343 // Base class
345 // type of Mixture
348 // type of data
349 typedef typename Data::Type Type;
350 // class of mixture
351 enum
352 {
354 };
355 typedef std::vector<std::pair<int,int> >::const_iterator ConstIterator;
356 using Base::mixture_;
357 using Base::p_dataij_;
358 using Base::p_tik;
359 using Base::v_missing_;
361
370 {
371 removeMissing(); // remove missing from data only once at creation
372 mixture_.setData(*p_dataij_);
373 }
377// { mixture_.setData(*p_dataij_);}
379 virtual ~GammaBridge() {}
386 virtual GammaBridge* clone() const { return new GammaBridge(*this);}
392 virtual GammaBridge* create() const
393 {
394 GammaBridge* p_bridge = new GammaBridge( mixture_, this->idData(), this->nbCluster());
395 p_bridge->p_dataij_ = p_dataij_;
396 p_bridge->mixture_.setData(*p_dataij_);
397 p_bridge->v_missing_ = v_missing_;
398 return p_bridge;
399 }
402 Type safeValue( int j) const
403 { return p_dataij_->col(j).safe(1).mean();}
404
405 private:
414};
415
416} // namespace STK
417
418#endif /* STK_GAMMABRIDGE_H */
In this file we define the Gamma_pk_a_bjk and Gamma_p_a_bjk models.
In this file we define the Gamma_pk_a_bk and Gamma_p_a_bk models.
In this file we define the Gamma_pk_aj_bjk and Gamma_p_aj_bjk models.
In this file we define the Gamma_pk_aj_bk and Gamma_p_aj_bk models.
In this file we define the Gamma_pk_ajk_b and Gamma_p_ajk_b mixture models.
In this file we define the Gamma_pk_ajk_bj and Gamma_p_ajk_bj mixture models.
In this file we define the Gamma_pk_ajk_bjk and Gamma_p_ajk_bjk models.
In this file we define the Gamma_pk_ajk_bk and Gamma_p_ajk_bk models.
In this file we define the Gamma_pk_ak_b and Gamma_p_ak_b mixture models.
In this file we define the Gamma_pk_ak_bj and Gamma_p_ak_bj mixture models.
In this file we define the Gamma_pk_ak_bjk and Gamma_p_ak_bjk models.
In this file we define the Gamma_pk_ak_bk and Gamma_p_ak_bk models.
template implementation of the IMixtureBridge interface allowing to bridge a STK++ mixture with the c...
hidden::MixtureBridgeTraits< GammaBridge< Id, Data > >::Parameters Parameters
Type safeValue(int j) const
GammaBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
IMixtureBridge< GammaBridge< Id, Data > > Base
GammaBridge(Data *p_dataij, String const &idData, int nbCluster)
default constructor.
virtual GammaBridge * create() const
This is a standard create function in usual sense.
GammaBridge(GammaBridge const &bridge)
copy constructor
virtual GammaBridge * clone() const
This is a standard clone function in usual sense.
virtual ~GammaBridge()
destructor
hidden::MixtureBridgeTraits< GammaBridge< Id, Data > >::Mixture Mixture
std::vector< std::pair< int, int > >::const_iterator ConstIterator
Interface base class for the bridges of the STK++ mixture.
MissingIndexes v_missing_
vector with the coordinates of the missing values
hidden::MixtureBridgeTraits< GammaBridge< Id, Data > >::Data Data
virtual void removeMissing()
This function will be used once for imputation of missing data at the initialization step (.
Mixture mixture_
The Mixture to bridge with the composer.
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.
virtual void setData(YArray_ const &y, XArray_ const &x)
set the data set.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
std::basic_string< Char > String
STK fundamental type of a String.
The namespace STK is the main domain space of the Statistical ToolKit project.
ModelParameters< Clust::Gamma_a_bjk_ > 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.
ModelParameters< Clust::Gamma_a_bk_ > 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.
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.
ModelParameters< Clust::Gamma_aj_bjk_ > 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.
ModelParameters< Clust::Gamma_aj_bk_ > Parameters
Type of the structure storing the mixture parameters.
ModelParameters< Clust::Gamma_ajk_b_ > 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::Gamma_ajk_bj_ > 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.
std::vector< std::pair< std::pair< int, int >, Type > > MissingValues
Type of the array storing missing values.
ModelParameters< Clust::Gamma_ajk_bjk_ > 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.
ModelParameters< Clust::Gamma_ajk_bk_ > Parameters
Type of the structure storing the mixture parameters.
std::vector< std::pair< int, int > > MissingIndexes
Type of the array storing missing values indexes.
ModelParameters< Clust::Gamma_ak_b_ > 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.
std::vector< std::pair< int, int > > MissingIndexes
Type of the array storing missing values indexes.
ModelParameters< Clust::Gamma_ak_bj_ > 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::Gamma_ak_bjk_ > 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< 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::Gamma_ak_bk_ > Parameters
Type of the structure storing the mixture parameters.
MixtureBridgeTraits struct for bridged mixtures The traits struct MixtureBridgeTraits must be special...