Linear regression
Module: linear_regression.py
This module implements the LinearRegressionModel class for regression tasks, extending the base Regression class from the SciREX library.
The implementation uses scikit-learn's LinearRegression model for: - Training the linear regression algorithm - Generating predictions for input features - Evaluating performance using standard regression metrics
Key Features
- Support for fitting a linear regression model
- Access to model parameters (coefficients, intercept)
- Seamless integration with the SciREX regression pipeline
Classes:
Name | Description |
---|---|
LinearRegressionModel |
Implements a Linear Regression model. |
Dependencies
- numpy
- scikit-learn
- scirex.core.ml.supervised.regression.base
Version Info
- 16/Jan/2025: Initial version
LinearRegressionModel
Bases: Regression
Linear Regression model implementation using scikit-learn.
Source code in scirex/core/ml/supervised/regression/linear_regression.py
__init__(random_state=42)
Initialize the LinearRegressionModel class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
random_state
|
int
|
Seed for reproducibility where applicable. Defaults to 42. |
42
|
Source code in scirex/core/ml/supervised/regression/linear_regression.py
fit(X, y)
Fit the linear regression model to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
ndarray
|
The input training features (n_samples, n_features). |
required |
y
|
ndarray
|
The target training values (n_samples). |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/ml/supervised/regression/linear_regression.py
get_model_params()
Get the parameters of the linear regression model.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The parameters of the linear regression model. |
Source code in scirex/core/ml/supervised/regression/linear_regression.py
predict(X)
Predict the target values for the input data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
ndarray
|
The input data (n_samples, n_features). |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The predicted target values. |