glassbox.models.linear_model¶
Linear regression and classification models.
BaseLinearModel
¶
Bases: BaseModel
Abstract base class for linear models trained with gradient-based optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
learning_rate
|
float
|
Initial learning rate used by the optimizer. |
0.01
|
max_epochs
|
int
|
Maximum number of optimization epochs. |
1000
|
tol
|
float
|
Convergence tolerance used by stopping criteria. |
1e-6
|
schedule
|
LearningSchedule
|
Strategy used to update the learning rate across epochs. |
LearningSchedule.CONSTANT
|
Initialize shared linear-model hyperparameters and learned coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
learning_rate
|
float
|
Initial learning rate used by the optimizer. |
0.01
|
max_epochs
|
int
|
Maximum number of optimization epochs. |
1000
|
tol
|
float
|
Convergence tolerance used by stopping criteria. |
1e-6
|
schedule
|
LearningSchedule
|
Strategy used to update the learning rate across epochs. |
LearningSchedule.CONSTANT
|
Source code in glassbox/models/linear_model/_base.py
fit
abstractmethod
¶
Fit the linear model to training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Training feature matrix of shape (n_samples, n_features). |
required |
y
|
ndarray
|
Training target vector of shape (n_samples,). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The fitted model instance. |
Source code in glassbox/models/linear_model/_base.py
predict
abstractmethod
¶
Predict target values for input samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input feature matrix of shape (n_samples, n_features). |
required |
**kwargs
|
Any
|
Additional keyword arguments for prediction. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Predicted values of shape (n_samples,). |
Source code in glassbox/models/linear_model/_base.py
LearningSchedule
¶
Bases: Enum
Learning rate scheduling strategies for linear models.
Attributes:
| Name | Type | Description |
|---|---|---|
CONSTANT |
LearningSchedule
|
Keep the learning rate fixed across epochs. |
TIME_DECAY |
LearningSchedule
|
Decrease the learning rate proportionally with epoch growth. |
EXPONENTIAL |
LearningSchedule
|
Decrease the learning rate exponentially over epochs. |
LinearRegression
¶
Bases: BaseLinearModel
Linear regression model.
Source code in glassbox/models/linear_model/_base.py
fit
¶
Fit the linear regression model to training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Training feature matrix of shape (n_samples, n_features). |
required |
y
|
ndarray
|
Training target vector of shape (n_samples,). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The fitted model instance. |
Source code in glassbox/models/linear_model/linear.py
predict
¶
Predict continuous target values for input samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input feature matrix of shape (n_samples, n_features). |
required |
**kwargs
|
Any
|
Additional keyword arguments for prediction. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Predicted values of shape (n_samples,). |
Source code in glassbox/models/linear_model/linear.py
LogisticRegression
¶
Bases: BaseLinearModel
Logistic regression model for binary classification.
Source code in glassbox/models/linear_model/_base.py
fit
¶
Fit the logistic regression model to training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Training feature matrix of shape (n_samples, n_features). |
required |
y
|
ndarray
|
Training target vector of shape (n_samples,). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The fitted model instance. |
Source code in glassbox/models/linear_model/logistic.py
predict
¶
Predict class labels for input samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input feature matrix of shape (n_samples, n_features). |
required |
**kwargs
|
Any
|
Additional keyword arguments for prediction. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Predicted class labels of shape (n_samples,). |
Source code in glassbox/models/linear_model/logistic.py
predict_proba
¶
Predict class probabilities for input samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input feature matrix of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Predicted probabilities of shape (n_samples,). |