Home | Develop | Download | Contact
example_perceptron_kernel_poly_circle.cpp

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

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

Para executar o programa:

./example_perceptron_kernel_poly_circle

Retornando por consola:

Neurona:
-3.9290636877995        0.17121159083447        -0.040841236223358      8.4118052572778 -0.094905185116023      8.3201343003554
Optimal:
╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.14            ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 996     5       ║
║ Pred.[1]/Act.[*]: 4       995     ║
╠═══════════════════════════════════╣
║         Accuracy: 99.55 %         ║
║        Precision: 99.6  %         ║
║           Recall: 99.5  %         ║
╠═══════════════════════════════════╣
║           FScore: 99.55 %         ║
╚═══════════════════════════════════╝
Testing:
╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.14            ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 989     7       ║
║ Pred.[1]/Act.[*]: 11      993     ║
╠═══════════════════════════════════╣
║         Accuracy: 99.1  %         ║
║        Precision: 98.9  %         ║
║           Recall: 99.3  %         ║
╠═══════════════════════════════════╣
║           FScore: 99.1  %         ║
╚═══════════════════════════════════╝
Classification - data


Classification - training


Classification - testing

Código example_perceptron_kernel_poly_circle.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
unsigned int M=2;
// 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_circle_data.png");
// Create Perceptron
Conf.SetMaxIter(10000);
Pds::Perceptron Neurona(Conf,F,Y);
Neurona.Print("\nNeurona:\n");
// Predict training data
Yp=Neurona.Predict(F);
// Metrics of training
Metrics.Print("Optimal:\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_poly_circle_training.png");
// Predict testing data
Yp=Neurona.Predict(F);
// Metrics testing
Metrics.Print("Testing:\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_poly_circle_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 LoadDataCircle(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.
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