pub struct DTrees { /* private fields */ }
Expand description
The class represents a single decision tree or a collection of decision trees.
The current public interface of the class allows user to train only a single decision tree, however the class is capable of storing multiple decision trees and using them for prediction (by summing responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) use this capability to implement decision tree ensembles.
§See also
[ml_intro_trees]
Implementations§
Source§impl DTrees
impl DTrees
Sourcepub fn create() -> Result<Ptr<DTrees>>
pub fn create() -> Result<Ptr<DTrees>>
Creates the empty model
The static method creates empty decision tree with the specified parameters. It should be then trained using train method (see StatModel::train). Alternatively, you can load the model from file using Algorithm::load<DTrees>(filename).
Sourcepub fn load(filepath: &str, node_name: &str) -> Result<Ptr<DTrees>>
pub fn load(filepath: &str, node_name: &str) -> Result<Ptr<DTrees>>
Loads and creates a serialized DTrees from a file
Use DTree::save to serialize and store an DTree to disk. Load the DTree from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
§Parameters
- filepath: path to serialized DTree
- nodeName: name of node containing the classifier
§C++ default parameters
- node_name: String()
Sourcepub fn load_def(filepath: &str) -> Result<Ptr<DTrees>>
pub fn load_def(filepath: &str) -> Result<Ptr<DTrees>>
Loads and creates a serialized DTrees from a file
Use DTree::save to serialize and store an DTree to disk. Load the DTree from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier
§Parameters
- filepath: path to serialized DTree
- nodeName: name of node containing the classifier
§Note
This alternative version of DTrees::load function uses the following default values for its arguments:
- node_name: String()
Trait Implementations§
Source§impl AlgorithmTrait for DTrees
impl AlgorithmTrait for DTrees
Source§impl AlgorithmTraitConst for DTrees
impl AlgorithmTraitConst for DTrees
fn as_raw_Algorithm(&self) -> *const c_void
Source§fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
Source§fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
Source§fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
Source§fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
§Note
Source§fn empty(&self) -> Result<bool>
fn empty(&self) -> Result<bool>
Source§fn save(&self, filename: &str) -> Result<()>
fn save(&self, filename: &str) -> Result<()>
Source§fn get_default_name(&self) -> Result<String>
fn get_default_name(&self) -> Result<String>
Source§impl Boxed for DTrees
impl Boxed for DTrees
Source§unsafe fn from_raw(ptr: <DTrees as OpenCVFromExtern>::ExternReceive) -> Self
unsafe fn from_raw(ptr: <DTrees as OpenCVFromExtern>::ExternReceive) -> Self
Source§fn into_raw(self) -> <DTrees as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <DTrees as OpenCVTypeExternContainer>::ExternSendMut
Source§fn as_raw(&self) -> <DTrees as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <DTrees as OpenCVTypeExternContainer>::ExternSend
Source§fn as_raw_mut(&mut self) -> <DTrees as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut(&mut self) -> <DTrees as OpenCVTypeExternContainer>::ExternSendMut
Source§impl DTreesTrait for DTrees
impl DTreesTrait for DTrees
fn as_raw_mut_DTrees(&mut self) -> *mut c_void
Source§fn set_max_categories(&mut self, val: i32) -> Result<()>
fn set_max_categories(&mut self, val: i32) -> Result<()>
Source§fn set_max_depth(&mut self, val: i32) -> Result<()>
fn set_max_depth(&mut self, val: i32) -> Result<()>
Source§fn set_min_sample_count(&mut self, val: i32) -> Result<()>
fn set_min_sample_count(&mut self, val: i32) -> Result<()>
Source§fn set_cv_folds(&mut self, val: i32) -> Result<()>
fn set_cv_folds(&mut self, val: i32) -> Result<()>
Source§fn set_use_surrogates(&mut self, val: bool) -> Result<()>
fn set_use_surrogates(&mut self, val: bool) -> Result<()>
Source§fn set_use1_se_rule(&mut self, val: bool) -> Result<()>
fn set_use1_se_rule(&mut self, val: bool) -> Result<()>
Source§fn set_truncate_pruned_tree(&mut self, val: bool) -> Result<()>
fn set_truncate_pruned_tree(&mut self, val: bool) -> Result<()>
Source§fn set_regression_accuracy(&mut self, val: f32) -> Result<()>
fn set_regression_accuracy(&mut self, val: f32) -> Result<()>
Source§fn set_priors(&mut self, val: &impl MatTraitConst) -> Result<()>
fn set_priors(&mut self, val: &impl MatTraitConst) -> Result<()>
Source§impl DTreesTraitConst for DTrees
impl DTreesTraitConst for DTrees
fn as_raw_DTrees(&self) -> *const c_void
Source§fn get_max_categories(&self) -> Result<i32>
fn get_max_categories(&self) -> Result<i32>
Source§fn get_max_depth(&self) -> Result<i32>
fn get_max_depth(&self) -> Result<i32>
Source§fn get_min_sample_count(&self) -> Result<i32>
fn get_min_sample_count(&self) -> Result<i32>
Source§fn get_cv_folds(&self) -> Result<i32>
fn get_cv_folds(&self) -> Result<i32>
Source§fn get_use_surrogates(&self) -> Result<bool>
fn get_use_surrogates(&self) -> Result<bool>
Source§fn get_use1_se_rule(&self) -> Result<bool>
fn get_use1_se_rule(&self) -> Result<bool>
Source§fn get_truncate_pruned_tree(&self) -> Result<bool>
fn get_truncate_pruned_tree(&self) -> Result<bool>
Source§fn get_regression_accuracy(&self) -> Result<f32>
fn get_regression_accuracy(&self) -> Result<f32>
Source§fn get_priors(&self) -> Result<Mat>
fn get_priors(&self) -> Result<Mat>
Source§fn get_splits(&self) -> Result<Vector<DTrees_Split>>
fn get_splits(&self) -> Result<Vector<DTrees_Split>>
Source§impl StatModelTrait for DTrees
impl StatModelTrait for DTrees
fn as_raw_mut_StatModel(&mut self) -> *mut c_void
Source§fn train_with_data(
&mut self,
train_data: &Ptr<TrainData>,
flags: i32,
) -> Result<bool>
fn train_with_data( &mut self, train_data: &Ptr<TrainData>, flags: i32, ) -> Result<bool>
Source§fn train_with_data_def(&mut self, train_data: &Ptr<TrainData>) -> Result<bool>
fn train_with_data_def(&mut self, train_data: &Ptr<TrainData>) -> Result<bool>
Source§fn train(
&mut self,
samples: &impl ToInputArray,
layout: i32,
responses: &impl ToInputArray,
) -> Result<bool>
fn train( &mut self, samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray, ) -> Result<bool>
Source§impl StatModelTraitConst for DTrees
impl StatModelTraitConst for DTrees
fn as_raw_StatModel(&self) -> *const c_void
Source§fn get_var_count(&self) -> Result<i32>
fn get_var_count(&self) -> Result<i32>
fn empty(&self) -> Result<bool>
Source§fn is_trained(&self) -> Result<bool>
fn is_trained(&self) -> Result<bool>
Source§fn is_classifier(&self) -> Result<bool>
fn is_classifier(&self) -> Result<bool>
Source§fn calc_error(
&self,
data: &Ptr<TrainData>,
test: bool,
resp: &mut impl ToOutputArray,
) -> Result<f32>
fn calc_error( &self, data: &Ptr<TrainData>, test: bool, resp: &mut impl ToOutputArray, ) -> Result<f32>
Source§fn predict(
&self,
samples: &impl ToInputArray,
results: &mut impl ToOutputArray,
flags: i32,
) -> Result<f32>
fn predict( &self, samples: &impl ToInputArray, results: &mut impl ToOutputArray, flags: i32, ) -> Result<f32>
Source§fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>
fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>
impl Send for DTrees
Auto Trait Implementations§
impl Freeze for DTrees
impl RefUnwindSafe for DTrees
impl !Sync for DTrees
impl Unpin for DTrees
impl UnwindSafe for DTrees
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
Source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res
Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data,
but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place
modification is imgproc::threshold
. Read more