/usr/include/vigra/random_forest/rf_online_prediction_set.hxx is in libvigraimpex-dev 1.10.0+dfsg-3ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #include "../multi_array.hxx"
#include <set>
#include <vector>
namespace vigra
{
template<class T>
struct SampleRange
{
SampleRange(int start,int end,int num_features)
{
this->start=start;
this->end=end;
this->min_boundaries.resize(num_features,-FLT_MAX);
this->max_boundaries.resize(num_features,FLT_MAX);
}
int start;
mutable int end;
mutable std::vector<T> max_boundaries;
mutable std::vector<T> min_boundaries;
bool operator<(const SampleRange& o) const
{
return o.start<start;
}
};
template<class T>
class OnlinePredictionSet
{
public:
template<class U>
OnlinePredictionSet(MultiArrayView<2,T,U>& features,int num_sets)
{
this->features=features;
std::vector<int> init(features.shape(0));
for(unsigned int i=0;i<init.size();++i)
init[i]=i;
indices.resize(num_sets,init);
std::set<SampleRange<T> > set_init;
set_init.insert(SampleRange<T>(0,init.size(),features.shape(1)));
ranges.resize(num_sets,set_init);
cumulativePredTime.resize(num_sets,0);
}
int get_worsed_tree()
{
int result=0;
for(unsigned int i=0;i<cumulativePredTime.size();++i)
{
if(cumulativePredTime[i]>cumulativePredTime[result])
{
result=i;
}
}
return result;
}
void reset_tree(int index)
{
index=index % ranges.size();
std::set<SampleRange<T> > set_init;
set_init.insert(SampleRange<T>(0,features.shape(0),features.shape(1)));
ranges[index]=set_init;
cumulativePredTime[index]=0;
}
std::vector<std::set<SampleRange<T> > > ranges;
std::vector<std::vector<int> > indices;
std::vector<int> cumulativePredTime;
MultiArray<2,T> features;
};
}
|