STK++ 0.9.13
STK_HDMatrixGaussianBridge.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_HDMATRIXGAUSSIANBRIDGE_H
38#define STK_HDMATRIXGAUSSIANBRIDGE_H
39
41#include "../STK_IMixtureBridge.h"
42
43namespace STK
44{
45
46// forward declaration
47template<int IdRow, int IdCol, class Data_> class HDMatrixGaussianBridge;
48
49namespace hidden
50{
54template<int IdRow_, int IdCol_, class Data_>
56{
57 typedef Data_ Data;
65 typedef std::vector<std::pair<int,int> > MissingIndexes;
67 typedef std::vector< std::pair<std::pair<int,int>, Type > > MissingValues;
68 enum
69 {
70 idMixtureClass_ = Clust::HDMatrixGaussian_
71 };
72};
73
74} // namespace hidden
75
76
77
93template<int IdRow, int IdCol, class Data>
94class HDMatrixGaussianBridge: public IMixtureBridge< HDMatrixGaussianBridge<IdRow, IdCol,Data> >
95{
96 public:
97 // Base class
99 // type of Mixture
102 // type of data
104 // class of mixture
105 enum
106 {
108 };
109 typedef std::vector<std::pair<int,int> >::const_iterator ConstIterator;
110 using Base::mixture_;
111 using Base::p_dataij_;
112 using Base::p_tik;
113 using Base::v_missing_;
115
123 , int nbRow
124 , int nbCluster
125 )
127 {
128 removeMissing(); // remove missing from data only once at creation
129 mixture_.setData(p_data_->dataij());
130 }
141 virtual HDMatrixGaussianBridge* clone() const { return new HDMatrixGaussianBridge(*this);}
148 {
150 p_bridge->p_dataij_ = p_dataij_;
151 p_bridge->mixture_.setData(*p_dataij_);
152 p_bridge->v_missing_ = v_missing_;
153 return p_bridge;
154 }
157 Type safeValue( int j) const
158 { return p_dataij_->col(j).meanSafe();}
159
160 private:
169};
170
171} // namespace STK
172
173#endif /* STK_HDMATRIXGAUSSIANBRIDGE_H */
In this file we define the HDMatrixGaussianModel class.
template implementation of the IMixture interface allowing to bridge a STK++ mixture with the compose...
std::vector< std::pair< int, int > >::const_iterator ConstIterator
HDMatrixGaussianBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
HDMatrixGaussianBridge(Data *p_dataij, String const &idData, int nbRow, int nbCluster)
default constructor.
virtual HDMatrixGaussianBridge * create() const
This is a standard create function in usual sense.
hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Parameters Parameters
virtual HDMatrixGaussianBridge * clone() const
This is a standard clone function in usual sense.
IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > > Base
HDMatrixGaussianBridge(HDMatrixGaussianBridge const &bridge)
copy constructor
hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Mixture Mixture
hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Type Type
Interface base class for the bridges of the STK++ mixture.
MissingIndexes v_missing_
vector with the coordinates of the missing values
hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Data Data
virtual void removeMissing()
This function will be used once for imputation of missing data at the initialization step (.
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.
HDMatrixModelParameters< Data_ > Parameters
Type of the structure storing the mixture parameters.
std::vector< std::pair< int, int > > MissingIndexes
Type of the array storing missing values indexes.
HDMatrixGaussianModel< IdRow_, IdCol_, Data_ > Mixture
Type of the mixture model.
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...