This Y is not 1D?

Hi guys, mentors,

I am in the Exercise 2 - sample from “dinosaurs island”
If I use the code, idx = np.random.choice(range(len(y)), p = y), my local machine gives me an error, and says not 1D. However,my y is already 1d as (27,1). So why this is not working?
I saw the hint says, I need to do y.ravel(), so, my original y as (27,1) is not true ID after all?

A vector with dimensions (27,1) is a 2D vector, right? It’s got two dimensions: one of them is 27 and the other is 1. A 1D vector with 27 elements would have shape (27,). The numpy squeeze function is relevant here. :nerd_face:

1 Like

It was a silly question. but now i got it. (27,1) is 2d, (27,) means 1d. thank you.