Struct DecisionTreeClassifier

Source
pub struct DecisionTreeClassifier { /* private fields */ }

Implementations§

Source§

impl DecisionTreeClassifier

Source

pub fn new( max_depth: usize, samples_split: usize, metric_function: fn(x: NDArray<f64>) -> f64, ) -> DecisionTreeClassifier

Create instance of decision tree classifier

Source

pub fn root(&self) -> &Node

Return root node of decision tree classifier tree

Source

pub fn build_tree(&self, features: &NDArray<f64>, curr_depth: usize) -> Node

Build decision tree classifier

Source

pub fn best_split(&self, features: NDArray<f64>) -> (f64, usize, f64)

Find optimal split for decision tree classifier

Source

pub fn information_gain( &self, feature: NDArray<f64>, left: NDArray<f64>, right: NDArray<f64>, ) -> f64

Calculate information gain for decision tree classifier

Source

pub fn select_max_class(&self, target: NDArray<f64>) -> f64

Select highest probability class from target output

Source

pub fn fit(&mut self, features: &NDArray<f64>, _target: &NDArray<f64>)

Fit decision tree classifier to features and target

Source

pub fn prediction(&self, inputs: NDArray<f64>, node: Node) -> f64

Generate prediction for row sample of decision tree classifier

Source

pub fn predict(&self, input: NDArray<f64>) -> NDArray<f64>

Generate prediction for all row samples for decision tree classification

Source

pub fn save(&self, filepath: &str) -> Result<()>

Save model parameters for decision tree classification

Source

pub fn load( filepath: &str, max_depth: usize, samples_split: usize, metric_function: fn(x: NDArray<f64>) -> f64, ) -> DecisionTreeClassifier

Load model parameters for decision tree classification

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V