Skip to main content

DL85Builder

Struct DL85Builder 

Source
pub struct DL85Builder<C, D, E, H>{ /* 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>

Source

pub fn new() -> Self

A builder with the default rules and no limits.

Source

pub fn min_support(self, value: usize) -> Self

Minimum number of instances in each leaf.

Source

pub fn max_depth(self, value: usize) -> Self

Maximum depth of the tree.

Source

pub fn max_error(self, value: f64) -> Self

Only trees with a lower error are accepted.

Source

pub fn max_time(self, value: f64) -> Self

Time limit in seconds for the whole search.

Source

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.

The solver used for depth-2 subtrees.

Source

pub fn add_node_rule(self, rule: Box<dyn Rule>) -> Self

Adds a rule evaluated on entering each node.

Source

pub fn add_node_rules(self, rules: Vec<Box<dyn Rule>>) -> Self

Adds several node rules.

Source

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.

Source

pub fn add_search_rules(self, rules: Vec<Box<dyn Rule>>) -> Self

Adds several search rules.

Source

pub fn always_sort(self, value: bool) -> Self

Sort the features by the heuristic at every node, not only at the root.

Source

pub fn specialization(self, value: OptimalDepth2Policy) -> Self

Whether to use the depth-2 solver.

Source

pub fn lower_bound_strategy(self, value: LowerBoundPolicy) -> Self

Whether to use the similarity lower bound.

Source

pub fn branching_strategy(self, value: BranchingPolicy) -> Self

Which branch of a feature is searched first.

Source

pub fn node_exposed_data(self, value: NodeDataType) -> Self

What the error function receives: class counts or instance ids.

Source

pub fn cache(self, value: Box<C>) -> Self

The cache of subproblems.

Source

pub fn error_function(self, value: Box<E>) -> Self

The error of a leaf.

Source

pub fn heuristic(self, value: Box<H>) -> Self

The heuristic used to order features.

Source

pub fn build(self) -> Result<DL85<C, D, E, H>, String>

Builds the search, or says which required part is missing.

Trait Implementations§

Source§

impl<C, D, E, H> Default for DL85Builder<C, D, E, H>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C, D, E, H> !RefUnwindSafe for DL85Builder<C, D, E, H>

§

impl<C, D, E, H> !UnwindSafe for DL85Builder<C, D, E, H>

§

impl<C, D, E, H> Freeze for DL85Builder<C, D, E, H>
where C: ?Sized, D: ?Sized, E: ?Sized, H: ?Sized,

§

impl<C, D, E, H> Send for DL85Builder<C, D, E, H>
where C: Send + ?Sized, D: Send + ?Sized, E: ?Sized, H: ?Sized,

§

impl<C, D, E, H> Sync for DL85Builder<C, D, E, H>
where C: Sync + ?Sized, D: Sync + ?Sized, E: ?Sized, H: ?Sized,

§

impl<C, D, E, H> Unpin for DL85Builder<C, D, E, H>
where C: ?Sized, D: ?Sized, E: ?Sized, H: ?Sized,

§

impl<C, D, E, H> UnsafeUnpin for DL85Builder<C, D, E, H>
where C: ?Sized, D: ?Sized, E: ?Sized, H: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.