Go to the documentation of this file.
109 (
const std::vector<typename Base::LabelC>& labelCs,
110 const std::vector<double>& ys) {
112 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
124 (
const std::vector<typename Base::LabelC>& labelCs,
125 const std::string&
table) {
127 std::vector<double> ys;
128 std::istringstream iss(
table);
129 std::copy(std::istream_iterator<double>(iss),
130 std::istream_iterator<double>(), std::back_inserter(ys));
134 Base::create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
144 template <
typename Iterator>
156 template <
typename M>
158 const std::map<M, L>& map) {
160 std::function<
L(
const M&)> L_of_M = [&map](
const M& label) ->
L {
161 return map.at(label);
163 std::function<double(
const double&)> op =
Ring::id;
178 template <
typename X,
typename Func>
210 auto visitor = [&](
double y) {
sum +=
y; };
211 this->
visit(visitor);
226 auto visitor = [&](
double x) {
min =
x <
min ?
x :
min; };
227 this->
visit(visitor);
235 auto visitor = [&](
double x) {
max =
x >
max ?
x :
max; };
236 this->
visit(visitor);
255 std::stringstream
ss;
256 ss << std::setw(4) << std::setprecision(8) <<
v;
272 template <
typename T>
274 :
public Testable<AlgebraicDecisionTree<T>> {};
std::function< std::string(Key)> LabelFormatter
AlgebraicDecisionTree operator-() const
AlgebraicDecisionTree(const DecisionTree< L, X > &other, Func f)
Create from an arbitrary DecisionTree<L, X> by operating on it with a functional f.
static Y add(const Y &y1, const Y &y2)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Concept check for values that can be used in unit tests.
static double div(const double &a, const double &b)
AlgebraicDecisionTree(double leaf=1.0)
bool equals(const DecisionTree &other, const CompareFunc &compare=&DefaultCompare) const
AlgebraicDecisionTree operator/(const AlgebraicDecisionTree &g) const
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
static std::string DefaultFormatter(const L &x)
Default method used by labelFormatter or valueFormatter when printing.
void print(const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const
GTSAM-style print.
bool equals(const AlgebraicDecisionTree &other, double tol=1e-9) const
Equality method customized to value type double.
double max() const
Find the maximum values amongst all leaves.
static double mul(const double &a, const double &b)
static std::stringstream ss
AlgebraicDecisionTree operator+(const AlgebraicDecisionTree &g) const
NodePtr root_
A DecisionTree just contains the root. TODO(dellaert): make protected.
static NodePtr compose(Iterator begin, Iterator end, const L &label)
AlgebraicDecisionTree normalize() const
Helper method to perform normalization such that all leaves in the tree sum to 1.
void visit(Func f) const
Visit all leaves in depth-first fashion.
AlgebraicDecisionTree operator-(const AlgebraicDecisionTree &g) const
AlgebraicDecisionTree(const typename Base::LabelC &labelC, double y1, double y2)
Create a new leaf function splitting on a variable.
DecisionTree apply(const Unary &op) const
AlgebraicDecisionTree sum(const L &label, size_t cardinality) const
void g(const string &key, int i)
double sum() const
Compute sum of all values.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
a decision tree is a function from assignments to values.
static NodePtr create(It begin, It end, ValueIt beginY, ValueIt endY)
AlgebraicDecisionTree(const AlgebraicDecisionTree< M > &other, const std::map< M, L > &map)
static double add(const double &a, const double &b)
void print(const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const
print method customized to value type double.
AlgebraicDecisionTree(const L &label, double y1, double y2)
std::pair< Key, size_t > LabelC
Array< int, Dynamic, 1 > v
double min() const
Find the minimum values amongst all leaves.
DecisionTree combine(const L &label, size_t cardinality, const Binary &op) const
AlgebraicDecisionTree operator*(const AlgebraicDecisionTree &g) const
static const EIGEN_DEPRECATED end_t end
AlgebraicDecisionTree(const Base &add)
static std::string valueFormatter(const double &v)
static double negate(const double &x)
AlgebraicDecisionTree(Iterator begin, Iterator end, const L &label)
Create a range of decision trees, splitting on a single variable.
static double id(const double &x)
static NodePtr convertFrom(const typename DecisionTree< L, X >::NodePtr &f, std::function< Y(const X &)> Y_of_X)
Convert from a DecisionTree<L, X> to DecisionTree<L, Y>.
AlgebraicDecisionTree sum(const typename Base::LabelC &labelC) const
Matrix< RealScalar, Dynamic, Dynamic > M
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:05