Skip to content

Instantly share code, notes, and snippets.

@finlytics-hub
Last active October 24, 2020 05:56
Show Gist options
  • Save finlytics-hub/61aa4c9e867802dd1b5cfc52c9822a06 to your computer and use it in GitHub Desktop.
Save finlytics-hub/61aa4c9e867802dd1b5cfc52c9822a06 to your computer and use it in GitHub Desktop.
Linear Regression - Normal Equation - Prediction
# make predictions on new data - deliberately chosen the minimum and maximum possible X values to plot a straight line
X_new = np.array([[0], [5]])
# add ones
X_new_2d = np.c_[np.ones((2, 1)), X_new]
# predict
y_predict = X_new_2d.dot(theta_best)
y_predict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment