Using One Hot Encodings question

Dear friends,

I am not following here. I thought the final output of one hot encoding is a matrix not a row. In other words, you give the the row input like [0 1 2 3 0 2 1], and you wish to have a matrix output.
my code is --- give a row here, but passes all tests… but again, it gives me error in the

new_y_test = y_test.map(one_hot_matrix)
new_y_train = y_train.map(one_hot_matrix)

So, I think something is not right here even the tests are all passed.

update: it seems like the problem is resolved after I changed to “—”. So I need to use shape=(depth,) instead of “depth”. Even the shape=(depth,) is wrong.
I am kinda confused…

It seems like you’ve got the answer.
Here are 2 link to see:

  1. one_hot
  2. reshape

When in doubt about method signature, use named arguments when invoking the method.

Don’t forget to remove code from your posts.

1 Like