Home | Develop | Download | Contact
example_perceptron_kernel_gaussian_yinyang.cpp

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

g++ -static -o example_perceptron_kernel_gaussian_yinyang example_perceptron_kernel_gaussian_yinyang.cpp -lpdsnnmm

Para executar o programa:

./example_perceptron_kernel_gaussian_yinyang

Retornando por consola:

LogitMS:
Error: RMS(△ W)/Std(W)
-------------------------
   IterationConf data    
-------------------------
    Alpha: 0.1
   Lambda: 0
    Gamma: 0.001
 MinError: 1e-05
  MaxIter: 10000
-------------------------
LastError: 8.1092e-05
 LastIter: 10000
-------------------------
GradientCE:
Error: RMS(△ W)/Std(W)
-------------------------
   IterationConf data    
-------------------------
    Alpha: 0.1
   Lambda: 0
    Gamma: 0.001
 MinError: 1e-05
  MaxIter: 10000
-------------------------
LastError: 5.9437e-07
 LastIter: 1
-------------------------
    
Neurona:
-22.015414619719        974.47635201915 -388.69526027418        2221.9119665425 -1170.8717865901        -285.12805466639        -602.57923588944        477.1794866834  2386.0997139032 -437.9385005309 1345.8475914772 955.60387481235 50.459285608015 1452.1974801103 45.355210225558 151.01777959763 -473.74096120226        1042.2553554642 155.52014349348 -286.32232691115        -689.36045685797        959.17846110744 -298.31659372462        1123.37266732   -1355.8937157428        -1388.560027485 -60.961926708792        -972.61017865465        2596.105286434  -1298.1797521371        -93.932192826028346.13469321316 1760.8138347611 -635.26758980179        679.96179401898 -72.639905639517        -1457.906949542 569.16433010229 -447.53535920644        -1068.1914803344        -445.27079510545        -1257.7547893321        -1969.9462071881        1126.983671896  -324.16012978509        -834.86276630123        1999.4615226322 -781.12315810674        364.232952      -1469.9205921802        848.3492915785  670.50376350551 976.68141811107 -1109.6458154473        -1223.5298282734        -64.513278260571        -821.60771192785        -734.24375776208        -53.202122154055        1102.7410911588 -1458.5786186129        889.45684878378 1433.8476255018 381.46102873046 161.18616269913 -1447.6784306711        -1794.9563055048        -1615.4886253404        -2741.68622756  -1570.3562963945        -2585.15748964781147.2143546868 957.89746982763 1036.7595950058 1406.8257042689 -1544.3501086199        -3411.7253392375        -549.32080127582        1985.5136603527 -207.06378051299        888.2650712199  -176.83338829125        -473.28517025696        -754.23587776827        -219.25125642423        -3269.04194093  135.98291972272 1157.0362139491 -1378.4276496169        1953.2040523559 62.606550148612 -1181.81043213132935.7698453278 -523.73567122849        620.60681434468 -33.250154865753        -1279.7171389604        628.47250566441 -1597.3401635784        1652.6632059983 2055.6807252634 -720.83640313122        -644.13181193162        2714.539255748  -951.73978839289        -101.41229445851        -494.24605681719        -1604.4277381094        -687.20280552756        -1093.3943201141        284.04779568522 49.929337790058 196.88922085901 -2243.9063449713        1085.0432531242 -715.99392374066        -1422.6202809428        2041.4616165209 -1007.6915001947        -1618.4898344909        -2679.0422129996        1960.2281362214 -2348.3131903396        -26.478026900981        37.61065589275  651.54598596163 -335.00180384826        -838.96311340064        118.77740503351 -1815.9042437927        2432.0470953751 2647.4777965771 1271.8455859589 234.06738894309 -594.94604015112        -814.41162332451        -1485.1631271225        490.15820102564 1220.309312506  2513.2718008591 -1677.5529183213        2073.0550815297 -77.09392799546 1017.4206359795 911.48818790158 339.53418276681 1003.0315107396 -777.30840535681        540.71783021733 649.91699118993 -3853.6464029531        -1774.0716460761        -1609.0293966187        -661.77813124904        242.73476590284 -1158.4184827326        -30.821138783788        574.51042538545 -1429.3804911326        -508.52011205999        -714.89363156176        -73.030551797923-1976.9971581859        857.65395688311 -355.27527231671        -1437.2498160169        83.171826257336 5006.4247079871 -87.50252111149 307.77199467646 43.419076623556 946.22904428637 1355.4923763689 -444.03578097658        -2115.2739353255        1398.7559397067 -1086.4570015012        -1669.7574101912        -419.47367255969        -178.17869904491        -467.55502341068        1013.4974345505 939.74096850505 851.62978314883 1952.0889414123 -4149.1182044473        927.86340947245 1732.3782105068 -555.68016374069        9.7692285749705 1388.4822958961 -1503.3111759818        121.54643914609 553.32014702711 498.02879416502 675.57286761556 1119.9717356742 -198.43170407486        1495.1921342369 554.98950175319 1364.9317348153 -727.39126875139        1283.1498135108 2379.2459842614 1085.3749947172 -1560.4900032275        -1083.8147994399        109.62192722219 -2273.7801007006        286.58488199969 -265.62214218467        -1360.7278333716        -993.81346391658        -1578.7433209108        2699.1653316421 -32.01153353685 1344.3914053279 1110.5928042833 1356.4867163634 -1116.8904328343        686.89908069056 339.45770187193 652.82431002716 1611.289955647  536.75546426691 1800.8596118637 969.53201811556 -430.93949715509        -159.57990356777        -318.58209507915        946.588114198   1452.7480986625 -1266.2197056661        -2712.1671516701        725.39267509294 -1799.4059896759        -194.31781745786932.21901991708 -1371.767243255 -1690.6006794811        2358.355192253  682.63311029972 -935.90384931891        1623.9710993504 511.27503244908 -566.91923596431        1241.2772791148 1293.1232384536 -730.99676696673        861.00114173575 -766.447081269  1727.4950017098 655.57596589031 -1087.4112124088        225.47137723047 1559.1879295887 1261.0410012136 1258.5418249738 2298.5813882385 865.72514269351 1438.4726136085 457.08067617818 -282.34909797409        2761.4280576806 -1638.7825382364        571.92338366072 640.17945909262 -419.0697150921 -1130.9744771761        -1846.4034333389        1014.8747176344 3303.4874763601 -671.94790631458        1822.7002834967 897.8473593171  -785.51414256548        -1031.0257285935        2227.0653027288 495.91596375239 -735.21669877187        -188.14025417353-1251.1335056643        -1456.3326081602        1915.2404041664 1964.8079191957 -708.46260348011        -404.4617126491 2115.499813497  -1856.0752503055        -1012.5502010785        -404.56424958808        -445.7077835338 -3295.2104470638        -340.91678707055        1393.9643835817 -505.85010017925        262.98614088966 -4251.9119787471        -146.18901444067        -2896.9075595062        -480.82585353923        -1998.5083062516        1186.8579867432 -1971.0940633692        -741.12265004017        1797.5348299662 497.04339151265 403.54943651732 -166.69423811938        206.81292824383 1062.015275105  175.17787440071 1015.5655591676 1709.0292306164 -1316.1367459352        455.10050139255 -1498.9581461326        -1642.8050866016        1013.3959700393 -3952.641280335 872.63520771677 -577.66248554444-1499.0851441687        1176.0725614072 2555.6293246162 -1249.8177615841        510.98322993172 49.515235521899 1162.6642224525 2030.0907410442 2003.8001724426 470.61589712654 -3373.9467717791        -1961.5029073716        1394.9977505765 1207.7095504182 -1850.388467242 -1117.3572449794        629.91149973987 -1172.6219524914        495.38721087484 1785.3410397628 -105.85662854821        3130.0435835205 -995.88852622955        -467.20200095086        -408.4259459475 -754.40328372532        -1049.2798855641        421.97907726724 2281.9500284981 783.02404463494 -69.399187643013        -527.99328048281        1101.4436844943 -2178.5413038052        -3295.8491457137        91.993932680129 -1523.9770947379        -662.33939978116        -740.35021504201        1906.5543625311 2493.0871631242 -1368.9318968778        1315.0284232673 -2768.706866466 1545.299503977  3700.363741559  -1448.8054282245        333.75312587817 -1795.3690587126        1297.1733754821 -866.99916880819        -379.96329924349        186.93110352915 155.35170697519 254.2568333999  1187.3323401811 865.42667200416 -2037.2153891881        1375.0241851279 -2015.2447901185        1183.5264720364 2431.3765898899 729.73104964148 597.95998991586 -291.51713206988        -2238.3354989279        -1022.3764534914        -264.29849506486        1353.1290938076 -1557.6409386478        -582.11364174922        -3108.2801799078        -303.22502295151        -182.80914901925        -192.3186082525 -1126.6396481282        -2146.795119017 6169.9364085131 306.83021449463
    
