Home | Develop | Download | Contact
example_logisticregression_ms.cpp

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

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

Para executar o programa:

./example_logisticregression_ms

Retornando por consola:

W:
0.0031532109277748      4.5655191182942 4.6114943601509
Elapsed time: 4.766 ms

-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 2000
----------------:------------
Pred.[0]/Act.[*]: 1006  0
Pred.[1]/Act.[*]: 3     991
----------------:------------
Accuracy        : 99.85%
Precision       : 99.7%
Recall          : 100%
----------------:------------
FScore          : 99.85%
-----------------------------

-----------------------------
 ClassificationMetrics data  
-----------------------------
Threshold       : 0.5
Samples         : 2000
----------------:------------
Pred.[0]/Act.[*]: 1009  2
Pred.[1]/Act.[*]: 2     987
----------------:------------
Accuracy        : 99.8%
Precision       : 99.8%
Recall          : 99.8%
----------------:------------
FScore          : 99.8%
-----------------------------
Classification - data


Classification - training


Classification - testing

Código example_logisticregression_ms.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::IterationConf Conf; Conf.Show=true; Conf.SetMinError(1e-07);
Pds::Vector Yp;
// Generating data
unsigned int L=5000;
Pds::Matrix X;
Pds::Vector Y;
Pds::Vector W(X.Ncol()+1);
// Split data set in {Training,Cross-validation,Test}
Pds::Octave::XLabel="x_1";
Pds::Octave::YLabel="x_2";
Pds::Octave::Plot::PointsX2DY(Dat.Xtr,Dat.Ytr,"testando.m","example_logisticregression_ms_data.png");
// Create W using training data
W.Fill(0.1); Conf.SetAlpha(0.1);
Pds::Ra::Tic();
W.T().Print("W:\n");
Pds::Ra::Toc();
// Testing W with testing data set
// Metrics
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DYW( Dat.Xcv,Yp.Geq(Metrics.Threshold),W,
"testando.m","example_logisticregression_ms_training.png");
// Testing W with testing data set
Metrics.Print("\n");
Pds::Octave::Plot::PointsX2DYW( Dat.Xtt,Yp.Geq(Metrics.Threshold),W,
"testando.m","example_logisticregression_ms_testing.png");
return 0;
}
La clase tipo Pds::ClassificationMetrics . Esta clase genera un bloque de datos para analizar curvas ...
La clase tipo Pds::DataSetBlock . Esta clase genera un bloque de datos para analizar curvas de aprend...
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.
static Pds::ClassificationMetrics Optimal(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.
Pds::DataSetBlock Split(const Pds::Matrix &X, const Pds::Vector &Y, double Training, double CrossVal, double Test)
Divide un data set en 3 data set: {Training, CrossValidation, Test}, selecionados aleatoriamente sin ...
void LoadDataLine(unsigned int L, Pds::Matrix &X, Pds::Vector &Y)
Clasificacion de datos separados por una linea.
Pds::Vector FittingLogitMeanSquare(Pds::IterationConf &Conf, const Pds::Matrix &X, const Pds::Vector &Y, double Delta=0.0001)
Calculo de pesos.
Pds::Vector Classify(const Pds::Vector &W, const Pds::Matrix &X)
Calculo del resultado del clasificador.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed