Home | Develop | Download | Contact
example_perceptron_kernel_gaussian_circle.cpp

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

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

Para executar o programa:

./example_perceptron_kernel_gaussian_circle

Retornando por consola:

Neurona:
-244.16136648319        548.84350894962 -1058.0840488566        174.8832376661  201.06378644318 -421.63911640356        9.14222865853   870.75690440037 28.61874636037  -1137.8035348168        -1018.7742743357        443.99251458725 -754.75887724499        -79.950185198032        216.2439817103  -1887.751676586 1628.5095088326 -126.74949869789        312.8789329168  16.746823369284 565.98972119948-748.03446117916 544.03091236026 1017.0991768131 -466.76008910886        3.1235998708596 -608.44398993276        843.37746266645 81.287725732578 -246.49366745357        779.61849138377 -232.57139579813        -103.38540534845        -430.37668959038        192.72721679621 317.62751248198 199.74316381893 -1493.4656025513        1370.2885683159 -303.6852050284 -456.45841595621        1056.2477914892 -487.52675075247        -1734.6121169785        -322.36076483496        -151.43751654156        975.08491107031 -708.63650222362        -164.23212991503        100.96536166123 994.48093736097 640.19820989548 -98.739074174531        -790.40154693088        -842.87348973158        1029.0372344918 318.19462645773 1294.8083866416 84.333721252866 -289.73893191752        872.22804897278 -189.96614099464        671.65108448506 -511.08292064363        -870.22896934127        -35.337383409002        -108.45808018362        799.49532411707 930.1367192698  -2508.4953396237        956.22434399656 543.57705509569 -182.24971276734        454.05883077752 -540.71547285794        -1087.4234141599        -1015.9553577321        671.92565279399 273.60022612532 -691.3538379886-430.46924111984 1544.0887553602 -620.52412220881        1282.1945194731 -828.80026361047        -355.77792023955        -153.88883351163        700.83889948787 -120.25023210063        -439.62805012595        255.32133019409 535.28898711331 105.12537495258 1676.152650045  -191.36852097326        713.48583530815 732.70041653771 -354.33989704622        1696.8425988462 -12.4310188185  -343.00131567544        -382.60923671563        228.68991180191 575.81506532225 683.11141429986 -110.17750642011        -1349.4891058742        -640.0008714746 -348.29817756373        270.9994472106  172.58219274869 6.8183000983159 -1215.360017453 256.39230374201 150.83827026908 199.44543506053 74.709752413083 -563.88913384947        705.44986065352 372.7121887872  128.40072158234 -1124.5358823451        -220.16127586103        -643.60773861429        -160.04043114473        -204.02163896548        337.00156225193 -560.30052104282        1278.5966766221 -372.58781285161        532.4069952138281.88189241236   428.73049683822 -406.79338183678        223.00335925859 -326.55001310655        1030.0175738151 -410.39343163765        -72.030106538215        1265.075461     -512.50045031906        51.966172408925 571.32525270008 -432.96915143341        -807.27601469149        -366.42576152715        246.98280858384 784.58427674272 851.65009830469 -151.59478909137        -68.816735856089        970.03294165599 0.94489122476522        251.14986409973 593.00129814625 101.43433468171 664.82492309891 -280.70204002073        652.99307922869 600.82721221754 795.03581992383 13.542777611883 509.98666264883 -102.08245545549        -368.71272587664        -505.59517448707        437.70940222928 -432.561910732  -1030.5799859917        246.92573546189 455.69177308625 -156.42503082002        51.648381621279 284.57345390346 -373.35381000985        -532.54840786998        172.24896901427 824.50755881328 -459.14813886269        -443.9808417543 760.16250932621 681.44831578804 -519.29370606607        145.22031613407 -740.21435006642        -15.395114478598        -43.382571971341        1049.6804910781 -480.91472140217        213.7790424525  347.59540500901 526.52255293292 -83.452470824982        996.41900556258 427.7732340658  97.975210703281 1716.4059213799 -510.41394512767        860.8539524175  -711.30088490243        1682.1021675374 -154.24086898853        634.50774027013 -600.76077918124        -522.49924833413        -843.10585256995        -562.14931533364        -341.7639934966 -956.60926513691        922.45863131507 116.59821259539 39.261175159181 682.20141063855 -1414.8781921097        1539.6646272677 -753.11873149447        -1109.4884181542        748.78825718881 1004.9014285894 15.48306737688  -961.83566206384        -407.78782885898        -788.58681705436        894.54199415229 403.2771373551  685.51585084014 711.76682491433 -55.622337802742        136.92071989459 -451.84157475268        -66.48083143349 -133.43964969091        -324.40197046916        -392.34996747068        670.9590368458  917.32463012235 46.225545326839 476.04698488635 374.93102795301 -271.07003198365        167.68075954254 -744.80408235361        1096.7999728919 -799.10247186646        773.27892890122 788.82416937254 147.00242053604 337.90456973618 -953.37150675597        -233.93217272938        152.22326361255 2.3520027153443 38.239567549601 -74.227627505503        -583.25313954349        -417.50349279414        197.70509622862 94.839028277609 -320.65472678572        72.314136449643 -689.6239757779 -338.93943662902        -143.44627670697        199.18457226381 -87.722640387544        497.13251090771 751.17859262545 75.825916645399 398.0063732322  55.773367526211 -596.98768933571        -18.559895650118        -631.67164560804        -386.26549951745        174.52224618362-590.79353782876 -96.929902898317        -518.96669605947        317.06052453242 266.69352900531 288.63679153441 173.86705345486 604.70800341734 -193.90639979607        375.39058228998 184.02905351598 447.53820015231 -326.9028270635 248.97832494462 -59.857160266306        390.77872119593 -984.10438526612        208.23003939132 -1090.4624876672        -57.249264926989        -1408.6218882391        -172.31826953317        -111.24494668645        -1077.4161668955        -129.02533304535        -1087.0273235747        -21.815979440797        -798.96328642777        -362.79891405473        469.33143423325 123.10826822194 -52.402762184894        633.08151526967 120.15147458415 191.9935296032  327.39684678983 -994.35340321991        -428.46712027711        -695.29660190397        782.71788049002 80.396080546547 -80.695746876876        901.35329723425 -796.85801180914        -232.57312415333        481.94464726621 323.08092408976 8.1331855476568 615.85271301073 -70.328322139299        -518.73819324318        -341.83224168547        -666.03712432359        324.46183769208 -238.73217072781        410.70405786629 497.15539999848 -670.19234857249        825.42064817386 -770.70747603434        392.67178116129 798.75709910429 384.13733634285 -652.10551051921        160.31395737207 168.3004144745  1141.7435383007 547.14768607272 -324.55185945504        499.38562765154 -119.99200250222        317.1112465716  -1013.8947921251        156.73565396337 -363.89624893877        -58.49898458649 264.15225312448 -767.16403676307        467.67190922759 -699.6502085123 -483.40841557737        -577.06856024718        385.58406745753 -1002.9975092454        -45.226843965006        268.66468223031 -193.57825257011        -247.33466106684        -171.13341476626        -21.937172181034        493.88138530118 282.21620783077 357.04648020587 312.77694914356 427.01876937143 -468.6528492439 -194.43065074632        -434.13401436971        -639.36313087856        795.38885739519 34.632747396281 263.12055481467 -89.370795194849        -368.55840533673        -106.74216205128        489.36402691741 198.42230087809 -599.4655784243 325.82130152484 -155.98963275919        -387.99116002673        67.14356591904  -354.76654355271        147.27499583956 83.878903015714 -1092.264277665 -251.42446468266        -1114.0005109486        914.61268478356 -698.6509544632 -176.37155938659        -321.07833515744        -45.879156818916        246.14234681342 9.5956454331748 -712.51774351675

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 400             ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 200     4       ║
║ Pred.[1]/Act.[*]: 0       196     ║
╠═══════════════════════════════════╣
║         Accuracy: 99    %         ║
║        Precision: 100   %         ║
║           Recall: 98    %         ║
╠═══════════════════════════════════╣
║           FScore: 98.99 %         ║
╚═══════════════════════════════════╝

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 400             ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 200     5       ║
║ Pred.[1]/Act.[*]: 0       195     ║
╠═══════════════════════════════════╣
║         Accuracy: 98.75 %         ║
║        Precision: 100   %         ║
║           Recall: 97.5  %         ║
╠═══════════════════════════════════╣
║           FScore: 98.73 %         ║
╚═══════════════════════════════════╝
Classification - data


Classification - training


Classification - testing

Código example_perceptron_kernel_gaussian_circle.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
Pds::Matrix G;
Pds::IterationConf Conf; Conf.SetMaxIter(10000);
double Sigma=0.3;
// Generating data
unsigned int L=200;
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_gaussian_circle_data.png");
// Create Perceptron
G=X;
F=Pds::Kernel::Gaussian(X,G,Sigma);
Pds::Perceptron Neurona(Conf,F,Y);
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_gaussian_circle_training.png");
// Predict testing data
F=Pds::Kernel::Gaussian(X,G,Sigma);
Yp=Neurona.Predict(F);
// Metrics testing
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_perceptron_kernel_gaussian_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.
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 Gaussian(const Pds::Matrix &X, const Pds::Matrix &G, double Sigma=1.0)
Crea una nueva matriz de "features" kernelizando de forma gaussiana.
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