Previous question · 198
Mean Reciprocal Rank
easyML Coding
Next question · 200
Neural Network Classifier
hardML Coding
Random coding question

199. Bag of words vectorization

easy
GeneralGeneral
senior
Function contract
Inputs
texts
np.ndarray
vocabulary
np.ndarray
Returns
value
np.ndarray

Examples

Input
{
  "texts": [
    "I like cats",
    "I like like dogs"
  ],
  "vocabulary": [
    "i",
    "like",
    "cats",
    "dogs"
  ]
}
Output
[
  [
    1,
    1,
    1,
    0
  ],
  [
    1,
    2,
    0,
    1
  ]
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
senior
entry
Tags
bag-of-words
tokenization
hashmap-counting
nlp-preprocessing

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
35 people are solving this problem
Loading editor for the selected language
Ln 1, Col 1
Program Output
DATAINTERVIEW
Interactive coding terminal
Python / NumPy environment ready.
Type a command below or run code from the editor.
run scriptExecute the current editor contents
submitGrade the current editor contents against all solution test cases
python ("print hello world")Run an isolated Python command
helpShow all available commands