nextwe will load the diabetes dataset and create its objectdiabetes datasets load_diabetes(as we are implementing slrwe will be using only one feature as followsx diabetes data[:np newaxis nextwe need to split the data into training and testing sets as followsx_train [:- x_test [- :nextwe need to split the target into training and testing sets as followsy_train diabetes target[:- y_test diabetes target[- :nowto train the model we need to create linear regression object as followsregr linear_model linearregression(nexttrain the model using the training sets as followsregr fit(x_trainy_trainnextmake predictions using the testing set as followsy_pred regr predict(x_testnextwe will be printing some coefficient like msevariance score etc as followsprint('coefficients\ 'regr coef_print("mean squared error fmean_squared_error(y_testy_pred)print('variance score fr _score(y_testy_pred)nowplot the outputs as followsplt scatter(x_testy_testcolor='blue'plt plot(x_testy_predcolor='red'linewidth= plt xticks(()plt yticks(()plt show(