Skip to main content

Neighbors

Build Status Coverage Status Python Versions Platforms

A Python package for collaborative filtering on social datasets

Installation

  1. Pip (official releases): pip install neighbors
  2. Github (bleeding edge): pip install git+https://github.com/cosanlab/neighbors.git

Getting started

The best way to learn how to use the package is by checking out the documentation site which contains usage tutorials as well as API documentation for all package functionality.

Quick Demo Usage

from neighbors.models import NNMF_sgd
from neighbors.utils import create_user_item_matrix, estimate_performance

# Assuming data is 3 column pandas df with 'User', 'Item', 'Rating'
# convert it to a (possibly sparse) user x item matrix
mat = create_user_item_matrix(df)

# Initialize a model
model = NNMF_sgd(mat)

# Fit
model.fit()

# If data are time-series optionally fit model using dilation
# to leverage auto-correlation and improve performance
model.fit(dilate_by_nsamples=60)

# Visualize results
model.plot_predictions()

# Estimate algorithm performance using
# Repeated refitting with random masking (dense data)
# Or cross-validation (sparse data)
group_results, user_results = estimate_performance(NNMF_sgd, mat)

Algorithms

Currently supported algorithms include:

  • Mean - a baseline model
  • KNN - k-nearest neighbors
  • NNMF_mult - non-negative matrix factorization trained via multiplicative updating
  • NNMF_sgd - non-negative matrix factorization trained via stochastic gradient descent

By default both NNMF models clip their predictions to the range of the observed ratings, since matrix factorization (and especially the unconstrained bias terms in NNMF_sgd) can otherwise produce predictions outside that range (e.g. negative values despite all-positive ratings). This is the same approach the Surprise package takes when making predictions, and can be disabled with .fit(clip_predictions=False).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neighbors-0.2.0.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neighbors-0.2.0-py3-none-any.whl (896.3 kB view details)

Uploaded Python 3

File details

Details for the file neighbors-0.2.0.tar.gz.

File metadata

  • Download URL: neighbors-0.2.0.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for neighbors-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c3fd11efc2b9a2a4b98d55d50d8ba881595d51c2026af13d6a6dd3b5f53ed0e4
MD5 6d5501b215117567609cfcc955247644
BLAKE2b-256 35e4da88baffb45deb1458fe6c2ee849cab53fa5b72fa7dbb542d0ad71def2f2

See more details on using hashes here.

File details

Details for the file neighbors-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: neighbors-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 896.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for neighbors-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b4d861dd71a843b43dbbd0302ec65c855c66b8f3c1036980e9fa03ca0dde229
MD5 777c12ffb71fe550d3011809b39f19a1
BLAKE2b-256 3a47fb223f26dc5f51b99d3872903d78db83f1f53344962c7dd4a7ba5e9e4ddf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page