@@ -6,22 +6,26 @@ use linfa_trees::DecisionTreeParams;
66use rand:: rngs:: ThreadRng ;
77use rand:: Rng ;
88
9+ /// The set of valid hyper-parameters that can be specified for the fitting procedure of the
10+ /// [Ensemble Learner](crate::EnsembleLearner).
911#[ derive( Clone , Copy , Debug , PartialEq ) ]
1012pub struct EnsembleLearnerValidParams < P , R > {
1113 /// The number of models in the ensemble
1214 pub ensemble_size : usize ,
1315 /// The proportion of the total number of training samples that should be given to each model for training
1416 pub bootstrap_proportion : f64 ,
15- /// The proportion of the total number of training feature that should be given to each model for training
17+ /// The proportion of the total number of training features that should be given to each model for training
1618 pub feature_proportion : f64 ,
1719 /// The model parameters for the base model
1820 pub model_params : P ,
1921 pub rng : R ,
2022}
2123
24+ /// A helper struct for building a set of [Ensemble Learner](crate::EnsembleLearner) hyper-parameters.
2225#[ derive( Clone , Copy , Debug , PartialEq ) ]
2326pub struct EnsembleLearnerParams < P , R > ( EnsembleLearnerValidParams < P , R > ) ;
2427
28+ /// A helper struct for building a set of [Random Forest](crate::RandomForest) hyper-parameters.
2529pub type RandomForestParams < F , L , R > = EnsembleLearnerParams < DecisionTreeParams < F , L > , R > ;
2630
2731impl < P > EnsembleLearnerParams < P , ThreadRng > {
@@ -41,16 +45,25 @@ impl<P, R: Rng + Clone> EnsembleLearnerParams<P, R> {
4145 } )
4246 }
4347
48+ /// Specifies the number of models to fit in the ensemble.
4449 pub fn ensemble_size ( mut self , size : usize ) -> Self {
4550 self . 0 . ensemble_size = size;
4651 self
4752 }
4853
54+ /// Sets the proportion of the total number of training samples that should be given to each model for training
55+ ///
56+ /// Note that the `proportion` should be in the interval (0, 1] in order to pass the
57+ /// parameter validation check.
4958 pub fn bootstrap_proportion ( mut self , proportion : f64 ) -> Self {
5059 self . 0 . bootstrap_proportion = proportion;
5160 self
5261 }
5362
63+ /// Sets the proportion of the total number of training features that should be given to each model for training
64+ ///
65+ /// Note that the `proportion` should be in the interval (0, 1] in order to pass the
66+ /// parameter validation check.
5467 pub fn feature_proportion ( mut self , proportion : f64 ) -> Self {
5568 self . 0 . feature_proportion = proportion;
5669 self
0 commit comments