GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
gurls::ConfBoltzman< T > Class Template Reference

ConfBoltzman is the sub-class of Confidence that computes the probability of belonging to the highest scoring class.

#include <boltzman.h>

Inheritance diagram for gurls::ConfBoltzman< T >:
Collaboration diagram for gurls::ConfBoltzman< T >:

List of all members.

Public Member Functions

GurlsOptionsListexecute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) throw (gException)
 Computes the probability of belonging to the highest scoring class.

Static Public Member Functions

static Confidence< T > * factory (const std::string &id) throw (BadConfidenceCreation)
 Factory function returning a pointer to the newly created object.

Detailed Description

template<typename T>
class gurls::ConfBoltzman< T >

Definition at line 58 of file boltzman.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::ConfBoltzman< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) throw (gException) [virtual]

The scores are converted in probabilities using the Boltzman distribution.

Parameters:
Xnot used
Ynot used
optoptions with the following:
  • pred (settable with the class Prediction and its subclasses)
Returns:
ret, a GurlsOptionList with the following fields:
  • confidence = array containing the confidence score for each row of the field pred of opt.
  • labels = array containing predicted class for each row of the field pred of opt.

Implements gurls::Confidence< T >.

Definition at line 77 of file boltzman.h.

{
    //   out = struct;
    //   [n,k] = size(opt.pred);
    const gMat2D<T> &pred = opt.getOptValue<OptMatrix<gMat2D<T> > >("pred");

    const unsigned long n = pred.rows();
    const unsigned long t = pred.cols();


//    expscores = exp(opt.pred);
//    expscores = expscores./(sum(expscores,2)*ones(1,k));
//    [out.confidence, out.labels] = max(expscores,[],2);

    const T* expscores = pred.getData();

    T sum;
    T* rowT = new T[t];

    gMat2D<T> *conf = new gMat2D<T>(n,1);
    T* confidence = conf->getData();

    gMat2D<T> *lab = new gMat2D<T>(n,1);
    T* labels = lab->getData();

    //TODO optmize search of two maxes
    for(unsigned long i=0; i<n; ++i)
    {
        getRow(expscores, n, t, i, rowT);
        exp(rowT, t);

        sum = sumv(rowT, t);
        scal(t, (T)(1.0/sum), rowT, 1);

        int index = static_cast<int>(std::max_element(rowT, rowT+t) - rowT);
        confidence[i] = rowT[index];
        labels[i] = index+1;
    }

    delete [] rowT;

    GurlsOptionsList* ret = new GurlsOptionsList("confidence");

    ret->addOpt("confidence", new OptMatrix<gMat2D<T> >(*conf));
    ret->addOpt("labels", new OptMatrix<gMat2D<T> >(*lab));

    return ret;
}
template<typename T>
static Confidence<T>* gurls::Confidence< T >::factory ( const std::string &  id) throw (BadConfidenceCreation) [inline, static, inherited]
Warning:
The returned pointer is a plain, un-managed pointer. The calling function is responsible of deallocating the object.

Definition at line 105 of file confidence.h.

    {
        if(id == "boltzman")
            return new ConfBoltzman<T>;
        if(id == "boltzmangap")
            return new ConfBoltzmanGap<T>;
        if(id == "gap")
                return new ConfGap<T>;
        if(id == "maxscore")
            return new ConfMaxScore<T>;
        throw BadConfidenceCreation(id);
    }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends