Neighbors
A Python package for collaborative filtering on social datasets
Installation
- Pip (official releases):
pip install neighbors - 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 modelKNN- k-nearest neighborsNNMF_mult- non-negative matrix factorization trained via multiplicative updatingNNMF_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). If the observed ratings don't span the full rating scale (e.g. no one used the top of a 1-5 scale), pass the scale explicitly with .fit(clip_range=(1, 5)).
Metadata
Release files for neighbors 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neighbors-0.2.1.tar.gz | 1.6 MB | Without provenance | Details for neighbors-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neighbors-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for neighbors-0.2.1-py3-none-any.whl |
Total release size: 2.5 MB
Release files / neighbors-0.2.1.tar.gz
| Download URL | neighbors-0.2.1.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
273aa171bc867ba75672ce4284fea237b8ccebfb69325e3fe4197eeaba087314
|
|
BLAKE2b-256 checksum How to use checksums |
afb0652d7967cb85290ee5cd7ed6a273e9a2700f1d8c097d6b8205a75abb32ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / neighbors-0.2.1-py3-none-any.whl
| Download URL | neighbors-0.2.1-py3-none-any.whl |
|---|---|
| Size | 898.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
061be09504ab3e841a116d218bbfca7c459fa5b740423fb0bfb86c45c81fd542
|
|
BLAKE2b-256 checksum How to use checksums |
abd11af5805d4c09244ad4fb52a3d7e590edd7dbb7341be9327153282445fc3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for neighbors 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.