From 59c8e896206be9e798a653a99c8ffc93176acc92 Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Wed, 14 Oct 2020 20:32:26 +0200 Subject: [PATCH] fix: Ensure `X_test` does not get overwritten * Previously due to a overfit/underfit/goodfit sample, which also used the variable `X_test`, the students/users were in for a nasty surprise when they tried to work with `X_test` -- it had completely different dimensions. * This commit ensures that the variable does not get shadowed inside that particular `for` loop. Signed-off-by: mr.Shu --- assignment2/regression.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assignment2/regression.ipynb b/assignment2/regression.ipynb index c4eaff1..ebc6bd6 100644 --- a/assignment2/regression.ipynb +++ b/assignment2/regression.ipynb @@ -625,10 +625,10 @@ " (\"linear_regression\", linear_regression)])\n", " pipeline.fit(X[:, np.newaxis], y)\n", "\n", - " X_test = np.linspace(0, 1, 100)\n", - " plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]),\n", + " X_test_i = np.linspace(0, 1, 100)\n", + " plt.plot(X_test_i, pipeline.predict(X_test_i[:, np.newaxis]),\n", " label=\"Model\")\n", - " plt.plot(X_test, true_fun(X_test), label=\"True function\")\n", + " plt.plot(X_test_i, true_fun(X_test_i), label=\"True function\")\n", " plt.scatter(X, y, edgecolor='b', s=20, label=\"Samples\")\n", " plt.xlabel(\"x\")\n", " plt.ylabel(\"y\")\n", @@ -806,4 +806,4 @@ ] } ] -} \ No newline at end of file +}