Which of these are examples of a value in a sparse vector? (Select 2 answers.)

Which of these are examples of a value in a sparse vector? (Select 2 answers.)
A . [0, 5, 0, 0, 0, 0]
B . [0, 0, 0, 1, 0, 0, 1]
C . [0, 1]
D . [1, 0, 0, 0, 0, 0, 0]

Answer: C,D

Explanation:

Categorical features in linear models are typically translated into a sparse vector in which each possible value has a corresponding index or id. For example, if there are only three possible eye colors you can represent ‘eye_color’ as a length 3 vector: ‘brown’ would become [1, 0, 0], ‘blue’ would become [0, 1, 0] and ‘green’ would become [0, 0, 1]. These vectors are called "sparse" because they may be very long, with many zeros, when the set of possible values is very large (such as all English words).

[0, 0, 0, 1, 0, 0, 1] is not a sparse vector because it has two 1s in it. A sparse vector contains only a single 1.

[0, 5, 0, 0, 0, 0] is not a sparse vector because it has a 5 in it. Sparse vectors only contain 0s and 1s.

Reference: https://www.tensorflow.org/tutorials/linear#feature_columns_and_transformations

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments