Skip to content

Data module

Alessio Faraci edited this page Sep 11, 2025 · 2 revisions

Requirements

When working with custom datasets, it's essential to follow the specified file structure.

Directory Structure

Organize your dataset files as follows:

your_dataset_folder/
├── dataset_x.csv    # Complete feature set
├── dataset_y.csv    # Complete label set
├── train_x.csv      # Training features
├── train_y.csv      # Training labels
├── test_x.csv       # Test features
└── test_y.csv       # Test labels

CSV File Format

  • Delimiter: All CSV files must use comma (,) delimiters.
  • Headers: Files must not include any headers.
  • Structure: Each row must represent a single sample, with columns corresponding to features or targets.

Core Functionality

Loading Datasets

Function Description
load(file_path: Path) Loads training and test datasets from CSV files in a specified directory.

load

  • Parameters:
    • file_path: Path to the directory containing train_x.csv, train_y.csv, test_x.csv, test_y.csv.
  • Returns: A tuple of numpy arrays: (train_x, test_x, train_y, test_y).

Synthetic Data Generation

generate_synthetic

Generates synthetic datasets by evaluating a given function on sampled input points.

  • Parameters:
    • bounds: An array of shape (2, dim) specifying the lower and upper bounds.
    • fn: The function to evaluate on the generated samples.
    • data_size: The total number of samples to generate.
    • train_size: The number of training samples.
    • file_path: The directory path where the generated data will be saved.
    • method (optional): The sampling method to use ("uniform" or "lhs" for Latin Hypercube Sampling). Default is "uniform".
    • seed (optional): A random seed for reproducibility.
  • Returns: A tuple of the generated datasets: (train_x, test_x, train_y, test_y).

Dataset Splitting

split_dataset

Splits an existing dataset into training and test sets.

  • Parameters:
    • file_path: The path to the directory containing dataset_x.csv and dataset_y.csv.
    • test_size: The proportion of the dataset to be used for testing.
  • Returns: A tuple of the split datasets: (train_x, test_x, train_y, test_y).

Clone this wiki locally