Implementation:Scikit learn Scikit learn LinearModelModule
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Linear Models |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for aggregating all linear model estimators under a single namespace, provided by scikit-learn.
Description
The sklearn.linear_model module is the central namespace that re-exports all linear model implementations in scikit-learn. It includes ordinary linear regression, regularized regression (Ridge, Lasso, ElasticNet), Bayesian regression (ARDRegression, BayesianRidge), generalized linear models (Poisson, Gamma, Tweedie regressors), logistic regression, stochastic gradient descent classifiers and regressors, perceptron, passive aggressive models, RANSAC, Huber regression, and more.
Usage
Use this module to access any linear model estimator in scikit-learn. It serves as the primary entry point for linear classification and regression algorithms.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/linear_model/__init__.py
Signature
# Module-level imports (selected):
from sklearn.linear_model._base import LinearRegression
from sklearn.linear_model._ridge import Ridge, RidgeCV, RidgeClassifier, RidgeClassifierCV
from sklearn.linear_model._coordinate_descent import Lasso, LassoCV, ElasticNet, ElasticNetCV
from sklearn.linear_model._logistic import LogisticRegression, LogisticRegressionCV
from sklearn.linear_model._stochastic_gradient import SGDClassifier, SGDRegressor
from sklearn.linear_model._perceptron import Perceptron
Import
from sklearn.linear_model import LinearRegression, Ridge, Lasso, LogisticRegression
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (varies) | N/A | N/A | Each estimator has its own parameters; see individual class documentation |
Outputs
| Name | Type | Description |
|---|---|---|
| estimators | classes | Linear model estimator classes for classification and regression |
Usage Examples
Basic Usage
from sklearn.linear_model import LinearRegression, LogisticRegression
from sklearn.datasets import make_regression, make_classification
# Regression
X, y = make_regression(n_samples=100, n_features=2, random_state=0)
reg = LinearRegression().fit(X, y)
print(reg.coef_)
# Classification
X, y = make_classification(n_samples=100, random_state=0)
clf = LogisticRegression().fit(X, y)
print(clf.score(X, y))