Skip to main content

Machine unlearning methods for energy consumption prediction

Project description

Machine Unlearning Library

This library provides modular implementations of machine unlearning techniques for time-series data. It is designed for use in research, evaluation, and deployment scenarios where data privacy and the right to be forgotten are important.

Features

  • Support for Exact Retraining, SISA, and Knowledge Distillation as unlearning strategies
  • LSTM-based model architecture for building energy consumption prediction
  • Modular preprocessing, training, evaluation, and unlearning components
  • Support for measuring carbon emissions via CodeCarbon
  • Designed as a reusable, extendable Python package

Project Structure

├── data_utils.py         # Data loading, preprocessing, and forget set selection
├── model_utils.py        # LSTM model definition
├── training.py           # Training loops and model evaluation
├── evaluation.py         # Metrics: RMSE, MAE, R²
├── unlearning.py         # Implementations of unlearning methods
├── workflow.py           # High-level run_* functions for each unlearning method
├── __init__.py           # Public API

Getting Started

Installation

Clone the repository and make sure dependencies are installed:

pip install torch pandas scikit-learn

Example Usage

from Machine_Unlearning_Tool import (
    load_dataset, preprocess_data, run_sisa_unlearning
)

# Load and preprocess data
df = load_dataset("data/train.csv")
config = { ... }  # preprocessing configuration
df = preprocess_data(df, config)

# Convert to tensors and run SISA
X = ...
y = ...
results = run_sisa_unlearning(X, y, df, input_cols, target_col, id_col, forget_ids, device)

Public API Overview

load_dataset(filepath: str) -> pd.DataFrame

Loads a dataset from CSV.

preprocess_data(df: pd.DataFrame, config: dict) -> pd.DataFrame

Preprocesses the dataset using normalization and categorical encoding.

train_model(model, ...)

Trains a PyTorch model on provided data.

run_sisa_unlearning(...)

Performs SISA unlearning: slices and shards the dataset, retrains on retained data.

run_exact_retraining(...)

Performs full retraining on retained data.

run_knowledge_distillation(...)

Trains a student model using teacher model outputs while excluding forget set.

evaluate_on_loader(model, loader, loss_fn, device)

Computes RMSE, MAE, and R² metrics on a test or validation loader.


Output

Each run_* method returns:

  • Trained model or model dictionary
  • Pre- and post-unlearning performance metrics
  • (Optional) CodeCarbon energy emission data

Notes

  • Forget set is defined using user-specified id_column and list of IDs
  • Can be extended with new models or additional unlearning methods
  • Suitable for research on GDPR-compliant model behavior

License

No License specified.

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

mlforget-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

mlforget-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlforget-0.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for mlforget-0.1.0.tar.gz
Algorithm Hash digest
SHA256 807f1aeefcf2ea676b20d601bf51f5c092f07b174ba06144158fe92802be1d2f
MD5 c3d607890c3cec7039af9031b56712b8
BLAKE2b-256 d65349b56f0623436520c8510df0316db492c16617ee1f38e032b7054376cd98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlforget-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for mlforget-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78c6c9ac5688373e098042f61ed41ceb2d68546f878301e6fdfe89cc35c52504
MD5 946d5dae89d67c5a1a510d0a471d688a
BLAKE2b-256 cef6d542a5a327062290d968ffaf21657da244e20e3e6a7fd5434b3984b367b7

See more details on using hashes here.

Supported by

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