sklearn.linear model

(Redirected from sklearn.linear model module)
Jump to: navigation, search

A sklearn.linear_model is a collection of generalized linear model fitting systems within scikit-learn.




    • QUOTE: The following are a set of methods intended for regression in which the target value is expected to be a linear combination of the input variables. In mathematical notion, if \hat{y} is the predicted value: [math]\hat{y}(w, x) = w_0 + w_1 x_1 + ... + w_p x_p[/math] Across the module, we designate the vector w = (w_1, ..., w_p) as coef_ and w_0 as intercept_.

      To perform classification with generalized linear models, see Logistic regression.


import sklearn.datasets
from sklearn.model_selection import cross_val_predict
import sklearn.linear_model
import matplotlib.pyplot as plt

lr = linear_model.LinearRegression() boston = datasets.load_boston() y =
# cross_val_predict returns an array of the same size as `y` where each entry # is a prediction obtained by cross validation: predicted = cross_val_predict(lr,, y, cv=10)
fig, ax = plt.subplots() ax.scatter(y, predicted, edgecolors=(0, 0, 0)) ax.plot([y.min(), y.max()], [y.min(), y.max()], 'k--', lw=4) ax.set_xlabel('Measured') ax.set_ylabel('Predicted')