Skip to content
Back to skills

Data Loading

ASecurity

Load, inspect, validate, and split Surprise rating datasets.

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 9, 2026
datapythongoapi

Works with

  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill data-loading --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Data Loading?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Data Loading
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-data-loading-d4ef2398/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-data-loading-d4ef2398)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: data-loading
description: "Load, inspect, validate, and split Surprise rating datasets."
disable-model-invocation: true
metadata:
  disco-role: operating
license: BSD 3-Clause
---

# Surprise data loading

Use this sub-skill when the task is to load ratings into Surprise, inspect the resulting `Trainset`, diagnose parser/layout errors, or prepare train/test material from local data. It is intentionally about data ingestion and trainset construction only.

## Fast route

1. Identify the data source:
   - Built-in cache/download: `Dataset.load_builtin(name, prompt=...)`.
   - One ratings file: `Reader(...)` + `Dataset.load_from_file(file_path, reader)`.
   - Pandas dataframe: `Reader(rating_scale=...)` + `Dataset.load_from_df(df[[user, item, rating]], reader)`.
   - Predefined train/test files: `Dataset.load_from_folds([(train_file, test_file), ...], reader)` + `PredefinedKFold().split(data)`.
2. Validate the layout before using an algorithm: check `Reader.line_format`, `sep`, `skip_lines`, dataframe column order, and fold file existence.
3. Build or materialize trainsets:
   - Full local dataset: `trainset = data.build_full_trainset()`.
   - Predefined folds: iterate `for trainset, testset in PredefinedKFold().split(data): ...`.
4. Use raw ids at public prediction/testset boundaries and inner ids only for `Trainset` internals. Convert with `to_inner_uid`, `to_inner_iid`, `to_raw_uid`, and `to_raw_iid`.
5. For details, read [`references/data-loading.md`](references/data-loading.md). For errors, read [`references/troubleshooting.md`](references/troubleshooting.md).

## API selection

| Need | Use | Contract to remember |
| --- | --- | --- |
| Built-in MovieLens/Jester data | `Dataset.load_builtin("ml-100k" | "ml-1m" | "jester")` | May prompt/download if the cache file is absent; cache root comes from `get_dataset_dir()` / `SURPRISE_DATA_FOLDER`. |
| Custom delimited file | `Reader(line_format=..., sep=..., rating_scale=..., skip_lines=...)` then `Dataset.load_from_file(...)` | `line_format` tokens are space-separated field names; `sep` is the actual delimiter in the file. |
| Dataframe | `Dataset.load_from_df(df[[user_col, item_col, rating_col]], reader)` | Column names are ignored; positional order must be user, item, rating. Only `rating_scale` is needed on the reader. |
| Existing train/test folds | `Dataset.load_from_folds(folds_files, reader)` | `folds_files` is a list of `(train_file, test_file)` tuples, and every path must exist up front. |
| Trainset inspection | `n_users`, `n_items`, `n_ratings`, `ur`, `ir`, `all_ratings()`, `build_testset()`, `build_anti_testset()` | `ur`, `ir`, `all_*`, and `knows_*` use inner ids; `build_*testset()` returns raw ids. |

## Bundled smoke scripts

Run these from this sub-skill directory after installing Surprise and any script-specific dependency:

- `python scripts/load_custom_file_smoke.py` — creates a temporary ratings file, loads it with `Reader`/`load_from_file`, checks zero-rating preservation, and verifies a wrong separator fails.
- `python scripts/load_from_dataframe_smoke.py` — creates a tiny dataframe, loads it with explicit column ordering, and checks the bad-ordering trap.
- `python scripts/load_predefined_folds_smoke.py` — creates temporary train/test fold files, loads them with `load_from_folds`, materializes `PredefinedKFold`, and checks nonexistent fold paths fail early.

## Boundaries

This sub-skill excludes algorithm choice, similarity math, cross-validation metrics/search, top-N recommendation generation, and model serialization. Use sibling sub-skills for those tasks: [`../prediction-algorithms/`](../prediction-algorithms/), [`../evaluation-and-search/`](../evaluation-and-search/), and [`../recommendation-and-analysis/`](../recommendation-and-analysis/).

Files in this skill

  • SKILL.md3.7 KB
  • references/data-loading.md8.7 KB
  • references/troubleshooting.md4.6 KB
  • scripts/load_custom_file_smoke.py2.3 KB
  • scripts/load_from_dataframe_smoke.py2.2 KB
  • scripts/load_predefined_folds_smoke.py2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.