All problems
Day-of-Week Embedding
Problem
Build a one-hot day-of-week embedding of length embedding_dim with a 1 at index day_index % embedding_dim.
Return an empty list for non-positive embedding_dim. This is how a model learns a separate effect per weekday.
Hint
Negative indices wrap via the modulo operator.
Test cases
case 1
in: [0,4]
expected: [1,0,0,0]
case 2
in: [3,4]
expected: [0,0,0,1]
case 3
in: [9,4]
expected: [0,1,0,0]
case 4
in: [-1,4]
expected: [0,0,0,1]
Starter codePython
def day_of_week_embedding(day_index, embedding_dim):
# Your code here
pass4 test cases · run your code against them in the editor