Posts

Showing posts with the label linear regression

Regression 6. Finding Unknown Parameters with OLS - Solved Manual Example

Image
You can learn how to perform linear regression by watching my YouTube video. Numeric Example A hypothetical dataset about how online gaming habits affects marks involving children in the age group of 10-15 is tabulated. The first feature is the number of hours in a day spent in gaming. The second feature gives the average marks of the students who spend so many hours in gaming. Problem Statement Find the regression coefficients m and c in the linear regression model using Least Squares Approach: y = c+ m*x Step 1: We need to check if there is linearity between the dependent and independent variables by plotting the scatter plot. We see that there is a linear relationship between the data and so we can apply linear regression. From the blog on OLS, we know to calculate c and m as : This can be easily calculated by hand with a table as follows: So, the regression equation representing the relationship between 'Hours Spent' and 'Marks (%)' is: Marks = 89.0 − 5.5 × Hours Sp...

Regression 5. Least Squares Approach for Linear Regression - Derivation

Ordinary Least Squares (OLS) is a fundamental method in statistical modeling, particularly for linear regression. The goal of OLS is to find the best-fitting line through a set of data points that minimizes the sum of the squared differences (residuals) between the observed values and the values predicted by the model. Mathematical Formulation of OLS with and without Covariance Matrix

Regression 4. Linear Regression - Model Fitting Techniques

Image
 M odel Fitting Technique The term "model fitting technique" in the context of statistics and machine learning refers to the methods and algorithms used to construct a mathematical model that best describes the relationship between variables in a given dataset. Specifically, in the context of linear regression, it involves finding the coefficients (parameters) that minimize the difference between the observed data and the model's predictions .   Model Fitting in Linear Regression For linear regression, the process of model fitting typically involves estimating the parameters (coefficients) of the linear equation that best fits the observed data. The equation for a simple linear regression model is:   Techniques for Model Fitting 1. Ordinary Least Squares (OLS):    - The most common technique for fitting a linear regression model.    - It works by minimizing the sum of the squares of the residuals (the differences between the observed values a...

Regression 3. Linear Regression - Assumptions(With Python Code)

Image
 Linear regression, a foundational statistical method, relies on several key assumptions. Understanding these assumptions is crucial for interpreting the results accurately.  Assumptions Let's go through each assumption with examples: 1. Linearity:     Assumption: The relationship between the independent variables and the dependent variable is linear.     Example: Let's say you're studying the relationship between temperature and ice cream sales. If a linear regression model is appropriate, an increase in temperature should consistently lead to an increase in ice cream sales at a constant rate. 2. Independence:     Assumption: The residuals (or errors) are independent. The assumption states that the residuals (the differences between observed and predicted values) should be independent of each other. This means that the value of one error should not predict the value of another error. In other words, there should be no correlation between the resi...

Regression 2. Linear Regression - An Overview

Image
 Linear regression is a statistical method used to model the relationship between a dependent variable and one or more independent variables .  Goal The goal is to find a linear equation that best predicts the dependent variable from the independent variables .  Types of Linear Regression There are two main types of linear regression: 1. Simple Linear Regression:  This involves two variables - one independent variable (predictor) and one dependent variable (response). The relationship between these variables is modeled with a straight line (linear). The equation for simple linear regression is: 2. Multiple Linear Regression:  This extends simple linear regression by using more than one independent variable to predict the dependent variable. The equation is: Key Concepts in Linear Regression: Fit of the Model:  The process of "fitting" a linear regression model involves estimating the coefficients w_i based on the available data. This is typically done us...

Regression1. Regression Overview with Python Code

Image
A detailed explanation for Regression can be viewed in the following YouTube video. Regression vs Classification A regression task in the context of machine learning and statistics is a type of problem where the goal is to predict a continuous outcome variable based on one or more predictor variables . It's different from classification tasks, where the goal is to predict a discrete label . Regression is used to understand relationships between variables and for predicting trends or future values. The output to a regression problem is a vector of real numbers.  Understanding Regression 1. Continuous Outcome Variable:  This is a variable that can take any value within a range. It can take decimal values and not just integer values. They are the dependent variables. Example For instance, predicting temperatures, prices, or distances. The distance is a real number say 32km. Even though it looks like an integer, it may actually be a real number say 32.0000004 subsuming km and som...