8 #ifndef PCL_GPU_PEOPLE_TREE_TRAIN_H_
9 #define PCL_GPU_PEOPLE_TREE_TRAIN_H_
12 #include <boost/array.hpp>
25 class Histogram :
public boost::array<uint32_t,NUMLABELS> {
27 inline Histogram() { std::fill(begin(), end(), 0); }
87 for(
int li=0;li<NUMLABELS;++li) Ntotal += uint64_t(h[li]);
97 for(
int li=0;li<NUMLABELS;++li) {
99 double p = double(h[li]) / Ntotal;
115 for(
int li=0;li<NUMLABELS;++li) {
116 uint64_t Ni = uint64_t(htrue[li]) + uint64_t(hfalse[li]);
118 double p = double(Ni) / Ntotal;
135 double Ntotal = Ntrue + Nfalse;
138 if( Ntotal == 0 )
return 0.;
139 return e0 - (Ntrue/Ntotal)*etrue - (Nfalse/Ntotal)*efalse;
146 for(
int li=0;li<NUMLABELS;++li) os<< h[li]<<
" ";
152 for(
int li=0;li<NUMLABELS;++li) is >> h[li];
175 os.write( (
const char*)&lfs[0],
sizeof(
LabeledFeature)*lfs.size() );
205 std::ofstream fout(filename.c_str() );
206 if( !fout.is_open() )
throw std::runtime_error(std::string(
"(E) could not open ") + filename );
208 fout<<int(attribId)<<
" "<<int(threshold)<<
"\n";
218 std::ifstream fin(filename.c_str() );
219 if( !fin.is_open() )
throw std::runtime_error(std::string(
"(E) could not open") + filename );
221 fin>>attribId >>threshold>>gain>>HP;
222 if( fin.fail() )
throw std::runtime_error(std::string(
"(E) malformed splitInfo file ") + filename );
std::ostream & operator<<(std::ostream &os, const AttribLocation &aloc)
std::istream & operator>>(std::istream &is, AttribLocation &aloc)
This file defines compatibility wrappers for low level I/O functions.
static uint64_t numElements(const Histogram &h)
static double informationGain(const HistogramPair &hp)
This will compute the gain in information resulting from the split.
SplitPoint(int ai, Attrib t)
Attrib attribs[NUMATTRIBS]
static void writeLabeledFeatureVec(std::ostream &os, const std::vector< LabeledFeature > &lfs)
void accumTrue(const Label label)
void readInfoFile(const std::string &filename, int &attribId, Attrib &threshold, double &gain, HistogramPair &HP)
LabeledFeature(const LabeledFeature &B)
static double entropy_merged(const HistogramPair &hp)
This is a little weird.
LabeledAttrib(const Label &label, const Attrib &attrib)
const Histogram h_false() const
const Histogram h_true() const
void accumFalse(const Label label)
void writeInfoFile(const std::string &filename, int attribId, Attrib threshold, double gain, const HistogramPair &HP)
static double entropy(const Histogram &h)
This is cool.