Home | Develop | Download | Contact
example_perceptron_kernel_fourier_yinyang.cpp

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

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

Para executar o programa:

./example_perceptron_kernel_fourier_yinyang

Retornando por consola:

Elapsed time: 47.234 ms

Neurona:
0.21226448517277        -0.55795944252609       0.37018566377407        -0.20600607788485       0.10394964001847        -0.019970209874296      0.15543454060149        -0.30183428539947       0.51433574085581        -0.53558024381576       0.47725213564262        -0.41525653467309       0.34276340233109        -0.036765159558053      0.037510615682548       -0.17599075518798       0.30417824769794        -0.3871061863006        0.4283154587619 -0.52360366636155       0.38643199003687        -0.1424979285442        0.095852379574907       -0.0082546875852322     0.040058827050274       -0.10285316979851       0.29998408053205        -0.28659810113886       0.34788847144244        -0.21240921130359       0.23103957093935        -0.08077578434782       0.036245946737349       -0.065086507198097      0.10604160206896        -0.1537749470355        0.28349738261   -0.20063148646179       0.11653817440828        -0.10796152637291       0.0028678548162883      1.0866228993914 0.073697524139421       0.71641946842161        -0.057137186367632      -0.0022587697106831     -0.96909442440726       -0.32098203472446       -1.2577628380045        -3.7070769034047        0.32000126436097        -0.52579500928771       0.63894263242691        0.03839313264754        -0.25654001506679       -0.95196391003247       -1.1394888519714        1.322146008227  0.97082374050905        0.12659192282603        -0.9237684864603        1.0742832178805 -0.32901689873745       -0.32713271765827       -0.91095404422567       0.21849285692109        0.23569590381861        0.070265275010512       -1.3011108122478        -0.095657076122658      0.7602949186286 -0.43121222359906       -0.19394315837847       -0.31263664864442       0.093478862042149       1.0087882483009 0.017377895480621       -0.36848657768467       0.36839401796507        -0.023770717494916      -0.17538281979113

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 982     24      ║
║ Pred.[1]/Act.[*]: 18      976     ║
╠═══════════════════════════════════╣
║         Accuracy: 97.9  %         ║
║        Precision: 98.19 %         ║
║           Recall: 97.6  %         ║
╠═══════════════════════════════════╣
║           FScore: 97.89 %         ║
╚═══════════════════════════════════╝

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 982     25      ║
║ Pred.[1]/Act.[*]: 18      975     ║
╠═══════════════════════════════════╣
║         Accuracy: 97.85 %         ║
║        Precision: 98.19 %         ║
║           Recall: 97.5  %         ║
╠═══════════════════════════════════╣
║           FScore: 97.84 %         ║
╚═══════════════════════════════════╝
Classification - data


Classification - training


Classification - testing

Código example_perceptron_kernel_fourier_yinyang.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
unsigned int K=4;
// 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_fourier_yinyang_data.png");
// Create Perceptron
F=Pds::Kernel::FourierSeries(X,Pds::Vector("2.0 2.0"),K);
Pds::Ra::Tic();
Conf.SetMaxIter(10000);
Pds::Perceptron Neurona(Conf,F,Y);
Pds::Ra::Toc();
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_fourier_yinyang_training.png");
// Predict testing data
F=Pds::Kernel::FourierSeries(X,Pds::Vector("2.0 2.0"),K);
Yp=Neurona.Predict(F);
// Metrics testing
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_fourier_yinyang_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.
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 LoadDataYinYang(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de una curva.
Pds::Matrix FourierSeries(const Pds::Matrix &X, const Pds::Vector &L, unsigned int K)
Crea una nueva matriz de "features" kernelizando cada muestra en usando la serie de fourier.
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