Linear Regression analysis for Diabetes dataset using Python and Sklearn - Part 1


Hello everyone again in this lecture we want to make another linear regression model based on building data sets in a scaler in this lecture we use and diabetes data sets so to start we need import something from a scalar import everything and from Salem we need import data sets and a linear model after it we need some measurement to measure our accuracy right scalar that metric import mean square error mean squared and our to score and accuracy x-score echo crazy score all right we need some pellets library to visualize our outputs are immaculately that plus the dot pie drugs imports everything and imports match blood that pipe a lot as a PLT finally import numpy as MP import numpy as n p so build your codes to see the input output and possible Aurore we have some arrow here from SK Leonard data set we missed it this s and build it again alright we have no error so we must load our database to this code so defined the abilities equals two data sets that load underline the beauties all right by using this line of code our data generated and we can use it to generate our input and output data so you can use X equal 2 diabetes the fittest dot data and we find we want to use third columns of this data set so right n P dot new axis and you have three for it and build your data your code to see the possible output there or we have a no error here you can see the X by using print X dot shape okay as you can see we have a web tour with 442 rows and one columns then we go to define our output so write y equals two diabetes that target all right then generate our X&Y data we must split them into training test data to test and train our regression model so we must use a terrain test a split function as follows so writes X train why train X test and why just and use cross-validation dot train test escalates and we use X Y and we must define our test size dimension I use 30% for test size so right this common test size equals to 0.3 and it generates 70% of all of data as a train.

Data and 30% of them generated as a test data all right after it we must build our model so right reg equal to linear model the linear regression this code generates a linear regression model for us and put it in red parameter or Ric where you go to train our model we must use feet comment and train our model with extra and why train this comment train our regression model our linear regression model with extreme and why train and create appropriate coefficient for our linear model after it we must see the output of this model for test data so we need to define some prediction variable like wipe read as follows so Y parade akuel to read that predict predict and we use X test for prediction now we can see the coefficients.