Skip to content

Instantly share code, notes, and snippets.

@gandroz
Created May 24, 2020 01:24
Show Gist options
  • Save gandroz/1c385ed21a252ec5f478d7837117854e to your computer and use it in GitHub Desktop.
Save gandroz/1c385ed21a252ec5f478d7837117854e to your computer and use it in GitHub Desktop.
Fit new value
new_x = 15
data_x = np.array([new_x**i for i in range(0,13)])
new_y = 4*new_x+1+np.random.normal(0, 5, 1)
idx = 0
for degree in [1, 2, 4, 6, 8, 10]:
y_pred = models[idx].predict(data_x[0:degree+1].reshape(1,-1))
rss = (y_pred-new_y)**2
idx += 1
print "The residual error for X={} is {}".format(new_x, rss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment