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 -lpdsnnmm

Para executar o programa:

./example_perceptron_kernel_fourier_yinyang

Retornando por consola:

GradientCE:
Error: RMS(△ W)/Std(W)
-------------------------
   IterationConf data    
-------------------------
    Alpha: 0.1
   Lambda: 0
    Gamma: 0.001
 MinError: 1e-05
  MaxIter: 10000
-------------------------
LastError: 0.00010351
 LastIter: 10000
-------------------------
    
Neurona:
-0.18013357728758       -0.062464654376709      -0.033373401770462      0.020631568656203       0.29148311216059        0.34103979993106        -0.036814326751667      0.056527640141611       -0.089009821315453      -0.061814475465474      -0.20991150509969       0.1383167660938 -0.11519022512783       0.20581189190135        0.31899212059161        0.12156521351899        -0.032851106498302      0.10637286602318        -0.076658588787225      0.087865723457444       -0.2103724856583        0.046970181549205       -0.13474428211245       0.16246261952794        0.1014502514479 0.12025858759277        0.12292728372398        0.14820194005856        -0.17561079355043       -0.074020414548194      0.010411927648694       -0.032317581158461      -0.30375911716402       -0.016816800645918      -0.041463547396794      0.085102886247021       -0.11020529207607       0.34452625341816        -0.14275218964336       0.37053745760157        0.19829269949   1.1738819510541 0.02623556911298        1.7432490424743 0.049344445661633       -0.006948436973885      -1.9081471376394        -1.0319478940156        -1.0062113044379        -4.7103630170993        0.66930957926434        -1.2632909279677        1.8555869891644 -0.2330493860114        0.017175847264979       -1.997759003638 -1.6051261140504        1.2529922794403 0.91005060039906        0.1682226707831 -1.6946818003494        2.1507791810945 -0.39502900804857       -0.399741979132 -1.8135403131755        -0.70780602272872       1.0854814009978 -0.9846704557833        -1.9805559320964        -1.0023496839793        1.6668352513891 -0.82258632860867-0.0068211857809486    -0.038235436997667      0.43361805686668        1.5307859711456 -0.54289555032935       -0.98983901883901       1.1685220917887 0.23351103518634        -0.062793075917545
    
-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 2000
----------------:------------
Pred.[0]/Act.[*]: 999   5
Pred.[1]/Act.[*]: 1     995
----------------:------------
Accuracy        : 99.7%
Precision       : 99.9%
Recall          : 99.5%
----------------:------------
FScore          : 99.7%
-----------------------------
    
-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 2000
----------------:------------
Pred.[0]/Act.[*]: 998   12
Pred.[1]/Act.[*]: 2     988
----------------:------------
Accuracy        : 99.3%
Precision       : 99.8%
Recall          : 98.8%
----------------:------------
FScore          : 99.3%
-----------------------------

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=10000;
Pds::Matrix X;
Pds::Vector Y;
// 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");
// Evaluate training data
Yp=Neurona.Evaluate(F);
// Metrics of training
Metrics.Print("\n");
// Evaluate testing data
F=Pds::Kernel::FourierSeries(X,Pds::Vector("2.0 2.0"),K);
Yp=Neurona.Evaluate(F);
// Metrics testing
Metrics.Print("\n");
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 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.
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