Home | Develop | Download | Contact
example_funcgmm_probability.cpp

Programa para el testeo de las funciones.Para compilar o código example_funcgmm_probability.cpp:

g++ -static -o example_funcgmm_probability example_funcgmm_probability.cpp -lpdsmlmm -lpdsramm -lpdsspmm

Para executar o programa:

./example_funcgmm_probability

Retornando por consola:

┌──────────────────────────────┐
│    GMM                       │
│    IterationConf init data   │
├──────────────────────────────┤
│        MinError: 1.0000e-06  │
│         MaxIter: 2000        │
└──────────────────────────────┘
┌──────────────────────────────┐
│            Iter: 71          │
│       LastError: 7.6973e-07  │
│ Elapsed time(s): 0.002359    │
└──────────────────────────────┘
Dat:
Pi[0]: 0.3328
Pi[1]: 0.3195
Pi[2]: 0.3476
Mu[0]:
0.98662265997179     -0.00021508510074319 
Mu[1]:
-0.48555456702506 -0.90962657141875 
Mu[2]:
-0.50986272323955 0.82924594851797  
Sinv[0]:
10.577538761397  0.43347439875572 
0.43347439875572 18.994450171649  
Sinv[1]:
18.206494777711  0.15027393378441 
0.15027393378441 2.9001288199875  
Sinv[2]:
17.289970505333  -1.3245918459504 
-1.3245918459504 6.275061020014   
Det[0]: 0.004981899938309
Det[1]: 0.018947073977717
Det[2]: 0.0093684646413172
example_funcgmm_probability_data.png
example_funcgmm_probability_prob.png
example_funcgmm_probability_prob2.png
example_funcgmm_probability_prob3.png
example_funcgmm_probability_clusters.png
example_funcgmm_probability_clusters2.png
example_funcgmm_probability_clusters3.png

Código example_funcgmm_probability.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Octave::XLabel="x1";
Pds::Octave::YLabel="x2";
Pds::Octave::DAspect=true;
Pds::IterationConf Conf; Conf.Show=true; Conf.SetMinError(1.0e-6);
unsigned int L=1000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Vector P;
// Generating data X=[x1 x2]
Pds::Octave::MarkerSize=3;
Pds::Octave::Plot::PointsX2D(X,"testando.m","example_funcgmm_probability_data.png");
Pds::Octave::MarkerSize=12;
// Mu, Sigma estimation
Dat.Print("Dat:\n");
/*
Dat.ExportFile("Dat.txt");
Pds::DataGMM Dat2("Dat.txt");
Dat2.Print("\nDat2:\n");
std::ofstream myfile;
myfile.open("Dat2.txt");
Dat2.SaveInStream(myfile);
myfile.close();
Pds::DataGMM Dat3;
std::ifstream myinfile("Dat2.txt", std::ifstream::in);
Dat3.LoadFromStream(myinfile);
myinfile.close();
Dat3.Print("\nDat3:\n");
*/
// Gaussian Mixture Model density
Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_funcgmm_probability_prob.png");
P=Pds::Probability::GMMDensity(X,Dat.Pi,Dat.Mu,Dat.Sinv,Dat.Det);
Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_funcgmm_probability_prob2.png");
Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_funcgmm_probability_prob3.png");
// Gaussian Mixture Model partial density
Pds::Matrix A;
Pds::Vector ID;
ID=A.OperateRows(Pds::ArgMax);
Pds::Octave::Plot::ScatterX2DY(X,ID,"testando.m","example_funcgmm_probability_clusters.png");
A=Pds::Probability::GMMPartial(X,Dat.Pi,Dat.Mu,Dat.Sinv,Dat.Det);
ID=A.OperateRows(Pds::ArgMax);
Pds::Octave::Plot::ScatterX2DY(X,ID,"testando.m","example_funcgmm_probability_clusters2.png");
ID=A.OperateRows(Pds::ArgMax);
Pds::Octave::Plot::ScatterX2DY(X,ID,"testando.m","example_funcgmm_probability_clusters3.png");
return 0;
}
La clase tipo Pds::DataGMM . Esta clase genera un bloque de datos para analizar curvas de aprendisaje...
Definition: DataGMM.hpp:60
std::vector< double > Det
Definition: DataGMM.hpp:73
std::vector< Pds::Vector > Mu
Definition: DataGMM.hpp:67
std::vector< Pds::Matrix > Sinv
Definition: DataGMM.hpp:70
std::vector< double > Pi
Definition: DataGMM.hpp:64
La clase tipo Pds::IterationConf . Esta clase genera una matriz de Nlin lineas y 1 columna....
void Print(const std::string &str) const
Imprime los datos del Pds::DataGMM.
bool SetMinError(double MinError)
Coloca el valor MinError.
Pds::DataGMM GMM(Pds::IterationConf &Conf, const Pds::Matrix &X, const Pds::DataGMM &In)
Itera un Gaussian Mixture Model (GMM) (pp. 13). Tenemos como conocimiento de estrada,...
void LoadKGaussian(unsigned int L, unsigned int K, Pds::Matrix &X, Pds::Vector &Y, double factor=0.70711)
Clasificación múltiple de datos.
Pds::Matrix GMMPartial(const Pds::Matrix &X, const std::vector< double > &Pi, const std::vector< Pds::Vector > &Mu, const std::vector< Pds::Matrix > &Sinv)
Retorna una Matriz . Con este fin, evalua la "Gaussian mixture model partial probability density func...
Pds::Vector GMMDensity(const Pds::Matrix &X, const std::vector< double > &Pi, const std::vector< Pds::Vector > &Mu, const std::vector< Pds::Matrix > &Sinv)
Retorna el vector . Con este fin, evalua la "Gaussian mixture probability density function" usando ,...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed