Home | Develop | Download | Contact
example_ensembledecisiontree2.cpp

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

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

Para executar o programa:

./example_ensembledecisiontree2

Retornando por consola:

Pds::DecisionTree::Counter: 71
Trained bag   0 with 2000 samples obtaining  49 decision.
Trained bag   1 with 2000 samples obtaining  63 decision.
Trained bag   2 with 2000 samples obtaining  65 decision.
Trained bag   3 with 2000 samples obtaining  59 decision.
Trained bag   4 with 2000 samples obtaining  61 decision.
Trained bag   5 with 2000 samples obtaining  57 decision.
Trained bag   6 with 2000 samples obtaining  49 decision.
Trained bag   7 with 2000 samples obtaining  43 decision.
Trained bag   8 with 2000 samples obtaining  63 decision.
Trained bag   9 with 2000 samples obtaining  61 decision.
Trained bag  10 with 2000 samples obtaining  47 decision.
Trained bag  11 with 2000 samples obtaining  45 decision.
Trained bag  12 with 2000 samples obtaining  49 decision.
Trained bag  13 with 2000 samples obtaining  61 decision.
Trained bag  14 with 2000 samples obtaining  51 decision.
Trained bag  15 with 2000 samples obtaining  49 decision.

Código example_ensembledecisiontree2.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Octave::XLabel="x_1";
Pds::Octave::YLabel="x_2";
Pds::Vector Yp;
Conf.Show=false; Conf.SetMinError(1e-07); Conf.SetAlpha(0.1);
// Load training data
unsigned int L=2000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Octave::Plot::PointsX2DY(X,Y,"testando.m","example_ensembledecisiontree2_data_yinyang.png");
unsigned int StopSamples=3;
unsigned int StopDeep=64;
// Training DecisionTree
Pds::DecisionTree Arbol("k2means",Conf,X,Y,0.8,StopSamples,StopDeep);
std::cout<<"Pds::DecisionTree::Counter: "<<Pds::DecisionTree::Counter<<std::endl;
Arbol.ExportDotFile("arbol.dot");
// Predict training data
Yp=Arbol.Predict(X);
std::cout<<"Acc:"<<Pds::Accuracy(Y,Yp,0.5)<<"\n";
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_ensembledecisiontree2_simple_yinyang.png");
std::cout<<Pds::Ra::Repeat("*",128)<<"\n\n";
// Training Ensemble Decisiontree
Pds::EnsembleDecisionTree Arbol2(Conf,X,Y,16,0.5,0.8,StopSamples,StopDeep);
std::cout<<"Pds::DecisionTree::Counter: "<<Pds::DecisionTree::Counter<<std::endl;
Arbol2.GetStackingClassifier().Print("Arbol2.GetStackingClassifier():\n");
Arbol2.ExportFile("EnsembleDecisionTree.txt");
// Predict testing data
Yp=Arbol2.Predict(X);
std::cout<<"Acc:"<<Pds::Accuracy(Y,Yp,0.5)<<"\n";
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_ensembledecisiontree2_ensemble_yinyang.png");
std::cout<<Pds::Ra::Repeat("*",128)<<"\n\n";
// Ensemble DecisionTree
Pds::EnsembleDecisionTree Arbol3("EnsembleDecisionTree.txt");
Arbol3.GetStackingClassifier().Print("Arbol3.GetStackingClassifier():\n");
// Predict testing data
Yp=Arbol3.Predict(X);
std::cout<<"Acc:"<<Pds::Accuracy(Y,Yp,0.5)<<"\n";
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_ensembledecisiontree2_import_yinyang.png");
return 0;
}
La clase tipo Pds::DecisionTree . Esta clase genera un arbol de decision para unos datos dados....
static unsigned int Counter
La clase tipo Pds::EnsembleDecisionTree . Esta clase genera una matriz de Nlin lineas y 1 columna....
La clase tipo Pds::IterationConf . Esta clase genera una matriz de Nlin lineas y 1 columna....
double Predict(const Pds::Vector &x) const
Evalua el objeto de tipo Pds::DecisionTree.
bool ExportDotFile(const std::string &filename) const
Salva en formato .dot el objeto de tipo Pds::DecisionTree.
const Pds::Perceptron & GetStackingClassifier(void) const
Retorna el clasificador del segundo nivél.
bool ExportFile(const std::string &filename) const
Salva en formato texto el objeto de tipo Pds::EnsembleDecisionTree.
double Predict(const Pds::Vector &x) const
Evalua el objeto de tipo Pds::EnsembleDecisionTree.
bool SetAlpha(double Alpha)
Coloca el valor alpha.
bool SetMinError(double MinError)
Coloca el valor MinError.
void LoadDataYinYang(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de una curva.
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