STK++ 0.9.13
STK_DiagGaussianBridge.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_DIAGGAUSSIANBRIDGE_H
38#define STK_DIAGGAUSSIANBRIDGE_H
39
42#include "STK_DiagGaussian_s.h"
43#include "STK_DiagGaussian_sj.h"
44#include "STK_DiagGaussian_sk.h"
45#include "../STK_IMixtureBridge.h"
46
47namespace STK
48{
49
50// forward declaration
51template<int Id, class Data> class DiagGaussianBridge;
52
53namespace hidden
54{
58template<class Data_>
59struct MixtureBridgeTraits< DiagGaussianBridge< Clust::Gaussian_sjk_, Data_> >
60{
61 typedef Data_ Data;
63 typedef typename Data_::Type Type;
69 typedef std::vector<std::pair<int,int> > MissingIndexes;
71 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
72 enum
73 {
74 idMixtureClass_ = Clust::DiagGaussian_
75 };
76};
80template<class Data_>
81struct MixtureBridgeTraits< DiagGaussianBridge< Clust::Gaussian_sk_, Data_> >
82{
83 typedef Data_ Data;
85 typedef typename Data_::Type Type;
91 typedef std::vector<std::pair<int,int> > MissingIndexes;
93 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
94 enum
95 {
96 idMixtureClass_ = Clust::DiagGaussian_
97 };
98};
102template<class Data_>
103struct MixtureBridgeTraits< DiagGaussianBridge< Clust::Gaussian_sj_, Data_> >
104{
105 typedef Data_ Data;
107 typedef typename Data_::Type Type;
113 typedef std::vector<std::pair<int,int> > MissingIndexes;
115 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
116 enum
117 {
118 idMixtureClass_ = Clust::DiagGaussian_
119 };
120};
124template<class Data_>
125struct MixtureBridgeTraits< DiagGaussianBridge< Clust::Gaussian_sjsk_, Data_> >
126{
127 typedef Data_ Data;
129 typedef typename Data_::Type Type;
135 typedef std::vector<std::pair<int,int> > MissingIndexes;
137 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
138 enum
139 {
140 idMixtureClass_ = Clust::DiagGaussian_
141 };
142};
146template<class Data_>
147struct MixtureBridgeTraits< DiagGaussianBridge< Clust::Gaussian_s_, Data_> >
148{
149 typedef Data_ Data;
151 typedef typename Data_::Type Type;
157 typedef std::vector<std::pair<int,int> > MissingIndexes;
159 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
160 enum
161 {
162 idMixtureClass_ = Clust::DiagGaussian_
163 };
164};
165
166} // namespace hidden
167
168
186template<int Id, class Data>
187class DiagGaussianBridge: public IMixtureBridge< DiagGaussianBridge<Id,Data> >
188{
189 public:
190 // Base class
192 // type of Mixture
195 // type of data
197 // class of mixture
198 enum
199 {
201 };
202 typedef std::vector<std::pair<int,int> >::const_iterator ConstIterator;
203 using Base::mixture_;
204 using Base::p_dataij_;
205 using Base::p_tik;
206 using Base::v_missing_;
208
217 {
218 removeMissing(); // remove missing from data only once at creation
219 mixture_.setData(*p_dataij_);
220 }
224// { mixture_.setData(*p_dataij_);}
233 virtual DiagGaussianBridge* clone() const { return new DiagGaussianBridge(*this);}
239 virtual DiagGaussianBridge* create() const
240 {
242 p_bridge->p_dataij_ = p_dataij_;
243 p_bridge->mixture_.setData(*p_dataij_);
244 p_bridge->v_missing_ = v_missing_;
245 return p_bridge;
246 }
249 Type safeValue( int j) const
250 { return p_dataij_->col(j).meanSafe();}
251
252 private:
261};
262
263} // namespace STK
264
265#endif /* STK_DIAGGAUSSIANBRIDGE_H */
In this file we implement the DiagGaussian_s class.
In this file we define and implement the DiagGaussian_sj class.
In this file we implement the DiagGaussian_sjk class.
In this file we implement the DiagGaussian_sjsk class.
In this file we define the DiagGaussian_sk model.
template implementation of the IMixture interface allowing to bridge a STK++ mixture with the compose...
virtual ~DiagGaussianBridge()
destructor
DiagGaussianBridge(Data *p_dataij, String const &idData, int nbCluster)
default constructor.
DiagGaussianBridge(DiagGaussianBridge const &bridge)
copy constructor
DiagGaussianBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
virtual DiagGaussianBridge * clone() const
This is a standard clone function in usual sense.
IMixtureBridge< DiagGaussianBridge< Id, Data > > Base
hidden::MixtureBridgeTraits< DiagGaussianBridge< Id, Data > >::Parameters Parameters
hidden::MixtureBridgeTraits< DiagGaussianBridge< Id, Data > >::Mixture Mixture
hidden::MixtureBridgeTraits< DiagGaussianBridge< Id, Data > >::Type Type
std::vector< std::pair< int, int > >::const_iterator ConstIterator
virtual DiagGaussianBridge * create() const
This is a standard create function in usual sense.
Interface base class for the bridges of the STK++ mixture.
MissingIndexes v_missing_
vector with the coordinates of the missing values
hidden::MixtureBridgeTraits< DiagGaussianBridge< 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::Gaussian_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.
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::Gaussian_sj_ > Parameters
Type of the structure storing the mixture parameters.
ModelParameters< Clust::Gaussian_sjk_ > 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::Gaussian_sjsk_ > 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.
ModelParameters< Clust::Gaussian_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.
MixtureBridgeTraits struct for bridged mixtures The traits struct MixtureBridgeTraits must be special...