Skip to content

tf-idf example prints the right score but the wrong document #2

@KatMaff

Description

@KatMaff

When I added more examples to the documents array in the tf-idf example, the wrong document was shown as the most similar. For me, with scikit-learn version 0.24.1, the cosine similarities don't include the input document, so the index 'i' is actually one less than the corresponding document in the documents array. Therefore the most similar document turns out to be documents[highest_score_index + 1].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions