Documentation

class example_repo.linreg.LinearRegression[source]

Linear Regression.

Uses matrix multiplication to fit a linear model that minimizes the mean square error of a linear equation system.

Examples

>>> import numpy as np
>>> from example_repo import LinearRegression
>>> rng = np.random.RandomState(0)
>>> n = 100
>>> x = rng.uniform(-5, 5, n)
>>> y = 2*x + 1 + rng.normal(0, 1, n)
>>> linreg = LinearRegression().fit(x, y)
>>> linreg.predict(range(5)).T
array([[1.19061859, 3.18431209, 5.17800559, 7.17169909, 9.1653926 ]])

Methods

LinearRegression.fit(x, y)

Fit linear model.

LinearRegression.predict(x)

Predicts using the linear model.