pub struct DecisionTreeClassifier<State = Untrained> { /* private fields */ }Expand description
Decision Tree Classifier
Implementations§
Source§impl DecisionTreeClassifier<Untrained>
impl DecisionTreeClassifier<Untrained>
Sourcepub fn is_fitted(&self) -> bool
pub fn is_fitted(&self) -> bool
Check if the classifier has been fitted (always false for untrained classifiers)
Sourcepub fn criterion(self, criterion: SplitCriterion) -> Self
pub fn criterion(self, criterion: SplitCriterion) -> Self
Set the split criterion
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
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 at a leaf
Sourcepub fn max_features(self, max_features: MaxFeatures) -> Self
pub fn max_features(self, max_features: MaxFeatures) -> Self
Set the maximum features strategy
Sourcepub fn random_state(self, seed: u64) -> Self
pub fn random_state(self, seed: u64) -> Self
Set the random state
Sourcepub fn min_impurity_decrease(self, min_impurity_decrease: f64) -> Self
pub fn min_impurity_decrease(self, min_impurity_decrease: f64) -> Self
Set the minimum impurity decrease
Sourcepub fn pruning(self, pruning: PruningStrategy) -> Self
pub fn pruning(self, pruning: PruningStrategy) -> Self
Set the pruning strategy
Sourcepub fn missing_values(self, missing_values: MissingValueStrategy) -> Self
pub fn missing_values(self, missing_values: MissingValueStrategy) -> Self
Set the missing values handling strategy
Sourcepub fn feature_types(self, feature_types: Vec<FeatureType>) -> Self
pub fn feature_types(self, feature_types: Vec<FeatureType>) -> Self
Set feature types to enable multiway splits for categorical features
Sourcepub fn growing_strategy(self, strategy: TreeGrowingStrategy) -> Self
pub fn growing_strategy(self, strategy: TreeGrowingStrategy) -> Self
Set tree growing strategy
Sourcepub fn split_type(self, split_type: SplitType) -> Self
pub fn split_type(self, split_type: SplitType) -> Self
Set the split type (axis-aligned or oblique)
Source§impl DecisionTreeClassifier<Trained>
impl DecisionTreeClassifier<Trained>
Sourcepub fn is_fitted(&self) -> bool
pub fn is_fitted(&self) -> bool
Check if the classifier has been fitted (always true for trained classifiers)
Sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Get the number of features
Sourcepub fn max_depth_reached(&self) -> Option<usize>
pub fn max_depth_reached(&self) -> Option<usize>
Get the maximum depth reached
Sourcepub fn feature_importances(&self) -> Result<Array1<f64>>
pub fn feature_importances(&self) -> Result<Array1<f64>>
Get feature importances (impurity-based, normalised to sum to 1.0).
Importances are computed via SmartCore’s compute_feature_importances which
aggregates the impurity decrease weighted by the number of samples at each
internal node and then normalises to unit sum.
Trait Implementations§
Source§impl Default for DecisionTreeClassifier<Untrained>
impl Default for DecisionTreeClassifier<Untrained>
Source§impl Estimator for DecisionTreeClassifier<Untrained>
impl Estimator for DecisionTreeClassifier<Untrained>
Source§type Config = DecisionTreeConfig
type Config = DecisionTreeConfig
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
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>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for DecisionTreeClassifier<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for DecisionTreeClassifier<Untrained>
Source§type Fitted = DecisionTreeClassifier<Trained>
type Fitted = DecisionTreeClassifier<Trained>
Source§fn fit(self, x: &Array2<Float>, y: &Array1<i32>) -> Result<Self::Fitted>
fn fit(self, x: &Array2<Float>, y: &Array1<i32>) -> Result<Self::Fitted>
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,
Source§impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for DecisionTreeClassifier<Trained>
impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for DecisionTreeClassifier<Trained>
Source§fn predict(&self, x: &Array2<Float>) -> Result<Array1<i32>>
fn predict(&self, x: &Array2<Float>) -> Result<Array1<i32>>
Source§fn predict_with_uncertainty(
&self,
x: &X,
) -> Result<(Output, UncertaintyMeasure), SklearsError>
fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>
Auto Trait Implementations§
impl<State> Forget for DecisionTreeClassifier<State>
impl<State> Freeze for DecisionTreeClassifier<State>where
PhantomData<State>: Freeze,
impl<State> Move for DecisionTreeClassifier<State>
impl<State> RefUnwindSafe for DecisionTreeClassifier<State>where
PhantomData<State>: RefUnwindSafe,
impl<State> Send for DecisionTreeClassifier<State>where
PhantomData<State>: Send,
impl<State> Sync for DecisionTreeClassifier<State>where
PhantomData<State>: Sync,
impl<State> Unpin for DecisionTreeClassifier<State>where
PhantomData<State>: Unpin,
impl<State> UnsafeUnpin for DecisionTreeClassifier<State>where
PhantomData<State>: UnsafeUnpin,
impl<State> UnwindSafe for DecisionTreeClassifier<State>where
PhantomData<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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