Home | Develop | Download | Contact
example_perceptron_kernel_gaussian_gmm.cpp

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

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

Para executar o programa:

./example_perceptron_kernel_gaussian_gmm

Retornando por consola:

Neurona:
-0.084801134424809 6.5644266025979    6.7976090202446    7.2466923286193    7.0344311122582    6.4082894628588    6.0603114182925    6.4848189537356    8.6777704375106    7.5236535836757    7.4045759280255    -6.7251099705574   -7.6567594525611   -8.6558523629629   -6.9612035074631   -7.4106021940437   -5.9315724812651   -6.3772318212795   -6.470017398032    -5.1911400757936   -7.1811853152788   

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 974     17      ║
║ Pred.[1]/Act.[*]: 26      983     ║
╠═══════════════════════════════════╣
║         Accuracy: 97.85 %         ║
║        Precision: 97.42 %         ║
║           Recall: 98.3  %         ║
╠═══════════════════════════════════╣
║           FScore: 97.86 %         ║
╚═══════════════════════════════════╝

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 959     25      ║
║ Pred.[1]/Act.[*]: 41      975     ║
╠═══════════════════════════════════╣
║         Accuracy: 96.7  %         ║
║        Precision: 95.96 %         ║
║           Recall: 97.5  %         ║
╠═══════════════════════════════════╣
║           FScore: 96.73 %         ║
╚═══════════════════════════════════╝
Classification - data


Classification - training


Classification - testing

Código example_perceptron_kernel_gaussian_gmm.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
Conf.SetMaxIter(10000); Conf.Show=false;
unsigned int K=10;
// Generating data
unsigned int L=1000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Matrix G;
Pds::Octave::XLabel="x_1";
Pds::Octave::YLabel="x_2";
Pds::Octave::Plot::PointsX2DY(X,Y,"testando.m","example_perceptron_kernel_gaussian_gmm_data.png");
std::vector<Pds::Matrix> Block=X.FindRowsBlock(Y);
Pds::DataGMM Dat0=Pds::Clustering::GMM(Conf,Block[0],K,1.0);
Pds::DataGMM Dat1=Pds::Clustering::GMM(Conf,Block[1],K,1.0);
Dat1.Mu.insert (Dat1.Mu.end() , Dat0.Mu.begin() , Dat0.Mu.end());
Dat1.Sinv.insert(Dat1.Sinv.end(), Dat0.Sinv.begin(), Dat0.Sinv.end());
// Create Perceptron
F=Pds::Kernel::Gaussian(X,Dat1.Mu,Dat1.Sinv);
Pds::Perceptron Neurona(Conf,F,Y);
Neurona.Print("\nNeurona:\n");
// Predict training data
Yp=Neurona.Predict(F);
// Metrics of training
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_gaussian_gmm_training.png");
// Predict testing data
F=Pds::Kernel::Gaussian(X,Dat1.Mu,Dat1.Sinv);
Yp=Neurona.Predict(F);
// Metrics testing
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_gaussian_gmm_testing.png");
return 0;
}
La clase tipo Pds::ClassificationMetrics . Esta clase genera un bloque de datos para analizar curvas ...
La clase tipo Pds::DataGMM . Esta clase genera un bloque de datos para analizar curvas de aprendisaje...
Definition: DataGMM.hpp:60
std::vector< Pds::Vector > Mu
Definition: DataGMM.hpp:67
std::vector< Pds::Matrix > Sinv
Definition: DataGMM.hpp:70
La clase tipo Pds::IterationConf . Esta clase genera una matriz de Nlin lineas y 1 columna....
La clase tipo Pds::Perceptron . Esta clase genera una matriz de Nlin lineas y 1 columna....
Definition: Perceptron.hpp:64
static Pds::ClassificationMetrics Calculate(double Threshold, const Pds::Vector &Ypredict, const Pds::Vector &Yactual)
Crea un objeto Dat de tipo Pds::ClassificationMetrics.
void Print(std::string str="")
Imprime en pantalla los datos de la estructura tipo Pds::ClassificationMetrics.
bool SetMaxIter(unsigned int MaxIter)
Coloca el valor MaxIter.
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 LoadDataYinYang(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de una curva.
Pds::Matrix Gaussian(const Pds::Matrix &X, const Pds::Matrix &G, double Sigma=1.0)
Crea una nueva matriz de "features" kernelizando de forma gaussiana.
double Predict(const std::initializer_list< double > list) const
Evalua el objeto de tipo Pds::Perceptron.
void Print(std::string str="") const
Imprime en pantalla el contenido del vector de pesos después del texto indicado en str.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed