pub struct DecisionTree { /* private fields */ }Expand description
A single decision tree classifier. Configure tree-specific options
such as "maximum depth" or "minimum samples per split" via
DecisionTree::handle_mut before calling DecisionTree::fit.
Implementations§
Source§impl DecisionTree
impl DecisionTree
Sourcepub fn handle_mut(&mut self) -> &mut Handle
pub fn handle_mut(&mut self) -> &mut Handle
Borrow the underlying handle to set tree options.
Sourcepub fn fit(
&mut self,
n_samples: usize,
n_features: usize,
n_class: usize,
x: &[f64],
y: &[i32],
) -> Result<()>
pub fn fit( &mut self, n_samples: usize, n_features: usize, n_class: usize, x: &[f64], y: &[i32], ) -> Result<()>
Fit on column-major n_samples × n_features features x with
integer class labels y. n_class = 0 lets AOCL infer it from
the label distribution.
Sourcepub fn predict(
&mut self,
n_samples: usize,
n_features: usize,
x_test: &[f64],
labels: &mut [i32],
) -> Result<()>
pub fn predict( &mut self, n_samples: usize, n_features: usize, x_test: &[f64], labels: &mut [i32], ) -> Result<()>
Predict class labels for n_samples × n_features test data.
Sourcepub fn score(
&mut self,
n_samples: usize,
n_features: usize,
x_test: &[f64],
y_test: &[i32],
) -> Result<f64>
pub fn score( &mut self, n_samples: usize, n_features: usize, x_test: &[f64], y_test: &[i32], ) -> Result<f64>
Compute prediction accuracy on a labelled test set: returns the fraction of correctly classified samples.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for DecisionTree
impl Forget for DecisionTree
impl Freeze for DecisionTree
impl Move for DecisionTree
impl RefUnwindSafe for DecisionTree
impl Send for DecisionTree
impl Unpin for DecisionTree
impl UnsafeUnpin for DecisionTree
impl UnwindSafe for DecisionTree
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