LogisticRegressionParameters

Struct LogisticRegressionParameters 

Source
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: LogisticRegressionSolverName

Solver to use for estimation of regression coefficients.

§alpha: T

Regularization parameter.

Implementations§

Source§

impl<T> LogisticRegressionParameters<T>
where T: RealNumber,

Source

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}
Source

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,

Source§

fn clone(&self) -> LogisticRegressionParameters<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for LogisticRegressionParameters<T>
where T: Debug + RealNumber,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for LogisticRegressionParameters<T>
where T: RealNumber,

Source§

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>,

Source§

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,

Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,