File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 48
48
# Train the model using the training sets
49
49
regr .fit (diabetes_X_train , diabetes_y_train )
50
50
51
+ # Make predictions using the testing set
52
+ diabetes_y_pred = regr .predict (diabetes_X_test )
53
+
51
54
# The coefficients
52
55
print ('Coefficients: \n ' , regr .coef_ )
53
56
# The mean squared error
54
57
print ("Mean squared error: %.2f"
55
- % np .mean ((regr . predict ( diabetes_X_test ) - diabetes_y_test ) ** 2 ))
58
+ % np .mean ((diabetes_y_pred - diabetes_y_test ) ** 2 ))
56
59
# Explained variance score: 1 is perfect prediction
57
60
print ('Variance score: %.2f' % regr .score (diabetes_X_test , diabetes_y_test ))
58
61
59
62
# Plot outputs
60
63
plt .scatter (diabetes_X_test , diabetes_y_test , color = 'black' )
61
- plt .plot (diabetes_X_test , regr .predict (diabetes_X_test ), color = 'blue' ,
62
- linewidth = 3 )
64
+ plt .plot (diabetes_X_test , diabetes_y_pred , color = 'blue' , linewidth = 3 )
63
65
64
66
plt .xticks (())
65
67
plt .yticks (())
You can’t perform that action at this time.
0 commit comments