Skip to main content

silver-data

Python Version License Tests Code Style

Inspectable, deterministic dataset contracts and loaders for Silver. A Python package designed for ML researchers who need reliable dataset handling with built-in validation and reproducibility features.

The base install uses only the Python standard library for records, JSON, JSONL, and CSV. Add pandas only when you need DataFrame conversion:

pip install 'silver-data[pandas]'

Installation

pip install silver-data

Quick Start

from silver_data import Dataset

# Load from CSV file
dataset = Dataset.from_csv("my_data", "path/to/data.csv")

# Optional: load from pandas
import pandas as pd
df = pd.read_csv("path/to/data.csv")
dataset = Dataset.from_pandas("my_data", df)

# Inspect dataset
report = dataset.inspect()
print(f"Rows: {report.rows}, Columns: {len(report.columns)}")
for col in report.columns:
    print(f"  {col.name}: {col.value_type} ({col.unique} unique, {col.missing} missing)")

# Validate dataset
validation = dataset.validate()
if not validation.valid:
    print("Errors:", validation.errors)
if validation.warnings:
    print("Warnings:", validation.warnings)

# Split dataset for ML workflows
train, val, test = dataset.split(train=0.8, validation=0.1, test=0.1)
print(f"Train: {len(train.records())}, Val: {len(val.records())}, Test: {len(test.records())}")

Features

  • Multiple Data Sources: Load from CSV, JSON, JSONL, and pandas DataFrames
  • Dataset Inspection: Get detailed column statistics and metadata
  • Data Validation: Automatic detection of missing values, inconsistent columns, and data quality issues
  • Deterministic Fingerprinting: Generate unique identifiers for datasets to ensure reproducibility
  • Smart Splitting: Train/validation/test splitting with customizable ratios
  • Immutable Design: Safe data handling with copy-on-write semantics
  • Type Safety: Full type hints for better IDE support and fewer bugs

Use Cases

ML Pipeline Integration

from silver_data import Dataset
import pandas as pd

# Load and validate training data
df = pd.read_csv("train.csv")
dataset = Dataset.from_pandas("training", df)

# Ensure data quality before training
validation = dataset.validate()
if not validation.valid:
    raise ValueError(f"Dataset validation failed: {validation.errors}")

# Split for cross-validation
train_split, val_split, test_split = dataset.split(train=0.7, validation=0.15, test=0.15)

# Use fingerprints for caching
cache_key = dataset.fingerprint()
print(f"Dataset fingerprint: {cache_key}")

Data Quality Monitoring

from silver_data import Dataset

# Monitor data drift over time
dataset_v1 = Dataset.from_csv("data_v1", "data_2024_01.csv")
dataset_v2 = Dataset.from_csv("data_v2", "data_2024_02.csv")

if dataset_v1.fingerprint() != dataset_v2.fingerprint():
    print("Dataset has changed - retrain models")

# Check for new data quality issues
report_v2 = dataset_v2.inspect()
for col in report_v2.columns:
    if col.missing > len(dataset_v2.records()) * 0.1:  # More than 10% missing
        print(f"Warning: {col.name} has high missing rate: {col.missing}")

Experiment Reproducibility

from silver_data import Dataset

# Ensure exact same data across experiments
dataset = Dataset.from_csv("experiment", "data.csv")
experiment_id = f"exp_{dataset.fingerprint()}"

# Log for reproducibility
print(f"Running experiment {experiment_id} with dataset fingerprint {dataset.fingerprint()}")

Advanced Usage

Custom Data Loading

from silver_data import Dataset
import json

# Load from custom JSON format
with open("custom_data.json") as f:
    data = json.load(f)
dataset = Dataset.from_json("custom", data)

# Load from streaming JSONL
with open("streaming_data.jsonl") as f:
    dataset = Dataset.from_jsonl("streaming", f.read())

Data Type Analysis

from silver_data import Dataset

dataset = Dataset.from_csv("analysis", "mixed_data.csv")
report = dataset.inspect()

# Analyze column types
string_cols = [c.name for c in report.columns if c.value_type == "string"]
numeric_cols = [c.name for c in report.columns if c.value_type == "number"]
mixed_cols = [c.name for c in report.columns if c.value_type == "mixed"]

print(f"String columns: {string_cols}")
print(f"Numeric columns: {numeric_cols}")
print(f"Mixed type columns: {mixed_cols}")

Requirements

  • Python 3.8+
  • pandas 1.0+

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=silver_data --cov-report=html

# Run linting
flake8 src/ tests/
mypy src/

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

Apache-2.0 - see LICENSE file for details.

Related Packages

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

silver_data-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

silver_data-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file silver_data-0.1.0.tar.gz.

File metadata

  • Download URL: silver_data-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for silver_data-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0ec3e76f5dc944fced54f34428d5f71839805284102ac4823fcb14770c1c374
MD5 2e44c1b750cfffd45e0da4266e2ab9f2
BLAKE2b-256 20ce26a5fc0d324556427f0bc3aecf6bb3d52252a174d2141546499f7b19ee1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for silver_data-0.1.0.tar.gz:

Publisher: release.yml on adfgdartec/silver-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file silver_data-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: silver_data-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for silver_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94854d9fe64411dcd6ff5beb35b14deba344131a0756dcd3bbea684a4b062f40
MD5 94d78227f238a4948530bffe952ab899
BLAKE2b-256 87755467fc17f4bb0e5a79e5a88f4090a39dc0d1eabf9522006f8a4983f7c9ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for silver_data-0.1.0-py3-none-any.whl:

Publisher: release.yml on adfgdartec/silver-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page