Git Product home page Git Product logo

spear's Introduction

SPEAR

The reference implementation of the SPEAR ranking algorithm in Python.

Features

The purpose of this implementation is to make the inner workings of the SPEAR algorithm easy to understand and not to distract or confuse the reader with highly optimized code.

The SPEAR algorithm takes a list of user activities on resources as input, and returns ranked lists of users by expertise scores and resources by quality scores, respectively.

Using SPEAR to simulate the HITS algorithm

You can also use this library to simulate the HITS algorithm of Jon Kleinberg. Simply supply a credit score function C(x) = 1 to the SPEAR algorithm (see documentation of Spear.run()).

Installation

You can now download and install SPEAR from Python Package Index (aka Python Cheese Shop) via setuptools/easy_install. Just run

$ easy_install Spear

After installation, a simple import deliciousapi in your Python scripts will do the trick.

An alternative installation method is downloading the code straight from the git repository.

The SPEAR Python library requires SciPy/NumPy. If you don’t have these installed already, here are some installation instructures to get you started.

Updates

If you used setuptools/easy_install for installation, you can update Spear via

$ easy_install -U Spear

Alternatively, if you downladed the code from the git repository, simply pull the latest changes.

Usage

The algorithm requires a list of user activities on resources as input. More specifically, it requires a list of (timestamp, user, resource) tuples.

>>> import spear
>>> activities = [
... (datetime.datetime(2010,7,1,9,0,0), "alice", "http://www.quuxlabs.com/"),
... (datetime.datetime(2010,8,1,12,45,0), "bob", "http://www.quuxlabs.com/"),
... ]
>>> spear_algorithm = spear.Spear(activities)
>>> expertise_results, quality_results = spear_algorithm.run()

Get the top user and his expertise score:

>>> expertise_score, user = expertise_results[0]
>>> print "%s => %.4f" % (user, expertise_score)
alice => 0.5858

Get the top resource and its quality score:

>>> quality_score, resource = quality_results[0]
>>> print "%s => %.4f" % (resource, quality_score)
http://www.quuxlabs.com/ => 1.0000

More information

You can find more information about the SPEAR algorithm at:

License

The code is licensed to you under version 2 of the GNU General Public License.

Copyright

Copyright 2009-2010 Michael G. Noll http://www.michael-noll.com/, Ching-man Au Yeung http://www.albertauyeung.com/

spear's People

Contributors

camisatx avatar

Watchers

 avatar  avatar

Forkers

flipboard

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.