-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 400
----------------:------------
Pred.[0]/Act.[*]: 194   7
Pred.[1]/Act.[*]: 6     193
----------------:------------
Accuracy        : 96.75%
Precision       : 96.98%
Recall          : 96.5%
----------------:------------
FScore          : 96.74%
-----------------------------
    
-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 400
----------------:------------
Pred.[0]/Act.[*]: 196   12
Pred.[1]/Act.[*]: 4     188
----------------:------------
Accuracy        : 96%
Precision       : 97.92%
Recall          : 94%
----------------:------------
FScore          : 95.92%
-----------------------------

Código example_perceptron_kernel_gaussian_yinyang.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Pds::Matrix F;
double Sigma=0.6;
// Generating data
unsigned int L=1000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Matrix G;
// Create Perceptron
G=Pds::MergeVer( {Pds::Clustering::Kmeans(Conf,X.GetRows(Pds::Find(Y)),60),
Pds::Clustering::Kmeans(Conf,X.GetRows(Pds::Find(1-Y)), 60)}
); //X
F=Pds::Kernel::Gaussian(X,G,Sigma);
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");
// Evaluate testing data
F=Pds::Kernel::Gaussian(X,G,Sigma);
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.
Pds::Matrix Kmeans(Pds::IterationConf &Conf, const std::vector< Pds::Matrix > &Block, unsigned int K, Pds::Array< unsigned int > &IDMAP)
Calculo de los centroides.
void LoadDataYinYang(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de 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.
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