machine_learning.ordinary_least_squares_regression ================================================== .. py:module:: machine_learning.ordinary_least_squares_regression .. autoapi-nested-parse:: Ordinary Least Squares Regression (OLSR): Ordinary Least Squares Regression (OLSR) is a statistical method for estimating the parameters of a linear regression model. It is the most commonly used regression method, and it is based on the principle of minimizing the sum of the squared residuals. Below is a simple implementation of OLSR without using any external libraries. WIKI: https://en.wikipedia.org/wiki/Ordinary_least_squares Attributes ---------- .. autoapisummary:: machine_learning.ordinary_least_squares_regression.x_points Functions --------- .. autoapisummary:: machine_learning.ordinary_least_squares_regression.ols_regression Module Contents --------------- .. py:function:: ols_regression(x_point: numpy.ndarray, y_point: numpy.ndarray) -> tuple Performs Ordinary Least Squares Regression (OLSR) on the given data. Args: x: The independent variable. y: The dependent variable. Returns: a (float): The intercept of the regression line. b (float): The slope of the regression line. Examples: >>> x = np.array([1, 2, 3, 4, 5]) >>> y = np.array([2, 4, 6, 8, 10]) >>> a, b = ols_regression(x, y) >>> float(a) # Intercept should be 0.0 0.0 >>> float(round(b, 2)) # Slope should be 2.0 2.0 .. py:data:: x_points