pub struct DecisionTree<State = Untrained> { /* private fields */ }Expand description
Main Decision Tree structure that can be used for both classification and regression
Implementations§
Source§impl<State> DecisionTree<State>
impl<State> DecisionTree<State>
Sourcepub fn with_config(config: DecisionTreeConfig) -> Self
pub fn with_config(config: DecisionTreeConfig) -> Self
Create a new DecisionTree with custom configuration
Sourcepub fn builder() -> DecisionTreeBuilder<State>
pub fn builder() -> DecisionTreeBuilder<State>
Create a builder for configuring the decision tree
Sourcepub fn config(&self) -> &DecisionTreeConfig
pub fn config(&self) -> &DecisionTreeConfig
Get the configuration of the decision tree
Sourcepub fn feature_importances(&self) -> Option<&Array1<f64>>
pub fn feature_importances(&self) -> Option<&Array1<f64>>
Get feature importances (if available)
Sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Get the number of features the tree was trained on
Sourcepub fn criterion(self, criterion: SplitCriterion) -> Self
pub fn criterion(self, criterion: SplitCriterion) -> Self
Set the split criterion (fluent API)
Sourcepub fn max_depth(self, max_depth: usize) -> Self
pub fn max_depth(self, max_depth: usize) -> Self
Set the maximum depth of the tree (fluent API)
Sourcepub fn min_samples_split(self, min_samples_split: usize) -> Self
pub fn min_samples_split(self, min_samples_split: usize) -> Self
Set the minimum samples required to split an internal node (fluent API)
Sourcepub fn min_samples_leaf(self, min_samples_leaf: usize) -> Self
pub fn min_samples_leaf(self, min_samples_leaf: usize) -> Self
Set the minimum samples required to be at a leaf node (fluent API)
Sourcepub fn missing_values(self, strategy: MissingValueStrategy) -> Self
pub fn missing_values(self, strategy: MissingValueStrategy) -> Self
Set the missing value strategy (fluent API)
Sourcepub fn random_state(self, random_state: Option<u64>) -> Self
pub fn random_state(self, random_state: Option<u64>) -> Self
Set the random seed (fluent API)
Source§impl DecisionTree<Untrained>
impl DecisionTree<Untrained>
Trait Implementations§
Source§impl<State: Clone> Clone for DecisionTree<State>
impl<State: Clone> Clone for DecisionTree<State>
Source§fn clone(&self) -> DecisionTree<State>
fn clone(&self) -> DecisionTree<State>
Returns a duplicate 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<State: Debug> Debug for DecisionTree<State>
impl<State: Debug> Debug for DecisionTree<State>
Source§impl<State> Default for DecisionTree<State>
impl<State> Default for DecisionTree<State>
Source§impl Estimator<Trained> for DecisionTree<Trained>
impl Estimator<Trained> for DecisionTree<Trained>
Source§type Config = DecisionTreeConfig
type Config = DecisionTreeConfig
Configuration type for the estimator
Source§type Error = SklearsError
type Error = SklearsError
Error type for the estimator
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Validate estimator configuration with detailed error context
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Check if estimator is compatible with given data dimensions
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Get estimator metadata
Source§impl Estimator for DecisionTree<Untrained>
impl Estimator for DecisionTree<Untrained>
Source§type Config = DecisionTreeConfig
type Config = DecisionTreeConfig
Configuration type for the estimator
Source§type Error = SklearsError
type Error = SklearsError
Error type for the estimator
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Validate estimator configuration with detailed error context
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Check if estimator is compatible with given data dimensions
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Get estimator metadata
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for DecisionTree<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for DecisionTree<Untrained>
Source§type Fitted = DecisionTree<Trained>
type Fitted = DecisionTree<Trained>
The fitted model type
Source§fn fit(self, x: &Array2<f64>, y: &Array1<f64>) -> Result<Self::Fitted>
fn fit(self, x: &Array2<f64>, y: &Array1<f64>) -> Result<Self::Fitted>
Fit the model to the provided data with validation
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Fit with custom validation and early stopping
Source§impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for DecisionTree<Trained>
impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for DecisionTree<Trained>
Source§fn predict(&self, x: &Array2<f64>) -> Result<Array1<f64>>
fn predict(&self, x: &Array2<f64>) -> Result<Array1<f64>>
Make predictions on the provided data
Source§fn predict_with_uncertainty(
&self,
x: &X,
) -> Result<(Output, UncertaintyMeasure), SklearsError>
fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>
Make predictions with confidence intervals
Auto Trait Implementations§
impl<State> Freeze for DecisionTree<State>
impl<State> RefUnwindSafe for DecisionTree<State>where
State: RefUnwindSafe,
impl<State> Send for DecisionTree<State>where
State: Send,
impl<State> Sync for DecisionTree<State>where
State: Sync,
impl<State> Unpin for DecisionTree<State>where
State: Unpin,
impl<State> UnwindSafe for DecisionTree<State>where
State: 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> StableApi for Twhere
T: Estimator,
impl<T> StableApi for Twhere
T: Estimator,
Source§const STABLE_SINCE: &'static str = "0.1.0"
const STABLE_SINCE: &'static str = "0.1.0"
API version this type was stabilized in
Source§const HAS_EXPERIMENTAL_FEATURES: bool = false
const HAS_EXPERIMENTAL_FEATURES: bool = false
Whether this API has any experimental features