pub struct DL85Builder<C, D, E, H>where
C: Caching + ?Sized,
D: OptimalDepth2Tree + ?Sized,
E: ErrorWrapper + ?Sized,
H: Heuristic + ?Sized,{ /* private fields */ }Expand description
Builder for DL85.
A cache, a depth-2 solver, an error function and a heuristic are required. The pure-node, lower-bound and already-solved rules are always included; depth, support and time limits add their own rules.
use dtrees_rs::algorithms::common::errors::NativeError;
use dtrees_rs::algorithms::common::heuristics::NoHeuristic;
use dtrees_rs::algorithms::optimal::depth2::ErrorMinimizer;
use dtrees_rs::algorithms::optimal::dl85::DL85Builder;
use dtrees_rs::caching::Trie;
let error_fn = Box::<NativeError>::default();
let dl85 = DL85Builder::default()
.max_depth(3)
.min_support(5)
.max_time(60.0)
.cache(Box::<Trie>::default())
.heuristic(Box::<NoHeuristic>::default())
.depth2_search(Box::new(ErrorMinimizer::new(error_fn.clone())))
.error_function(error_fn)
.build();
assert!(dl85.is_ok());Implementations§
Source§impl<C, D, E, H> DL85Builder<C, D, E, H>where
C: Caching + ?Sized,
D: OptimalDepth2Tree + ?Sized,
E: ErrorWrapper + ?Sized,
H: Heuristic + ?Sized,
impl<C, D, E, H> DL85Builder<C, D, E, H>where
C: Caching + ?Sized,
D: OptimalDepth2Tree + ?Sized,
E: ErrorWrapper + ?Sized,
H: Heuristic + ?Sized,
Sourcepub fn min_support(self, value: usize) -> Self
pub fn min_support(self, value: usize) -> Self
Minimum number of instances in each leaf.
Sourcepub fn default_rules(self) -> Self
pub fn default_rules(self) -> Self
Adds the rules every search needs: already-solved nodes, pure nodes
and the lower bound. Called by Self::new.
Sourcepub fn depth2_search(self, search: Box<D>) -> Self
pub fn depth2_search(self, search: Box<D>) -> Self
The solver used for depth-2 subtrees.
Sourcepub fn add_node_rule(self, rule: Box<dyn Rule>) -> Self
pub fn add_node_rule(self, rule: Box<dyn Rule>) -> Self
Adds a rule evaluated on entering each node.
Sourcepub fn add_node_rules(self, rules: Vec<Box<dyn Rule>>) -> Self
pub fn add_node_rules(self, rules: Vec<Box<dyn Rule>>) -> Self
Adds several node rules.
Sourcepub fn add_search_rule(self, rule: Box<dyn Rule>) -> Self
pub fn add_search_rule(self, rule: Box<dyn Rule>) -> Self
Adds a rule evaluated before branching on each candidate feature,
such as DiscrepancyRule
or TopkRule.
Sourcepub fn add_search_rules(self, rules: Vec<Box<dyn Rule>>) -> Self
pub fn add_search_rules(self, rules: Vec<Box<dyn Rule>>) -> Self
Adds several search rules.
Sourcepub fn always_sort(self, value: bool) -> Self
pub fn always_sort(self, value: bool) -> Self
Sort the features by the heuristic at every node, not only at the root.
Sourcepub fn specialization(self, value: OptimalDepth2Policy) -> Self
pub fn specialization(self, value: OptimalDepth2Policy) -> Self
Whether to use the depth-2 solver.
Sourcepub fn lower_bound_strategy(self, value: LowerBoundPolicy) -> Self
pub fn lower_bound_strategy(self, value: LowerBoundPolicy) -> Self
Whether to use the similarity lower bound.
Sourcepub fn branching_strategy(self, value: BranchingPolicy) -> Self
pub fn branching_strategy(self, value: BranchingPolicy) -> Self
Which branch of a feature is searched first.
Sourcepub fn node_exposed_data(self, value: NodeDataType) -> Self
pub fn node_exposed_data(self, value: NodeDataType) -> Self
What the error function receives: class counts or instance ids.
Sourcepub fn error_function(self, value: Box<E>) -> Self
pub fn error_function(self, value: Box<E>) -> Self
The error of a leaf.