pub struct LogisticRegressionBuilder { /* private fields */ }Expand description
Builder for creating LogisticRegression models with customizable configurations.
The LogisticRegressionBuilder provides methods to configure the properties of a LogisticRegression model before it is instantiated, following the Builder design pattern.
§Fields
n_features- The number of input features for the logistic regression modelactivation_fn- The activation function to use (default: Sigmoid)
§Examples
use rust_ml::model::logistic_regression::LogisticRegression;
use rust_ml::core::activations::activation_functions::ActivationFn;
use rust_ml::builders::builder::Builder;
// Create a logistic regression model with 4 features and sigmoid activation
let model = LogisticRegression::builder()
.n_features(4)
.activation_function(ActivationFn::Sigmoid)
.build()
.unwrap();Implementations§
Source§impl LogisticRegressionBuilder
impl LogisticRegressionBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new LogisticRegressionBuilder with default parameter values.
The default configuration uses 1 feature and the Sigmoid activation function.
§Returns
Self- A new LogisticRegressionBuilder instance with default settings
Sourcepub fn n_features(self, n_features: usize) -> Self
pub fn n_features(self, n_features: usize) -> Self
Sourcepub fn activation_function(self, activation_function: ActivationFn) -> Self
pub fn activation_function(self, activation_function: ActivationFn) -> Self
Sets the activation function to use in the logistic regression model.
While sigmoid is the traditional activation function for logistic regression, other functions like ReLU or Tanh could be used for specific use cases.
§Arguments
activation_function- The activation function to use
§Returns
Self- Builder instance with updated activation function for method chaining
Trait Implementations§
Source§impl Builder<LogisticRegression, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegressionBuilder
impl Builder<LogisticRegression, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegressionBuilder
Source§fn build(&self) -> Result<LogisticRegression, ModelError>
fn build(&self) -> Result<LogisticRegression, ModelError>
Builds and returns a new LogisticRegression model with the configured parameters.
§Returns
Result<LogisticRegression, ModelError>- A new LogisticRegression instance with the specified configuration, or an error if construction fails
Source§impl Default for LogisticRegressionBuilder
impl Default for LogisticRegressionBuilder
Auto Trait Implementations§
impl Freeze for LogisticRegressionBuilder
impl RefUnwindSafe for LogisticRegressionBuilder
impl Send for LogisticRegressionBuilder
impl Sync for LogisticRegressionBuilder
impl Unpin for LogisticRegressionBuilder
impl UnwindSafe for LogisticRegressionBuilder
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> 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