i

R Programming Complete Tutorial

Simple Linear Regression

Machine Learning with R

Machine learning provides systems the ability to learn and improve from experience without being explicitly programmed automatically. Machine learning focuses on the development of computer programs that can access data and use it to learn for themselves. R has a powerful package set to work with different Machine learning algorithms. 

Simple Linear Regression

Linear Regression is a supervised machine learning algorithm.It is mostly used for finding out the relationship between variables and forecasting (prediction). Regression models are only used to predict a continuous value, so it is not possible to use it for classification problems. Regression analysis for one predictor is known as Simple Linear Regression, and for multiple predictors, it is Multiple Linear Regression.

In Simple Linear Regression, we have only one predictor (feature) and one target variable. And we use the statistical equation, Y=b0+b1X, where b0 (intercept) and b1 (slope) are model coefficients. X is our predictor, and Y is our target variable.

Example:

  • We have a data set of a group of people with their weight and height.

  • These blue points are our data points, and the line is our regression line.

  • From this Regression line, we can easily predict our target variable. Suppose for the height of 150 cm; the predicted weight will be around 62 Kg.

Application of Linear Regression

Linear Regression is a machine learning technique that is used everywhere, from scientific research to Retail market analysis. There are hundreds of examples, and I choose only a few from them.

  • Predicting prices of an apartment given the features of an apartment like size, location, number of rooms.

  • Studying engine performance from test data in automobiles.

  • Least squares regression is used to model causal relationships between parameters in biological systems.

  • Can be used in weather data prediction.

  • Can be used in market research studies to analyze the marketing effectiveness, pricing, and promotions on sales of a product.

  • If a company's sales have increased steadily every month for the past few years, by conducting a linear analysis of the sales data with monthly sales, the company could forecast sales in the coming months.

  • If a company wants to know if the funds that they have invested in marketing a particular brand has given them a substantial return on investment, they can use linear Regression.