A C implementation of the Network-Based Inference (NBI) algorithm for personalized recommendations using bipartite network projection.
Based on the paper:
Tao Zhou, Jie Ren, Matúš Medo, Yi-Cheng Zhang, "Bipartite network projection and personal recommendation", Phys. Rev. E 76, 046115 (2007).
The NBI algorithm performs personalized recommendations through a two-step resource diffusion process on a user-item bipartite network:
- Resource Allocation: Assign initial resource (f=1) to items selected by the target user
- Items → Users Diffusion:
f(user) = Σ f(item) / k(item) - Users → Items Diffusion:
f'(item) = Σ f(user) / k(user) - Ranking: Sort items by final score, excluding already selected items
# Compile
gcc nbi.c -o nbi
# Run with N recommendations per user
./nbi <N>
# Example: generate top-10 recommendations
./nbi 10Input files use tab-separated format:
UserID ItemID Timestamp
| File | Description |
|---|---|
training.txt |
Training data for building the network |
check.txt |
Test data for evaluation |
result.txt |
Output recommendations (generated) |
The included dataset is from MovieLens, randomly split into training and test sets.
Recommendations: 10, Hits: 11044, Precision: 0.1829
- Recommendations: Number of items recommended per user
- Hits: Total correct predictions in test set
- Precision: Hit rate = Hits / (N × Users)