Struct linfa_trees::DecisionTreeValidParams
source · 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.99);
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<'a, F: Float, L: Label + 'a + Debug, D, T> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, Error> for DecisionTreeValidParams<F, L>
impl<'a, F: Float, L: Label + 'a + Debug, D, T> Fit<ArrayBase<D, Dim<[usize; 2]>>, T, Error> for DecisionTreeValidParams<F, 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
This method 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> 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