AHMEDSANA / Linear-Regression

Linear Regression using Matlab on a Kaggle dataset.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linear Regression

We will use Matlab for linear regression on a Kaggle dataset

LinearRegression:

Regression models describe the relationship between variables by fitting a line to the observed data. Simple linear regression is used to estimate the relationship between two quantitative variables. The formula for a simple linear regression is:

  • y is the predicted value of the dependent variable (y) for any given value of the independent variable (x).
  • B0 is the intercept, the predicted value of when the x is zero.
  • B1 is the regression coefficient–how much we expect y to change as x increases.
  • X is the independent variable (the variable we expect is influencing y).

Cost Function:

The cost is the error in our predicted value. We will use the Mean Squared Error function to calculate the cost.

GradientDescentAlgorithm:

Gradient Descent is an algorithm that finds the best-fit line for a given training dataset in a smaller number of iterations.

Linear regression implementation Dataset:

I used a dataset from Kaggle for the prediction of diabetes based on different conditions. The dataset is provided in the repo as well.

Code

  • Download the Matlab files
  • Change the location of the dataset to the location on your machine in the code.
  • Run all the function files and then run the Main file after running the main file run the prediction file.
  • Change the values in the prediction portion of the code to the values you want to predict

Output

Prediction