pub struct LogisticRegressionParameters<T>where
T: RealNumber,{
pub solver: LogisticRegressionSolverName,
pub alpha: T,
}Expand description
Parameters for logistic regression (re-export from Smartcore) Logistic Regression parameters
Fields§
§solver: LogisticRegressionSolverNameSolver to use for estimation of regression coefficients.
alpha: TRegularization parameter.
Implementations§
Source§impl<T> LogisticRegressionParameters<T>where
T: RealNumber,
impl<T> LogisticRegressionParameters<T>where
T: RealNumber,
Sourcepub fn with_solver(
self,
solver: LogisticRegressionSolverName,
) -> LogisticRegressionParameters<T>
pub fn with_solver( self, solver: LogisticRegressionSolverName, ) -> LogisticRegressionParameters<T>
Solver to use for estimation of regression coefficients.
Examples found in repository?
examples/maximal_classification.rs (line 31)
4fn main() {
5 // Totally customize settings
6 let settings = Settings::default_classification()
7 .with_number_of_folds(3)
8 .shuffle_data(true)
9 .verbose(true)
10 .with_final_model(FinalModel::Blending {
11 algorithm: Algorithm::CategoricalNaiveBayes,
12 meta_training_fraction: 0.15,
13 meta_testing_fraction: 0.15,
14 })
15 .skip(Algorithm::RandomForestClassifier)
16 .sorted_by(Metric::Accuracy)
17 .with_preprocessing(PreProcessing::ReplaceWithPCA {
18 number_of_components: 5,
19 })
20 .with_random_forest_classifier_settings(
21 RandomForestClassifierParameters::default()
22 .with_m(100)
23 .with_max_depth(5)
24 .with_min_samples_leaf(20)
25 .with_n_trees(100)
26 .with_min_samples_split(20),
27 )
28 .with_logistic_settings(
29 LogisticRegressionParameters::default()
30 .with_alpha(1.0)
31 .with_solver(LogisticRegressionSolverName::LBFGS),
32 )
33 .with_svc_settings(
34 SVCParameters::default()
35 .with_epoch(10)
36 .with_tol(1e-10)
37 .with_c(1.0)
38 .with_kernel(Kernel::Linear),
39 )
40 .with_decision_tree_classifier_settings(
41 DecisionTreeClassifierParameters::default()
42 .with_min_samples_split(20)
43 .with_max_depth(5)
44 .with_min_samples_leaf(20),
45 )
46 .with_knn_classifier_settings(
47 KNNClassifierParameters::default()
48 .with_algorithm(KNNAlgorithmName::CoverTree)
49 .with_k(3)
50 .with_distance(Distance::Euclidean)
51 .with_weight(KNNWeightFunction::Uniform),
52 )
53 .with_gaussian_nb_settings(GaussianNBParameters::default().with_priors(vec![1.0, 1.0]))
54 .with_categorical_nb_settings(CategoricalNBParameters::default().with_alpha(1.0));
55
56 // Save the settings for later use
57 settings.save("examples/maximal_classification_settings.yaml");
58
59 // Load a dataset from smartcore and add it to the regressor
60 let mut model =
61 SupervisedModel::new(smartcore::dataset::breast_cancer::load_dataset(), settings);
62
63 // Run a model comparison with all models at default settings
64 model.train();
65
66 // Print the results
67 println!("{}", model);
68
69 // Save teh model for later
70 model.save("examples/maximal_classification_model.aml");
71}Sourcepub fn with_alpha(self, alpha: T) -> LogisticRegressionParameters<T>
pub fn with_alpha(self, alpha: T) -> LogisticRegressionParameters<T>
Regularization parameter.
Examples found in repository?
examples/maximal_classification.rs (line 30)
4fn main() {
5 // Totally customize settings
6 let settings = Settings::default_classification()
7 .with_number_of_folds(3)
8 .shuffle_data(true)
9 .verbose(true)
10 .with_final_model(FinalModel::Blending {
11 algorithm: Algorithm::CategoricalNaiveBayes,
12 meta_training_fraction: 0.15,
13 meta_testing_fraction: 0.15,
14 })
15 .skip(Algorithm::RandomForestClassifier)
16 .sorted_by(Metric::Accuracy)
17 .with_preprocessing(PreProcessing::ReplaceWithPCA {
18 number_of_components: 5,
19 })
20 .with_random_forest_classifier_settings(
21 RandomForestClassifierParameters::default()
22 .with_m(100)
23 .with_max_depth(5)
24 .with_min_samples_leaf(20)
25 .with_n_trees(100)
26 .with_min_samples_split(20),
27 )
28 .with_logistic_settings(
29 LogisticRegressionParameters::default()
30 .with_alpha(1.0)
31 .with_solver(LogisticRegressionSolverName::LBFGS),
32 )
33 .with_svc_settings(
34 SVCParameters::default()
35 .with_epoch(10)
36 .with_tol(1e-10)
37 .with_c(1.0)
38 .with_kernel(Kernel::Linear),
39 )
40 .with_decision_tree_classifier_settings(
41 DecisionTreeClassifierParameters::default()
42 .with_min_samples_split(20)
43 .with_max_depth(5)
44 .with_min_samples_leaf(20),
45 )
46 .with_knn_classifier_settings(
47 KNNClassifierParameters::default()
48 .with_algorithm(KNNAlgorithmName::CoverTree)
49 .with_k(3)
50 .with_distance(Distance::Euclidean)
51 .with_weight(KNNWeightFunction::Uniform),
52 )
53 .with_gaussian_nb_settings(GaussianNBParameters::default().with_priors(vec![1.0, 1.0]))
54 .with_categorical_nb_settings(CategoricalNBParameters::default().with_alpha(1.0));
55
56 // Save the settings for later use
57 settings.save("examples/maximal_classification_settings.yaml");
58
59 // Load a dataset from smartcore and add it to the regressor
60 let mut model =
61 SupervisedModel::new(smartcore::dataset::breast_cancer::load_dataset(), settings);
62
63 // Run a model comparison with all models at default settings
64 model.train();
65
66 // Print the results
67 println!("{}", model);
68
69 // Save teh model for later
70 model.save("examples/maximal_classification_model.aml");
71}Trait Implementations§
Source§impl<T> Clone for LogisticRegressionParameters<T>where
T: Clone + RealNumber,
impl<T> Clone for LogisticRegressionParameters<T>where
T: Clone + RealNumber,
Source§fn clone(&self) -> LogisticRegressionParameters<T>
fn clone(&self) -> LogisticRegressionParameters<T>
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<T> Debug for LogisticRegressionParameters<T>where
T: Debug + RealNumber,
impl<T> Debug for LogisticRegressionParameters<T>where
T: Debug + RealNumber,
Source§impl<T> Default for LogisticRegressionParameters<T>where
T: RealNumber,
impl<T> Default for LogisticRegressionParameters<T>where
T: RealNumber,
Source§fn default() -> LogisticRegressionParameters<T>
fn default() -> LogisticRegressionParameters<T>
Returns the “default value” for a type. Read more
Source§impl<'de, T> Deserialize<'de> for LogisticRegressionParameters<T>where
T: RealNumber + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for LogisticRegressionParameters<T>where
T: RealNumber + Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LogisticRegressionParameters<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LogisticRegressionParameters<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Serialize for LogisticRegressionParameters<T>where
T: RealNumber + Serialize,
impl<T> Serialize for LogisticRegressionParameters<T>where
T: RealNumber + Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<T> Freeze for LogisticRegressionParameters<T>where
T: Freeze,
impl<T> RefUnwindSafe for LogisticRegressionParameters<T>where
T: RefUnwindSafe,
impl<T> Send for LogisticRegressionParameters<T>where
T: Send,
impl<T> Sync for LogisticRegressionParameters<T>where
T: Sync,
impl<T> Unpin for LogisticRegressionParameters<T>where
T: Unpin,
impl<T> UnwindSafe for LogisticRegressionParameters<T>where
T: 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 more