Chemical Engineering Dataset Loader Library
Project description
CheLo (Chemical Engineering Dataset Loader) Library
Overview
The CheLo Library is a Python library designed to simplify the exploration of data-driven modeling for students studying chemical engineering and researchers working on related projects. This library provides a standardized framework for accessing, managing, and utilizing chemical engineering datasets for machine learning and statistical analysis.
Key Features
- Dataset Standardization: Unified API for accessing and exploring datasets.
- Multiple Data Formats: Provides ready to use loaders for numpy, PyTorch, and Keras.
- Preprocessing Tools: Methods for feature/target selection, statistics, and previewing datasets.
- Dataset Management: Automated downloading, caching, and registry of datasets.
- Extensibility: Abstract base class for easy addition of new datasets.
Installation
To install the library, run the following command:
pip install chelo
To install the library in editable mode for development purposes:
git clone https://github.com/your-repo/chelo.git
cd chelo
pip install -e .
Package Structure
chelo/ # Root package
├── __init__.py # Exposes core components
├── base.py # Abstract base class and shared utilities
├── datasets/ # Dataset-specific implementations
│ └── ... # Dataset implementations
├── utils/ # Utility functions and helpers
│ ├── __init__.py # Utility imports
│ └── download.py # Dataset downloader and caching
├── registry.py # Dataset registry
└── tests/ # Unit and integration tests
├── __init__.py # Makes this directory a package
├── test_base.py # Tests for the base class
└── test_X.py # Tests for X dataset
Usage Guide
Loading a Dataset
from chelo.datasets.wine_quality import WineQualityDataset
# Instantiate the dataset
dataset = WineQualityDataset(wine_type="red", selected_features=["alcohol", "pH"], selected_targets=["quality"])
# Load data (downloads if not cached)
dataset.load_data()
# Access dataset information
info = dataset.get_dataset_info()
print("Dataset Info:", info)
Accessing Data
# Convert to numpy arrays
features, targets = dataset.to_numpy()
print("Features shape:", features.shape)
print("Targets shape:", targets.shape)
# Convert to PyTorch Dataset
pytorch_dataset = dataset.to_pytorch()
print("Number of samples in PyTorch Dataset:", len(pytorch_dataset))
# Convert to Keras Sequence
keras_sequence = dataset.to_keras(batch_size=32)
for batch_features, batch_targets in keras_sequence:
print("Batch Features:", batch_features.shape)
print("Batch Targets:", batch_targets.shape)
Dataset Statistics and Preview
# Get basic statistics
stats = dataset.statistics()
print("Statistics:", stats)
# Preview the dataset
preview = dataset.preview(n=5)
print("Preview:", preview)
Registering and Accessing Datasets
from chelo.registry import DatasetRegistry
# List available datasets
print("Available Datasets:", DatasetRegistry.list_datasets())
# Retrieve and load a dataset by name
dataset = DatasetRegistry.get_dataset("WineQualityDataset", wine_type="red")
dataset.load_data()
Extending the Library
To add a new dataset, create a new class that inherits from ChemicalEngineeringDataset and implement the required methods:
- Create a new dataset module:
chelo/datasets/my_new_dataset.py
- Implement the dataset class:
from ..base import ChemicalEngineeringDataset
class MyNewDataset(ChemicalEngineeringDataset):
def __init__(self, selected_features=None, selected_targets=None):
super().__init__(selected_features, selected_targets)
self.dataset_name = "My New Dataset"
def load_data(self):
# Load dataset into self.raw_features and self.raw_targets
pass
def list_features(self):
return list(self.raw_features.keys())
def list_targets(self):
return list(self.raw_targets.keys())
def get_dataset_info(self):
return {"name": self.dataset_name, "description": "Description of the dataset."}
- Register the dataset:
Add the following line to chelo/datasets/__init__.py:
from .my_new_dataset import MyNewDataset
DatasetRegistry.register(MyNewDataset)
Advanced Features
Downloader Utility
The library includes a downloader utility for downloading and caching datasets. Files are stored in a structured cache directory (default: ~/.chelo).
Example Usage
from chelo.utils.download import DatasetDownloader
downloader = DatasetDownloader()
# Download a dataset file
url = "https://example.com/dataset.csv"
file_path = downloader.download(url, dataset_name="example_dataset", filename="example.csv")
print("Downloaded file path:", file_path)
Dataset Registry
The registry dynamically manages available datasets, allowing users to list and retrieve datasets by name.
Example Usage
from chelo.registry import DatasetRegistry
# List all registered datasets
print("Available Datasets:", DatasetRegistry.list_datasets())
# Retrieve a dataset by name
dataset = DatasetRegistry.get_dataset("WineQualityDataset", wine_type="white")
Testing
The library includes comprehensive unit tests to ensure correctness and reliability. Run tests using pytest:
pytest tests/
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Implement your changes and add tests.
- Submit a pull request with a detailed description of your changes.
License
This library is licensed under the MIT License. See the LICENSE file for more details.
Contact
For questions or feedback, please contact [your email or project contact].
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chelo-0.0.1.tar.gz.
File metadata
- Download URL: chelo-0.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f703d19a373e0cf660ff575e3f9dea1f228e9d1184d08394f6b4d5bf0ad40408
|
|
| MD5 |
7335d459786ebde4b565d56da1cf3206
|
|
| BLAKE2b-256 |
1ba7073400d40de5ee9d87b92b75a84a59ccb06d928b465d2725f1e8b51ad5b7
|
File details
Details for the file chelo-0.0.1-py3-none-any.whl.
File metadata
- Download URL: chelo-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
321fb72cfdc4cb9c22c2183bfccc38cf2ec6d16ab156397cab8899f167cdc8ae
|
|
| MD5 |
3bec25b39b0ec15d19f31406392e1960
|
|
| BLAKE2b-256 |
0d1e97ce15e8ce9e8a6958d3e10c23154f1b9edc585297542fd54d22439126ee
|