23 #include <boost/function.hpp> 35 template<
typename L,
typename Y>
41 typedef boost::function<Y(const Y&)>
Unary;
42 typedef boost::function<Y(const Y&, const Y&)>
Binary;
54 typedef boost::shared_ptr<const Node>
Ptr;
56 #ifdef DT_DEBUG_MEMORY 62 #ifdef DT_DEBUG_MEMORY 63 std::cout << ++nrNodes <<
" constructed " <<
id() << std::endl; std::cout.flush();
69 #ifdef DT_DEBUG_MEMORY 70 std::cout << --nrNodes <<
" destructed " <<
id() << std::endl; std::cout.flush();
75 const void*
id()
const {
return this; }
78 virtual void print(
const std::string&
s =
"")
const = 0;
79 virtual void dot(std::ostream&
os,
bool showZero)
const = 0;
82 virtual bool equals(
const Node& other,
double tol = 1
e-9)
const = 0;
84 virtual Ptr
apply(
const Unary& op)
const = 0;
88 virtual Ptr
choose(
const L& label,
size_t index)
const = 0;
89 virtual bool isLeaf()
const = 0;
104 template<
typename It,
typename ValueIt>
105 NodePtr
create(
It begin,
It end, ValueIt beginY, ValueIt endY)
const;
108 template<
typename M,
typename X> NodePtr
110 L>& map, boost::function<
Y(
const X&)> op);
130 DecisionTree(
const std::vector<LabelC>& labelCs,
const std::vector<Y>& ys);
136 template<
typename Iterator>
144 template<
typename M,
typename X>
146 const std::map<M, L>& map, boost::function<
Y(
const X&)> op);
153 void print(
const std::string&
s =
"DecisionTree")
const;
181 NodePtr newRoot = root_->
choose(label, index);
190 return combine(labelC.first, labelC.second, op);
194 void dot(std::ostream&
os,
bool showZero =
true)
const;
197 void dot(
const std::string&
name,
bool showZero =
true)
const;
206 template<
typename Iterator> NodePtr
207 compose(Iterator begin, Iterator
end,
const L& label)
const;
215 template<
typename Y,
typename L>
221 template<
typename Y,
typename L>
225 return f.
apply(g, op);
Matrix< RealScalar, Dynamic, Dynamic > M
virtual void print(const std::string &s="") const =0
virtual bool isLeaf() const =0
virtual bool equals(const Node &other, double tol=1e-9) const =0
An assignment from labels to a discrete value index (size_t)
DecisionTree apply(const Unary &op) const
virtual Ptr choose(const L &label, size_t index) const =0
boost::function< Y(const Y &, const Y &)> Binary
virtual Ptr apply_g_op_fL(const Leaf &, const Binary &) const =0
DecisionTree choose(const L &label, size_t index) const
const mpreal root(const mpreal &x, unsigned long int k, mp_rnd_t r=mpreal::get_default_rnd())
virtual void dot(std::ostream &os, bool showZero) const =0
void g(const string &key, int i)
virtual Ptr apply(const Unary &op) const =0
virtual const Y & operator()(const Assignment< L > &x) const =0
DecisionTree combine(const L &label, size_t cardinality, const Binary &op) const
boost::shared_ptr< const Node > Ptr
boost::function< Y(const Y &)> Unary
NodePtr compose(Iterator begin, Iterator end, const L &label) const
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
string::const_iterator It
NodePtr create(It begin, It end, ValueIt beginY, ValueIt endY) const
ofstream os("timeSchurFactors.csv")
virtual Ptr apply_f_op_g(const Node &, const Binary &) const =0
bool operator==(const DecisionTree &q) const
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
NodePtr convert(const typename DecisionTree< M, X >::NodePtr &f, const std::map< M, L > &map, boost::function< Y(const X &)> op)
virtual bool sameLeaf(const Leaf &q) const =0
Annotation for function names.
virtual Ptr apply_g_op_fC(const Choice &, const Binary &) const =0
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::pair< L, size_t > LabelC
DecisionTree combine(const LabelC &labelC, const Binary &op) const