Home | Develop | Download | Contact
example_decisiontree.cpp
1 
60 #include <iostream>
61 #include <Pds/Ra>
62 #include <Pds/Ml>
63 
64 int main(void)
65 {
67  Pds::Octave::XLabel="x_1";
68  Pds::Octave::YLabel="x_2";
69 
71 
72  Pds::IterationConf Conf;
73  Conf.Show=false; Conf.SetMinError(1e-07); Conf.SetAlpha(0.1);
74 
75  Pds::Vector Yp;
76 
77 
78  // Load training data
79  unsigned int L=1000;
80  Pds::Matrix X;
81  Pds::Vector Y;
83 
84  Pds::Octave::Plot::ScatterX2DY(X,Y,"testando.m","example_decisiontree_data.png");
85 
86  // Creando un arbol
88  Pds::DecisionTree Arbol(Conf,X,Y,0.8,4);
89  std::cout<<"Pds::DecisionTree::Counter: "<<Pds::DecisionTree::Counter<<std::endl;
90 
91  // Exportando arbol en archivo en formato dot.
92  Arbol.ExportDotFile("arbol.dot");
93 
94  // Evaluate training data
95  Yp=Arbol.Evaluate(X);
96 
97  // Metrics of training
98  Metrics = Pds::ClassificationMetrics::Calculate(0.5,Yp,Y);
99  Metrics.Print("\nTraining metrics:\n");
100 
101  Pds::Octave::Plot::ScatterX2DY(X,Yp,"testando.m","example_decisiontree_training.png");
102 
103  // Load testing data
104  Pds::DataSet::Classification::LoadDataYinYang(L,X,Y); // Load new data
105 
106  // Evaluate testing data
107  Yp=Arbol.Evaluate(X);
108 
109  // Metrics of testing
110  Metrics = Pds::ClassificationMetrics::Calculate(Metrics.Threshold,Yp,Y);
111  Metrics.Print("\nTesting metrics:\n");
112 
113  Pds::Octave::Plot::ScatterX2DY(X,Yp,"testando.m","example_decisiontree_testing.png");
114 
115  return 0;
116 }
La clase tipo Pds::ClassificationMetrics . Esta clase genera un bloque de datos para analizar curvas ...
La clase tipo Pds::DecisionTree . Esta clase genera un arbol de decision para unos datos dados....
static unsigned int Counter
La clase tipo Pds::IterationConf . Esta clase genera una matriz de Nlin lineas y 1 columna....
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 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.
std::string YLabel
Texto correspondente a ylabel.
std::string XLabel
Texto correspondente a xlabel.
std::string Colormap
Corlormap usado en el código octave.
bool ScatterX2DY(const Pds::Matrix &X, const Pds::Vector &Y, const std::string &octfilename, const std::string &imgfilename)
Plot de muestras en 2D en las columnas X, muestra los valores de Y con una degradación de colores.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed