July 2019
Beginner to intermediate
740 pages
16h 52m
English
Now that we have an idea of the effect each of our regressors has, let's use our model to make predictions of year length for the planets in the test set:
>>> preds = lm.predict(X_test)
Let's visualize how well we did by plotting the actual and predicted values:
>>> fig, axes = plt.subplots(1, 1, figsize=(5, 3))>>> axes.plot(... X_test.semimajoraxis, y_test, 'bo', label='actuals', ... alpha=0.5... )>>> axes.plot(... X_test.semimajoraxis, preds, 'ro', label='predictions', ... alpha=0.5... )>>> plt.xlabel('semimajoraxis')>>> plt.ylabel('period')>>> plt.legend()>>> plt.suptitle('Linear Regression')
The predicted values seem pretty close to the actual values and follow a similar pattern:
We can check their correlation to see ...
Read now
Unlock full access