Skip to main content

Malet

Malet: a tool for machine learning experiment

Full Documentation | Changelog

Malet (Machine Learning Experiment Tool) is a tool for hyperparameter grid searches, metric logging, advanced analyses and visualizations.

Minimum metric plot Animated curve plot Lambda schedule plot Animated lambda learning-rate plot Interval validation accuracy plot Lambda distribution plot Dense lambda validation accuracy plot Lambda distribution plot Small lambda distribution plot Lambda distribution plot Lambda distribution plot Lambda distribution plot

Features

  • 🔎 Easy & powerful hyperparameter grid search syntax
  • 📝 Experiment metric logging and resuming system
  • 📊 Flexible data process and visualization tools
  • 🚀 Search parallelization for multi-gpus

Installation

pip install malet

From source:

pip install git+https://github.com/dongyeoplee2/Malet.git

For development (uses uv):

uv sync

Quick Start

1. Prerequisite

Experiment Folder

Using Malet starts with making a folder with a single yaml config file. Various files resulting from some experiment is saved in this single folder. We advise to create a folder for each experiment under experiments folder.

experiments/
└── {experiment folder}/
    ├── exp_config.yaml : experiment config yaml file            (User created)
    ├── log.tsv         : log file for saving experiment results (generated by malet.experiment)
    ├── (log_splits)    : folder for splitted logs               (generated by malet.experiment)
    └── figure          : folder for figures                     (generated by malet.plot)

Pre-existing training pipeline

Say you have some training pipeline that takes in a configuration (any object w/ dictionary-like interface). We require you to return the result of the training so it gets logged.

def train(config, ...):
    ...
    # training happens here
    ...
    metric_dict = {
        'train_accuracies': train_accuracies,
        'val_accuracies': val_accuracies,
        'train_losses': train_losses,
        'val_losses': val_losses,
    }
    return metric_dict

2. Running experiments

Experiment config yaml

You can configure as you would do in the yaml file. But we provide useful special keyword grid, used as follows:

# static configs
model: LeNet5
dataset: mnist

num_epochs: 100
batch_size: 128
optimizer: adam

# grided fields
grid:
  seed: [1, 2, 3]
  lr: [0.0001, 0.001, 0.01, 0.1]
  weight_decay: [0.0, 0.00005, 0.0001]

Specifying list of config values under grid lets you run all possible combination (i.e. grid) of your configurations, with field least frequently changing in the order of declaration in grid.

Running experiments

The following will run the train_fn on grid of configs based on {exp_folder_path} and train_fn.

from functools import partial
from malet.experiment import Experiment

train_fn = partial(train, ...{other arguments besides config}..)
metric_fields =  ['train_accuracies', 'val_accuracies', 'train_losses', 'val_losses']
experiment = Experiment({exp_folder_path}, train_fn, metric_fields)
experiment.run()

Note that you need to partially apply your original function so that you pass in a function with only config as its argument.

Experiment logs

The experiment log will be automatically saved in the {exp_folder_path} as log.tsv, where the static configs and the experiment log are each saved in yaml and tsv like structure respectively. You can retrieve these data in python using ExperimentLog in malet.experiment as follows:

from malet.experiment import ExperimentLog

log = ExperimentLog.from_tsv({tsv_file})

static_configs = log.static_configs
df = log.df

Experiment logs also enable resuming to the most recently run config when a job is suddenly killed.

3. Plot making

Running malet.plot lets you make plots based on log.tsv in the experiment folder.

malet-plot \
-exp_folder ../experiments/{exp_folder} \
-mode curve-epoch-train_accuracy

The key intuition for using this is to leave only two fields in the dataframe for the x-axis and the y-axis by

  1. specifying a specific value (_e.g._ther hyperparameters),

which will leave only one value for each field.

Available plot modes: curve, curve_best, bar, heatmap, scatter, scatter_heat.

For the full list of CLI arguments, plot configuration options, advanced gridding, parallel GPU training, checkpointing, and more, see the full documentation.

Citation

If you find Malet useful, please cite it as:

@software{lee2024malet,
  author       = {Dongyeop Lee},
  title        = {Malet: Machine Learning Experiment Tool},
  year         = {2024},
  url          = {https://github.com/dongyeoplee2/Malet},
}

Metadata

Release files for malet 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for malet 0.2.2
File Size Uploaded Provenance Actions
malet-0.2.2.tar.gz 54.9 kB Without provenance Details for malet-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for malet 0.2.2
File Interpreter ABI Platform Actions
malet-0.2.2-py3-none-any.whl Python 3 none any Details for malet-0.2.2-py3-none-any.whl

Total release size: 102.4 kB

Release files / malet-0.2.2.tar.gz

Download URL malet-0.2.2.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a8440ecba5b5b0f7722d867314233dd45962e2853ace92b65b47718b0b85ce4e
BLAKE2b-256 checksum
How to use checksums
109230fee3f5320fb4a1c8ebe1c1eac87966e34207333ca55a11857c2df75565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / malet-0.2.2-py3-none-any.whl

Download URL malet-0.2.2-py3-none-any.whl
Size 47.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6176de20bb83642d0c6a12076bb07e7df9864595ecdbb73615bb21e118581394
BLAKE2b-256 checksum
How to use checksums
e8335b36855777ec139d14c146a2e929eae1469bc17b48c0aa0c508dc36c532d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for malet 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page