Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tfidf.md #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/api_docs/python/tft/tfidf.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ The term frequency of a term in a document is calculated as

The inverse document frequency of a term is, by default, calculated as
1 + log((corpus size + 1) / (count of documents containing term + 1)).

```
Example usage:
example strings [["I", "like", "pie", "pie", "pie"], ["yum", "yum", "pie]]

in: SparseTensor(indices=[[0, 0], [0, 1], [0, 2], [0, 3], [0, 4],
[1, 0], [1, 1], [1, 2]],
values=[1, 2, 0, 0, 0, 3, 3, 0])

out: SparseTensor(indices=[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1]],
values=[1, 2, 0, 3, 0])
SparseTensor(indices=[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1]],
values=[(1/5)*(log(3/2)+1), (1/5)*(log(3/2)+1), (3/5),
(2/3)*(log(3/2)+1), (1/3)]
NOTE that the first doc's duplicate "pie" strings have been combined to
one output, as have the second doc's duplicate "yum" strings.

```
#### Args:

* <b>`x`</b>: A `SparseTensor` representing int64 values (most likely that are the
Expand All @@ -54,4 +56,4 @@ Example usage:

Two `SparseTensor`s with indices [index_in_batch, index_in_bag_of_words].
The first has values vocab_index, which is taken from input `x`.
The second has values tfidf_weight.
The second has values tfidf_weight.