Home | Develop | Download | Contact
example_perceptron_kernel_poly_sine.cpp

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

g++ -static -o example_perceptron_kernel_poly_sine example_perceptron_kernel_poly_sine.cpp -lpdsmlmm

Para executar o programa:

./example_perceptron_kernel_poly_sine

Retornando por consola:

Neurona:
-0.44394896796723       23.369812401582 -5.5990859143574        1.6047345202706 -2.3234824190806        1.9410596273968 -121.38309823869        3.1348051746528 -32.992395188308        -19.520365097443        -0.67356985992054       2.9783538661135 -2.6597861788598        9.1168731797187 -4.7714304618693        145.64641915713 3.1174663505789 156.67697505028 -10.566567730069        -5.1222827984402        47.475062351416 -1.1031438346344        -1.1636195655602        -0.27212944691812       -7.8025071008203        3.5366155020148 -10.551246450729        6.1685389877243 -48.977294633292        -10.180053490278        -101.72465180136        16.716071856782 -35.878358431932        -1.696229395668 12.567109268125 -26.754055525364        0.090377306290623       0.6702065404376 2.3202973668627 0.38919350746505        -0.47738323137392       5.3347170140667 -2.7150870362765        3.50694434439   -2.9032676038638

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.53            ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 975     33      ║
║ Pred.[1]/Act.[*]: 25      967     ║
╠═══════════════════════════════════╣
║         Accuracy: 97.1  %         ║
║        Precision: 97.48 %         ║
║           Recall: 96.7  %         ║
╠═══════════════════════════════════╣
║           FScore: 97.09 %         ║
╚═══════════════════════════════════╝

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.53            ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 983     32      ║
║ Pred.[1]/Act.[*]: 17      968     ║
╠═══════════════════════════════════╣
║         Accuracy: 97.55 %         ║
║        Precision: 98.27 %         ║
║           Recall: 96.8  %         ║
╠═══════════════════════════════════╣
║           FScore: 97.53 %         ║
╚═══════════════════════════════════╝
Clasification - data


Clasification - training


Clasification - testing

Código example_perceptron_kernel_poly_sine.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
unsigned int M=8;
// Generating data
unsigned int L=1000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Octave::Plot::PointsX2DY(X,Y,"testando.m","example_perceptron_kernel_poly_sine_data.png");
// Create Perceptron
Conf.SetMaxIter(10000);
Pds::Perceptron Neurona(Conf,F,Y);
Neurona.Print("\nNeurona:\n");
// Evaluate training data
Yp=Neurona.Evaluate(F);
// Metrics of training
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_poly_sine_training.png");
// Evaluate testing data
Yp=Neurona.Evaluate(F);
// Metrics testing
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_poly_sine_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:63
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 LoadDataSine(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por una curva.
Pds::Matrix Polynomial(const Pds::Matrix &X, unsigned int M)
Crea una nueva matriz de "features" kernelizando de forma polinomial.
std::string YLabel
Texto correspondente a ylabel.
std::string XLabel
Texto correspondente a xlabel.
bool PointsX2DY(const Pds::Matrix &X, const Pds::Vector &Y, const std::string &octfilename, const std::string &imgfilename)
Plot de muestras en 2D en las columnas X, clasificadas de forma binaria con Y>=0.5,...
void Print(std::string str="") const
Imprime en pantalla el contenido del vector de pesos después del texto indicado en str.
double Evaluate(const std::initializer_list< double > list) const
Evalua el objeto de tipo Pds::Perceptron.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed