Home | Develop | Download | Contact
example_decisiontree_simple.cpp

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

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

Para executar o programa:

./example_decisiontree_simple

Retornando por consola:

Pds::DecisionTree::Counter: 2

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 994     1       ║
║ Pred.[1]/Act.[*]: 6       999     ║
╠═══════════════════════════════════╣
║         Accuracy: 99.65 %         ║
║        Precision: 99.4  %         ║
║           Recall: 99.9  %         ║
╠═══════════════════════════════════╣
║           FScore: 99.65 %         ║
╚═══════════════════════════════════╝

╔═══════════════════════════════════╗
║    ClassificationMetrics data     ║
╠═══════════════════════════════════╣
║        Threshold: 0.5             ║
║          Samples: 2000            ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 991     4       ║
║ Pred.[1]/Act.[*]: 9       996     ║
╠═══════════════════════════════════╣
║         Accuracy: 99.35 %         ║
║        Precision: 99.1  %         ║
║           Recall: 99.6  %         ║
╠═══════════════════════════════════╣
║           FScore: 99.35 %         ║
╚═══════════════════════════════════╝
example_decisiontree_simple_data.png


example_decisiontree_simple_training.png


example_decisiontree_simple_testing.png


example_decisiontree_simple_arbol.png

Código example_decisiontree_simple.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Vector Yp;
Conf.Show=false; Conf.SetMinError(1e-07); Conf.SetAlpha(0.1);
// =========================================================================
// Load training data
unsigned int L=1000;
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_decisiontree_simple_data.png");
// =========================================================================
// Creando un arbol
Pds::DecisionTree Arbol("k2means",Conf,X,Y,0.8,4);
std::cout<<"Pds::DecisionTree::Counter: "<<Pds::DecisionTree::Counter<<std::endl;
// Exportando arbol en archivo en formato dot.
Arbol.ExportDotFile("arbol.dot");
Pds::Ra::System("dot -Tpng -o example_decisiontree_simple_arbol.png arbol.dot");
// Predict training data
Yp=Arbol.Predict(X);
// Metrics of training
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_decisiontree_simple_training.png");
// =========================================================================
// Load testing data
// Predict testing data
Yp=Arbol.Predict(X);
// Metrics of testing
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_decisiontree_simple_testing.png");
return 0;
}
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.
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.
bool SetAlpha(double Alpha)
Coloca el valor alpha.
bool SetMinError(double MinError)
Coloca el valor MinError.
void LoadDataBand(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por mas de una curva.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed