Code Monkey home page Code Monkey logo

progress-table's Introduction

Progress Table

PyPi version PyPI license

Lightweight utility to display the progress of your process as a pretty table in the command line.

example

Designed to monitor machine learning experiments, but can be used for anything. Allows you to quickly see what is going on. Increases readability and cuteness of your command line logging.

Features

  • Displaying pretty table in the terminal
  • Progress bar embedded into the table
  • Exporting data as lists, numpy arrays or pandas dataframes
  • Built-in basic data aggregation: sum and mean

Purpose

Change this:

example

Into this:

example

Example

Click here for examples of integration with PyTorch and Keras: integrations.md.

import random
import sys
import time

from progress_table import ProgressTable

# Define the columns at the beginning
table = ProgressTable(
  columns=["step", "x", "x squared"],

  # Default arguments:
  refresh_rate=10,
  num_decimal_places=4,
  default_column_width=8,
  default_column_alignment="center",
  print_row_on_update=True,
  reprint_header_every_n_rows=30,
  custom_format=None,
  embedded_progress_bar=False,
  table_style="normal",
  file=sys.stdout,
)
table.add_column("x", width=3)
table.add_column("x root", color="red")
table.add_column("random average", color=["bright", "red"], aggregate="mean")

for step in range(10):
  x = random.randint(0, 200)

  # There are two equivalent ways to add new values
  # First:
  table["step"] = step
  table["x"] = x
  # Second:
  table.update("x root", x ** 0.5)
  table.update("x squared", x ** 2)

  # Display the progress bar by wrapping the iterator
  for _ in table(range(10)):
    # You can use weights for aggregated values
    table.update("random average", random.random(), weight=1)
    time.sleep(0.1)

  # Go to the next row when you're ready
  table.next_row()

# Close the table when it's ready
table.close()

# Export your data
data = table.to_list()
pandas_df = table.to_df()
np_array = table.to_numpy()

example

Installation

Install Progress Table easily with pip:

pip install progress-table

Links

Alternatives

  • Progress bars: great for tracking progress, but they do not provide pretty CLI data display

    • tqdm
    • Keras.utils.Progbar
  • Libraries displaying data: great for presenting data, but they lack the tracking progress element

    • tabulate
    • texttable

progress-table's People

Contributors

sjmikler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.