← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Implement TF-IDF (Term Frequency-Inverse Document Frequency) from scratch in a programming language of your choice. TF-IDF is a numerical statistic intended to reflect how important a word is to a document in a collection or corpus.
Input:
documents = [ ["apple", "banana", "apple"], ["banana", "orange", "apple", "banana", "banana"] ]
Output:
[ [0.81, 0.40, 0.40], # Document 1: TF-IDF for "apple", "banana", "orange" [0.20, 0.60, 0.20] # Document 2: TF-IDF for "apple", "banana", "orange" ]
The problem statement is complete and can be directly used for interview preparation. The constraints, examples, and hints are provided to guide the implementation of the TF-IDF from scratch.