GithubHelp home page GithubHelp logo

ccweikui / cosinesim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yebrahim/cosinesim

0.0 2.0 0.0 164 KB

Compute cosine similarities between users based on given collection of documents

Python 100.00%

cosinesim's Introduction

consinesim - a Cosine Similarity computation script for a collection of documents
created by Yasser Ebrahim, 29OCT12
----

This script takes a collection of documents that represent TF-IDF tokens from news articles (other measures can work too, provided they comply with the parsing format of this script). It also takes an additional file that describes votes for a number of users that we need to compute the cosine similarity between. It then computes the similarity in one of three modes:
    - User to user. In this case two user IDs are specified to the program. It outputs only one number representing similarity between the two users
    - User to all. Only one user is specified, and the similarities are calculated between this user and all other users. Output file will contain a one-dimensional table that describes similarities with other users.
    - All to all. No users are specified, and in this case the output file will contain also a one-dimensional table that has one entry per pair of users, and the corresponding similarity.

Please respect the following format, or modify the code yourself to fit your instances:
    - The user_vector.txt file:
        u1: item1, item2
        u2: item1
        u3: item2, item3
        ...
        ...

    - The documents containing the TF-IDF pairs look like:
        term1   tf-idf-score
        term2   tf-idf-score
        ...
        ...
The supplied example files demonstrats the rules above

Usage:
    python cosinesim [options] user_vectors.txt document_dir

Type -h to get a better explanation of the different directivs.

Please direct any comments, corrections, or questions to me at yasser [dot] ebrahim [at] gmail [dot] com.

cosinesim's People

Watchers

James Cloos avatar weikui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.