pub struct DecisionTreeValidParams<F, L> { /* private fields */ }
Expand description
The set of hyperparameters that can be specified for fitting a decision tree.
§Example
use linfa_trees::{DecisionTree, SplitQuality};
use linfa_datasets::iris;
use linfa::prelude::*;
// Initialize the default set of parameters
let params = DecisionTree::params();
// Set the parameters to the desired values
let params = params.split_quality(SplitQuality::Entropy).max_depth(Some(5)).min_weight_leaf(2.);
// Load the data
let (train, val) = linfa_datasets::iris().split_with_ratio(0.9);
// Fit the decision tree on the training data
let tree = params.fit(&train).unwrap();
// Predict on validation and check accuracy
let val_accuracy = tree.predict(&val).confusion_matrix(&val).unwrap().accuracy();
assert!(val_accuracy > 0.9);
Implementations§
Source§impl<F: Float, L> DecisionTreeValidParams<F, L>
impl<F: Float, L> DecisionTreeValidParams<F, L>
pub fn split_quality(&self) -> SplitQuality
pub fn max_depth(&self) -> Option<usize>
pub fn min_weight_split(&self) -> f32
pub fn min_weight_leaf(&self) -> f32
pub fn min_impurity_decrease(&self) -> F
Trait Implementations§
Source§impl<F: Clone, L: Clone> Clone for DecisionTreeValidParams<F, L>
impl<F: Clone, L: Clone> Clone for DecisionTreeValidParams<F, L>
Source§fn clone(&self) -> DecisionTreeValidParams<F, L>
fn clone(&self) -> DecisionTreeValidParams<F, L>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<F: Float, L: Label + Debug, D, T> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, Error> for DecisionTreeValidParams<F, L>where
D: Data<Elem = F>,
T: AsSingleTargets<Elem = L> + Labels<Elem = L>,
impl<F: Float, L: Label + Debug, D, T> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, Error> for DecisionTreeValidParams<F, L>where
D: Data<Elem = F>,
T: AsSingleTargets<Elem = L> + Labels<Elem = L>,
Source§impl<F: PartialEq, L: PartialEq> PartialEq for DecisionTreeValidParams<F, L>
impl<F: PartialEq, L: PartialEq> PartialEq for DecisionTreeValidParams<F, L>
Source§fn eq(&self, other: &DecisionTreeValidParams<F, L>) -> bool
fn eq(&self, other: &DecisionTreeValidParams<F, L>) -> bool
Tests for
self
and other
values to be equal, and is used by ==
.impl<F: Copy, L: Copy> Copy for DecisionTreeValidParams<F, L>
impl<F, L> StructuralPartialEq for DecisionTreeValidParams<F, L>
Auto Trait Implementations§
impl<F, L> Freeze for DecisionTreeValidParams<F, L>where
F: Freeze,
impl<F, L> RefUnwindSafe for DecisionTreeValidParams<F, L>where
F: RefUnwindSafe,
L: RefUnwindSafe,
impl<F, L> Send for DecisionTreeValidParams<F, L>
impl<F, L> Sync for DecisionTreeValidParams<F, L>
impl<F, L> Unpin for DecisionTreeValidParams<F, L>
impl<F, L> UnwindSafe for DecisionTreeValidParams<F, L>where
F: UnwindSafe,
L: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.