Utility Functions

The pydis_nn.utils module provides utility functions for generating sample datasets.

Utility functions for generating sample datasets and other helpers.

pydis_nn.utils.generate_sample_dataset(n=1000, seed=42)[source]

Generate a synthetic 5D dataset for testing and demos.

Creates a dataset with 5 features (x1-x5) and a target variable y that is a non-linear combination of the features: - sin/cos terms from x1, x2 - Exponential (Gaussian-like) term from x3, x4 - Quadratic term from x5 - Cross-product term from x1, x4 - Plus Gaussian noise

Parameters:
  • n (int) – Number of samples to generate (default: 1000)

  • seed (int) – Random seed for reproducibility (default: 42)

Returns:

  • ‘X’: numpy array with shape (n, 5) containing features

  • ’y’: numpy array with shape (n,) containing targets

Return type:

Dictionary with keys ‘X’ and ‘y’

Examples

Generate a synthetic dataset:

from pydis_nn.utils import generate_sample_dataset
import pickle

# Generate 1000 samples
data = generate_sample_dataset(n=1000, seed=42)

# Save to file
with open('sample_dataset.pkl', 'wb') as f:
    pickle.dump(data, f)