Home | Develop | Download | Contact
example_perceptron_kernel_poly_band.cpp

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

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

Para executar o programa:

./example_perceptron_kernel_poly_band

Retornando por consola:

Neurona:
-3.5569770398015        0.79670348005628        -0.63309815814264       15.39272544458  42.416871008276 17.32211476837  -2.1147183718924        1.3921990052308 -1.0786607452332        2.53300873880121.9302026069433  -65.170943476362        -121.7234808035 -62.594282031445        -2.0091214142462        0.9869732278331 -2.3940892940125        1.4250687639271 0.35088834779188        0.82018763562632        -1.8400653603591        -10.539811283958        5.1670012856281 60.022540811669 88.796257352587 57.990546031286 0.56854699090767        -9.183468393062

Optimal:
╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.6             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 881     6       ║
║ Pred.[1]/Act.[*]: 119     994     ║
╠═══════════════════════════════════╣
║         Accuracy: 93.75 %         ║
║        Precision: 89.31 %         ║
║           Recall: 99.4  %         ║
╠═══════════════════════════════════╣
║           FScore: 94.08 %         ║
╚═══════════════════════════════════╝

Calculate
╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.6             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 891     9       ║
║ Pred.[1]/Act.[*]: 109     991     ║
╠═══════════════════════════════════╣
║         Accuracy: 94.1  %         ║
║        Precision: 90.09 %         ║
║           Recall: 99.1  %         ║
╠═══════════════════════════════════╣
║           FScore: 94.38 %         ║
╚═══════════════════════════════════╝
Classification - data


Classification - training


Classification - testing

Código example_perceptron_kernel_poly_band.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
Conf.SetMaxIter(10000); Conf.Show=true;
unsigned int M=6;
// Generating data
unsigned int L=1000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Octave::XLabel="x_1";
Pds::Octave::YLabel="x_2";
Pds::Octave::Plot::PointsX2DY(X,Y,"testando.m","example_perceptron_kernel_poly_band_data.png");
// Create Perceptron
Pds::Perceptron Neurona(Conf,F,Y);
Neurona.Print("\nNeurona:\n");
// Predict training data
Yp=Neurona.Predict(F);
// Metrics of training
Metrics.Print("\nOptimal:\n");
Pds::Octave::Plot::PointsX2DY(X,Yp.Geq(Metrics.Threshold),"testando.m","example_perceptron_kernel_poly_band_training.png");
// Predict testing data
Yp=Neurona.Predict(F);
// Metrics testing
Metrics.Print("\nCalculate\n");
Pds::Octave::Plot::PointsX2DY(X,Yp.Geq(Metrics.Threshold),"testando.m","example_perceptron_kernel_poly_band_testing.png");
return 0;
}
La clase tipo Pds::ClassificationMetrics . Esta clase genera un bloque de datos para analizar curvas ...
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.
static Pds::ClassificationMetrics Optimal(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.
void LoadDataBand2(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de una curva.
Pds::Matrix Polynomial(const Pds::Matrix &X, unsigned int M)
Crea una nueva matriz de "features" kernelizando de forma polinomial.
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