educative.io

Educative

User Location as a feature

How is user location encoded as a feature? I imagine it is a sparse one-hot encoded vector, but the author seems to suggest that it is a dense feature.

Hi @Priyanka_Vageeswaran,

To represent the user’s location as a sparse one-hot encoded vector, you need to take into account all locations, which will significantly increase the size of the vector. Also, it will not be scalable i.e. what if we get a new location in our system? How are you going to incorporate it using the sparse vectors?
Therefore, we should use a dense vector for the user’s location representation.

Thanks for the response. I suppose my question was - how do you encode location as a sparse vector?

To encode location as a sparse vector, you need to know/take into account all locations beforehand. Then, you can design the sparse vector by encoding every index of the vector as one location.