Datasets API

See Datasets for each dataset’s metadata, precomputed feature availability, timestamps, sources, and checkpoint examples. Dataset citations are listed in Datasets.

class compresso_recsys.datasets.RecSysDataset(data_dir='data')[source]

Thin base class for interaction datasets used in example pipelines.

Canonical interactions schema: - user_id: str - item_id: str - value: float - timestamp: int | float | None

Parameters:

data_dir (str | Path)

static preprocess_interactions_for_recsys(df, *, min_value_to_keep=4.0, user_min_support=5, item_min_support=1, set_all_values_to=1.0, max_steps=0)[source]

Paper-style preprocessing: threshold, binarize, iterative pruning, categorical cleanup.

Return type:

DataFrame

Parameters:
  • df (DataFrame)

  • min_value_to_keep (float | None)

  • user_min_support (int)

  • item_min_support (int)

  • set_all_values_to (float | None)

  • max_steps (int)

to_hf_dataset(df=None)[source]

Convert interactions to HuggingFace Dataset.

Import is optional so core library does not hard-depend on datasets.

Parameters:

df (DataFrame | None)

static to_sparse_matrix(df)[source]

Return (X, user_ids, item_ids) where X is user x item CSR.

Parameters:

df (DataFrame)

class compresso_recsys.datasets.SplitBundle(train, val, test)[source]
Parameters:
  • train (DataFrame)

  • val (DataFrame)

  • test (DataFrame)

class compresso_recsys.datasets.MovieLens1M(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0)[source]
Parameters:
  • data_dir (str)

  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

class compresso_recsys.datasets.MovieLens20M(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0)[source]
Parameters:
  • data_dir (str)

  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

class compresso_recsys.datasets.Goodbooks(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0)[source]
Parameters:
  • data_dir (str)

  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

class compresso_recsys.datasets.AmazonReviews2023(data_dir='data', *, category='Toys_and_Games', metadata_text_fields=None, min_entity_text_words=0, include_image_urls=False, show_progress=True)[source]

Amazon Reviews 2023 category dataset loaded from McAuley’s files.

The recommender pipeline only needs compact rating-only interactions plus item metadata. Reviews are intentionally not downloaded.

Parameters:
  • data_dir (str)

  • category (str)

  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • include_image_urls (bool)

  • show_progress (bool)

load_source_dataframe(config, *, split='full')

Load a McAuley Amazon 2023 config into a DataFrame.

Kept under its historical name for compatibility with tests and subclasses, but this no longer uses Hugging Face datasets. Recent datasets releases reject repositories that still expose loading scripts, so we read direct Hugging Face/McAuley data files instead.

Return type:

DataFrame

Parameters:
  • config (str)

  • split (str)

load_timestamp_splits_with_history()[source]

Load McAuley’s timestamp split with per-row history fields.

Return type:

dict[str, DataFrame]

