Lesson 2 official topic

Try changing the definition of corr to this:

def corr(x,y): return np.corrcoef(x.squeeze(),y)[0][1]

Then it should run.

I found this by running Python’s interactive debugger with %debug, and type up until I got to the code in this notebook. Then looking at the inputs I noticed x has shape (9919,1) whereas y is just (9919,).

We need a way to drop the extra dimension, and np.squeeze is nice because if x is already 1 dimensional it won’t change the value.

I have no idea why the shape of the model’s predictions (the x here) differs between models.

2 Likes