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
sourceimpl<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
sourceimpl<F: Clone, L: Clone> Clone for DecisionTreeValidParams<F, L>
impl<F: Clone, L: Clone> Clone for DecisionTreeValidParams<F, L>
sourcefn clone(&self) -> DecisionTreeValidParams<F, L>
fn clone(&self) -> DecisionTreeValidParams<F, L>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: Debug, L: Debug> Debug for DecisionTreeValidParams<F, L>
impl<F: Debug, L: Debug> Debug for DecisionTreeValidParams<F, L>
sourceimpl<'a, F: Float, L: Label + 'a + 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<'a, F: Float, L: Label + 'a + 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>,
sourcefn fit(
&self,
dataset: &DatasetBase<ArrayBase<D, Ix2>, T>
) -> Result<Self::Object>
fn fit(
&self,
dataset: &DatasetBase<ArrayBase<D, Ix2>, T>
) -> Result<Self::Object>
Fit a decision tree using hyperparamters
on the dataset consisting of
a matrix of features x
and an array of labels y
.
type Object = DecisionTree<F, L>
sourceimpl<F: PartialEq, L: PartialEq> PartialEq<DecisionTreeValidParams<F, L>> for DecisionTreeValidParams<F, L>
impl<F: PartialEq, L: PartialEq> PartialEq<DecisionTreeValidParams<F, L>> for DecisionTreeValidParams<F, L>
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &DecisionTreeValidParams<F, L>) -> bool
fn ne(&self, other: &DecisionTreeValidParams<F, L>) -> bool
This method tests for !=
.
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> where
F: Send,
L: Send,
impl<F, L> Sync for DecisionTreeValidParams<F, L> where
F: Sync,
L: Sync,
impl<F, L> Unpin for DecisionTreeValidParams<F, L> where
F: Unpin,
L: Unpin,
impl<F, L> UnwindSafe for DecisionTreeValidParams<F, L> where
F: UnwindSafe,
L: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more