pub struct LogisticRegression {
pub weights: Vector,
pub bias: Vector,
pub activation_fn: ActivationFn,
/* private fields */
}
Expand description
A logistic regression model for binary classification.
This model uses a linear combination of features and weights, followed by an activation function, to predict the probability of an input belonging to a positive class.
Fields§
§weights: Vector
Model weights for each feature
bias: Vector
Bias term (intercept)
activation_fn: ActivationFn
Activation function used for prediction
Implementations§
Source§impl LogisticRegression
impl LogisticRegression
Sourcepub fn new(
n_features: usize,
activation_fn: ActivationFn,
threshold: f64,
) -> Self
pub fn new( n_features: usize, activation_fn: ActivationFn, threshold: f64, ) -> Self
Sourcepub fn builder() -> LogisticRegressionBuilder
pub fn builder() -> LogisticRegressionBuilder
Returns a builder for creating LogisticRegression models with custom configurations.
§Returns
A new LogisticRegressionBuilder instance
Trait Implementations§
Source§impl BaseModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
Implementation of BaseModel trait for LogisticRegression
impl BaseModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
Implementation of BaseModel trait for LogisticRegression
Source§fn compute_cost(&self, x: &Matrix, y: &Vector) -> Result<f64, ModelError>
fn compute_cost(&self, x: &Matrix, y: &Vector) -> Result<f64, ModelError>
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 ClassificationModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
Implementation of ClassificationModel trait for LogisticRegression
impl ClassificationModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
Implementation of ClassificationModel trait for LogisticRegression
Source§fn compute_metrics(
&self,
x: &Matrix,
y: &Vector,
) -> Result<ClassificationMetrics, ModelError>
fn compute_metrics( &self, x: &Matrix, y: &Vector, ) -> Result<ClassificationMetrics, ModelError>
Source§impl Debug for LogisticRegression
impl Debug for LogisticRegression
Source§impl GradientCollection for LogisticRegression
impl GradientCollection for LogisticRegression
Source§fn get_gradient<D: Dimension>(
&self,
key: &str,
) -> Result<ArrayView<'_, f64, D>, ModelError>
fn get_gradient<D: Dimension>( &self, key: &str, ) -> Result<ArrayView<'_, f64, D>, ModelError>
Get a reference to a specific gradient with strong typing.
Source§fn set_gradient<D: Dimension>(
&mut self,
key: &str,
value: ArrayView<'_, f64, D>,
) -> Result<(), ModelError>
fn set_gradient<D: Dimension>( &mut self, key: &str, value: ArrayView<'_, f64, D>, ) -> Result<(), ModelError>
Set the value of a gradient.
Source§impl OptimizableModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
impl OptimizableModel<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for LogisticRegression
Source§fn compute_output_gradient(
&self,
x: &Matrix,
y: &Vector,
) -> Result<Vector, ModelError>
fn compute_output_gradient( &self, x: &Matrix, y: &Vector, ) -> Result<Vector, ModelError>
Source§impl ParamCollection for LogisticRegression
impl ParamCollection for LogisticRegression
Source§fn get<D: Dimension>(
&self,
key: &str,
) -> Result<ArrayView<'_, f64, D>, ModelError>
fn get<D: Dimension>( &self, key: &str, ) -> Result<ArrayView<'_, f64, D>, ModelError>
Get a reference to a specific parameter with strong typing.
fn get_mut<D: Dimension>( &mut self, key: &str, ) -> Result<ArrayViewMut<'_, f64, D>, ModelError>
Auto Trait Implementations§
impl Freeze for LogisticRegression
impl RefUnwindSafe for LogisticRegression
impl Send for LogisticRegression
impl Sync for LogisticRegression
impl Unpin for LogisticRegression
impl UnwindSafe for LogisticRegression
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