Programa para el testeo de las funciones.Para compilar o código example_decisiontree.cpp:
g++ -static -o example_decisiontree example_decisiontree.cpp -lpdsmlmm -lpdsramm -lpdsspmm
Para executar o programa:
Retornando por consola:
Pds::DecisionTree::Counter: 43
Training metrics:
╔═══════════════════════════════════╗
║ ClassificationMetrics data ║
╠═══════════════════════════════════╣
║ Threshold: 0.5 ║
║ Samples: 2000 ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 980 22 ║
║ Pred.[1]/Act.[*]: 20 978 ║
╠═══════════════════════════════════╣
║ Accuracy: 97.9 % ║
║ Precision: 98 % ║
║ Recall: 97.8 % ║
╠═══════════════════════════════════╣
║ FScore: 97.9 % ║
╚═══════════════════════════════════╝
Testing metrics:
╔═══════════════════════════════════╗
║ ClassificationMetrics data ║
╠═══════════════════════════════════╣
║ Threshold: 0.5 ║
║ Samples: 2000 ║
╠═══════════════════════════════════╣
║ Pred.[0]/Act.[*]: 970 35 ║
║ Pred.[1]/Act.[*]: 30 965 ║
╠═══════════════════════════════════╣
║ Accuracy: 96.75 % ║
║ Precision: 96.98 % ║
║ Recall: 96.5 % ║
╠═══════════════════════════════════╣
║ FScore: 96.74 % ║
╚═══════════════════════════════════╝
example_decisiontree_data.png
example_decisiontree_training.png
example_decisiontree_testing.png
Código example_decisiontree.cpp:
#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Octave::Colormap="jet";
Pds::Octave::XLabel="x_1";
Pds::Octave::YLabel="x_2";
Pds::Vector Yp;
Pds::Matrix X(Pds::Ra::TextFormat,"../test/dataset/data_x_yinyang.txt");
Pds::Vector Y(Pds::Ra::TextFormat,"../test/dataset/data_y_yinyang.txt");
Pds::Octave::Plot::PointsX2DY(X,Y,"testando.m","example_decisiontree_data.png");
Metrics.
Print(
"\nTraining metrics:\n");
Pds::Octave::Plot::PointsX2DY(X,Yp,"testando.m","example_decisiontree_training.png");
Pds::Matrix Xtt(Pds::Ra::TextFormat,"../test/dataset/data_x_yinyang_test.txt");
Pds::Vector Ytt(Pds::Ra::TextFormat,"../test/dataset/data_y_yinyang_test.txt");
Metrics.
Print(
"\nTesting metrics:\n");
Pds::Octave::Plot::PointsX2DY(Xtt,Yp,"testando.m","example_decisiontree_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.