The linear model is fitted using the Ordinary Least Squares method. This method minimizes the sum of squared residuals, which are the differences between the observed and predicted values. The coefficients are calculated using the formula:
β = (X^T * X)^(-1) * X^T * y
where β is the vector of coefficients, X is the matrix of input features, and y is the vector of target values. The intercept c is calculated as:
c = ȳ - β * x̄
where ȳ is the mean of the target values and x̄ is the mean of the input features.
Building a linear regression model involves understanding these concepts and applying them to your data. With this foundation, you can effectively use linear regression for predictive modeling and data analysis.
It is a supervised machine learning and statistical technique used to model the relationship between a dependent variable(output) and one or more independent variables(inputs) by fitting a linear equation to observed data.
When to use Linear Regression?
- To predict numerical value such as House price prediction
- Understanding relationships between variables
- For analysing trends over time.
- Used as a baseline model in ML