Skip to main content

Log your ml training in the console in an attractive way.

Project description

LoggerML - Machine Learning Logger in the console

Log your Machine Learning training in the console in a beautiful way ✨ and with minimal code.

Support all Unix and Emacs distribution and Windows 11.

Be careful, Windows 10 is not supported.

Release](https://github.com/valentingol/logml/releases) PythonVersion License

Ruff_logo Black_logo

Ruff Flake8 Pydocstyle MyPy PyLint

Tests Coverage Bandit

Installation

In a new virtual environment, install simply the package via pipy:

pip install logml

For development, install the package dynamically and dev requirements with:

pip install -e .
pip install -r requirements-dev.txt

Quick start

Integrate the LogML logger in your training loop. For instance for 4 epochs, 20 batches per epoch and a log interval of 2 batches:

logger = Logger(
    n_epochs=4,
    n_batches=20,
    log_interval=2,
)
for _ in range(4):
    logger.start_epoch()  # Indicate the start of a new epoch
    for _ in range(20):
        logger.start_batch()  # Indicate the start of a new batch
        # Log every 2 batches but you should call the log method at every batch
        logger.log({'loss': 0.54321256, 'accuracy': 0.85244777})

Yields: Alt Text

Now you can customize the logger with your own styles and colors. You can set the default configuration at the initialization of the logger and then you can override it during log. For instance:

logger = Logger(
    n_epochs=4,
    n_batches=20,
    # (Log interval by default is 1, log every batch)
    styles='yellow',
    digits={'accuracy': 2},
    average=['loss'],  # loss will be averaged over the current epoch
    bold_keys=True,
    show_time=False,  # Remove the time bar
)
for _ in range(4):
    logger.start_epoch()
    for _ in range(20):
        logger.start_batch()
        # Overwrite the default style for "loss" and add a message
        logger.log(
            {'loss': 0.54321256, 'accuracy': 85.244777},
            styles={'loss': 'italic red'},
            message="Training is going well?\nYes!",
        )

Yields: Alt Text

Finally, if you don't have the number of batches in advance, you can initialize the logger with n_batches=None. Only the available information will be displayed. For instance with the configuration of the first example:

Alt Text

The progress bar is replaced by a cyclic animation. The eta times are not know at the first epoch but was estimated after the second epoch.

Todo

  • Manage a validation loop (then multiple loggers)
  • Enable not using new_epoch/log() if log config is minimal
  • Add color customization for message, epoch/batch number and time

How to contribute

Everyone can contribute to LogML, and we value everyone’s contributions. Please see our contributing guidelines for more information 🤗

License

Copyright (C) 2023 Valentin Goldité

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This project is free to use for COMMERCIAL USE, MODIFICATION, DISTRIBUTION and PRIVATE USE as long as the original license is include as well as this copy right notice at the top of the modified files.

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

loggerml-0.1.2.tar.gz (609.7 kB view hashes)

Uploaded Source

Built Distribution

loggerml-0.1.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

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