Apache Spark Deep Learning Cookbook
by Ahmed Sherif, Amrith Ravindra, Michal Malohlava, Adnan Masood
There's more...
While ytrain_array and ytest_array are both labels in a matrix format, they are not ideally encoded for deep learning. Since this is technically a classification model that we are building we need to encode our labels in a manner for them to be understood by the model. This means that our ratings of 0 through 5 should be encoded as 0 or 1 values, based on their value elements. Therefore, if a rating received the highest value of 5, it should be encoded as [0,0,0,0,0,1]. The first position is reserved for 0, and the sixth position is reserved for 1, indicating a value of 5. We can make this conversion using keras.utils and convert our categorical variables to one-hot encoded variables. In doing this, the shape of our training ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access