STK++ 0.9.13
STK_HDGaussianBridge.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_HDGAUSSIANBRIDGE_H
38#define STK_HDGAUSSIANBRIDGE_H
39
41#include "../STK_IMixtureBridge.h"
42
43namespace STK
44{
45
46// forward declaration
47template<int Id, class Data> class HDGaussianBridge;
48
49namespace hidden
50{
54template<class Data_>
55struct MixtureBridgeTraits< HDGaussianBridge< Clust::HDGaussian_AjkBkQkD_, Data_> >
56{
57 typedef Data_ Data;
59 typedef typename Data_::Type Type;
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::HDGaussian_
71 };
72};
73
74} // namespace hidden
75
76
77
93template<int Id, class Data>
94class HDGaussianBridge: public IMixtureBridge< HDGaussianBridge<Id,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
124 {
125 removeMissing(); // remove missing from data only once at creation
126 mixture_.setData(p_data_->dataij());
127 }
131 virtual ~HDGaussianBridge() {}
138 virtual HDGaussianBridge* clone() const { return new HDGaussianBridge(*this);}
144 virtual HDGaussianBridge* create() const
145 {
147 p_bridge->p_data_ = p_data_;
148 p_bridge->p_dataij_ = p_dataij_;
149 p_bridge->mixture_.setData(*p_dataij_);
150 p_bridge->v_missing_ = v_missing_;
151 return p_bridge;
152 }
155 Type safeValue( int j) const
156 { return p_data_->dataij().col(j).meanSafe();}
157
158 private:
167};
168
169} // namespace STK
170
171#endif /* STK_HDGAUSSIANBRIDGE_H */
template implementation of the IMixture interface allowing to bridge a STK++ mixture with the compose...
virtual HDGaussianBridge * clone() const
This is a standard clone function in usual sense.
HDGaussianBridge(Data *p_dataij, String const &idData, int nbCluster)
default constructor.
IMixtureBridge< HDGaussianBridge< Id, Data > > Base
hidden::MixtureBridgeTraits< HDGaussianBridge< Id, Data > >::Mixture Mixture
hidden::MixtureBridgeTraits< HDGaussianBridge< Id, Data > >::Type Type
HDGaussianBridge(HDGaussianBridge const &bridge)
copy constructor
virtual ~HDGaussianBridge()
destructor
hidden::MixtureBridgeTraits< HDGaussianBridge< Id, Data > >::Parameters Parameters
HDGaussianBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
std::vector< std::pair< int, int > >::const_iterator ConstIterator
virtual HDGaussianBridge * 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< HDGaussianBridge< 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.
std::vector< std::pair< std::pair< int, int >, Type > > MissingValues
Type of the array storing missing values.
ModelParameters< Clust::HDGaussian_ajk_bk_qk_d_ > 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...