RecBole

1.2.1 · active · verified Fri Apr 17

RecBole is a unified, comprehensive, and efficient Python library for recommendation systems, built on PyTorch. It provides a wide array of state-of-the-art recommendation models and datasets, featuring standardized data processing, training, and evaluation pipelines. The library undergoes active development, with major updates and new versions typically released every few months, incorporating user feedback and architectural improvements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to run a basic BPR recommendation model on the `ml-100k` dataset using `run_recbole`. RecBole will automatically download and preprocess the dataset if not found. The configuration dictionary allows for inline specification of model, dataset, and evaluation parameters without needing a separate YAML file.

import os
import torch
from recbole.quick_start import run_recbole

# Ensure you have a 'dataset' folder in the current directory
# and 'ml-100k' dataset downloaded/prepared, or RecBole will download it.

# Basic configuration for running a BPR model on ml-100k dataset
# Using CPU by default, or GPU if available and recbole[gpu] was installed.
config_dict = {
    'model': 'BPR',
    'dataset': 'ml-100k',
    'eval_args': {
        'split_ratio': '0.8:0.1:0.1', # Train:Valid:Test split
        'group_by': 'user' # Ensure evaluation is fair per user
    },
    'use_gpu': torch.cuda.is_available() # Dynamically check for GPU
}

print(f"Running RecBole with config: {config_dict}")

# Run the recommendation experiment
run_recbole(config_dict=config_dict)

view raw JSON →