class compresso_recsys.datasets.Steam(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Raw McAuley Steam reviews with original product IDs and game metadata.

Every review is an interaction, including negative reviews (BERT4Rec’s convention). Dates have day precision; equal dates retain source order. Metadata does not have to exist for every reviewed game.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

class compresso_recsys.datasets.NetflixPrize(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Netflix Prize ratings with dates, movie titles and release years.

Downloads the original-format archive from Internet Archive. No Kaggle dependency. Original Netflix terms apply; Compresso does not redistribute it.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

class compresso_recsys.datasets.TasteProfile(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

MSD Taste Profile triplets: play counts, no timestamps or item text.

The original source currently serves this archive over HTTP. Additional MSD metadata and mismatch lists are not part of this interaction adapter.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

timestamp_precision = None
class compresso_recsys.datasets.Gowalla(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Raw SNAP check-ins with timestamps and location coordinates.

Repeated check-ins are retained. This is not the remapped LightGCN split. Coordinates are taken from the first source occurrence of each location. The social graph is not required or downloaded.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

class compresso_recsys.datasets.RetailRocket(data_dir='data', *, events=('view',), metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Visitor events over 4.5 months: 2.76M rows, 1.41M visitors, 235k items.

Repeated views of the same item are retained; they are most of what makes this log a sequence rather than a set. Item properties are published as hashed values, so there is no usable item text and the catalog carries no metadata beyond the ids the events reference.

Sequences are short — under two events per visitor on average — so the leave-last-out protocol, which needs four, keeps only a small and heavily self-selected minority of visitors. Measure that share before reading anything into a metric computed on it.

Parameters:
  • events (Sequence[str])

  • min_entity_text_words (int)

  • show_progress (bool)

events_file = 'events.csv'

Kaggle serves the archive to signed-in users only, so there is no URL to fetch. Only this member of the archive is read; the rest may stay zipped.

download()[source]

Check for the manually placed export rather than fetching anything.

Raising beats a warning here: prepare would otherwise continue and fail inside the CSV reader, reporting a missing file instead of the manual step that is actually required.

Return type:

None

class compresso_recsys.datasets.Music4AllOnion(data_dir='data', *, start=None, end=None, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

252,984,396 listening events by 119,140 users over 56,512 tracks.

Heavy repeat consumption: a user replaying one track several times in a row is ordinary here, and those replays are retained as separate events. That makes this the one registered dataset where “predict the next listen” and “predict a new listen” are different questions, so report metrics split by whether the target already occurs in the history.

The source file is 2.2 GB compressed and expands to a quarter of a billion rows, which does not fit in memory as a DataFrame on an ordinary machine. Pass start and end to take a time window. Window by time rather than by sampling rows: dropping random events destroys the adjacency that any sequential claim rests on, while a window leaves the surviving histories intact.

Rows arrive newest-first within a user, which is the opposite of the chronological order every consumer wants. Nothing here re-sorts them – leave_last_out and the temporal split both sort by timestamp themselves, and rewriting the file order would destroy the only evidence available about how tied events were originally recorded.

The release also ships 26 audio, video, lyric and metadata feature sets that this adapter does not download; the catalog carries item IDs only.

Parameters:
  • start (str | None)

  • end (str | None)

  • min_entity_text_words (int)

  • show_progress (bool)

class compresso_recsys.datasets.OTTO(data_dir='data', *, session_sample=None, events=('clicks',), metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Sessions with real boundaries: 12.9M sessions, 1.8M items, 216M events.

Every other registered dataset either has no session structure or requires inferring one from inter-arrival gaps. Here the boundaries are recorded, so a session is a fact about the data rather than a threshold someone chose.

Sessions are the rows, so user_id holds a session id. There is no identity linking one session to the next and no item metadata whatsoever – this dataset can support sequential work and nothing else.

Parsing is a Python loop over nested JSON, which on the full file takes long enough to be worth doing once; the canonical columns are then cached as parquet and later runs skip it.

The full log is around 194 million clicks, which does not fit in memory as a DataFrame on an ordinary machine. session_sample keeps a deterministic fraction of sessions, chosen by hashing the session id:

OTTO(session_sample=0.1)

Sample sessions rather than rows or a time window. Dropping random events would destroy the adjacency inside a session, and a time window would cut sessions in half; keeping or dropping whole sessions leaves every surviving history exactly as it was. Hashing rather than taking the first N lines matters too, because the file is ordered by session id and the earliest ids are the longest-running sessions.

The competition’s test.jsonl is its held-out split and is not read; this adapter builds its own splits from train.jsonl.

Parameters:
  • session_sample (float | None)

  • events (Sequence[str])

  • min_entity_text_words (int)

  • show_progress (bool)

download_command = 'kaggle datasets download -d otto/recsys-dataset'

Kaggle serves both the competition and the standalone dataset to signed-in users only, so there is nothing to fetch over plain HTTP.

download()[source]

Check for the manually placed export rather than fetching anything.

Raising beats warning: prepare would otherwise continue and report a missing file from inside the reader instead of the manual step that is actually required.

Return type:

None

class compresso_recsys.datasets.Yambda(data_dir='data', *, variant='50m', organic_only=False, user_sample=None, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Listening events with an is_organic flag on every row.

That flag is the reason to reach for this dataset. Every other log here records what users did without recording how much of it the platform chose for them, so exposure bias can only be named as a caveat. Here it can be measured: organic_only=True keeps the events a user started themselves and drops the ones a recommender served.

Timestamps are seconds since the start of the log, not since 1970, and they are rounded to multiples of five. Both facts matter more than they look:

  • The relative epoch is silent if assumed wrong – values around 2.6e7 parse as January 1970 without raising – so nothing here converts them, and the builder’s magnitude normalisation leaves numbers this small untouched.

  • Five-second rounding creates ties by construction. A tie rate above zero here says nothing about the platform’s logging quality, unlike on a dataset recorded at second precision.

variant selects the release size: "50m" (the default), "500m" or "5b", named for roughly that many interactions. None of them builds whole on an ordinary machine: even "50m" is 46.5M listens, which exhausts a 16 GB machine. user_sample keeps a deterministic fraction of users, chosen by hashing the user id:

Yambda(user_sample=0.2)

Sample users rather than rows, for the same reason OTTO samples sessions: dropping random events would destroy the adjacency inside a history, while keeping or dropping whole users leaves every surviving history exactly as it was. The larger two variants need a lower fraction again, or the memory to hold them. Each variant is cached under its own filename, so switching between them re-reads rather than reusing the previous one’s rows.

The published files are sorted by (uid, timestamp). Order within a tie is therefore whatever that sort produced, so the within-tie ascent diagnostic measures the sort rather than the data, and cannot be read the way it can on a dataset stored in its original write order.

The release also carries likes, dislikes, unlikes, undislikes and audio embeddings. This adapter reads listens only: the canonical interaction schema has one event kind, and folding a dislike into the same column as a play would record the two as the same thing.

Parameters:
  • variant (str)

  • organic_only (bool)

  • user_sample (float | None)

  • min_entity_text_words (int)

  • show_progress (bool)

class compresso_recsys.datasets.DBbook(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

DBbook binary feedback; retains the upstream train/test label per row.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

timestamp_precision = None
get_official_split()[source]

Return the supplied train/test frames without merging or resplitting.

class compresso_recsys.datasets.LastFM2K(data_dir='data', *, metadata_text_fields=None, min_entity_text_words=0, show_progress=True)[source]

Artist listening counts; tagging dates are not listening timestamps.

Parameters:
  • metadata_text_fields (Iterable[str] | None)

  • min_entity_text_words (int)

  • show_progress (bool)

timestamp_precision = None