A single Python file with some tools for visualizing machine learning in the terminal.

Overview

Machine Learning Visualization Tools

A single Python file with some tools for visualizing machine learning in the terminal.

This demo is composed of three ideas, which are explained below. Here's how to get started:

git clone https://github.com/bwasti/mlvt.git
cd mlvt
python3 -m pip install -r requirements.txt
python3 test.py # demo above

or just copy the mlvt.py file!

mlvt.Reprint

Reprint helps with in-line animations. It works by keeping track of how much it printed so far and reprinting it when flush() is called.

You can use the with statement to hijack print statements and auto_flush=True to avoid calling flush() in a loop, like so:

print("loading!")
with mlvt.Reprint(auto_flush=True) as rp:
  for i in range(100):
    print(f"{i+1}%") # Reprint detects the loop and overwrites in-place
    time.sleep(0.02)
print("done!")

reprint.gif

or, if you'd prefer to avoid contexts, loop-detection and hijacked builtins

print("loading!")
rp = mlvt.Reprint()
for i in range(100):
  rp.print(f"{i+1}%")
  rp.flush()
  time.sleep(0.02)
print("done!")

mlvt.horiz_concat

horiz_concat concatenates multi-line strings horizontally, accounting for padding and ANSI escape sequences (for color text).

a = """
{ hello! }
          \_    
"""
b = """
 ___
|. .|
| ^ |
| o |
"""
print(mlvt.horiz_concat(a, b, padding=2))

yields


               ___
{ hello! }    |. .|
          \_  | ^ |
              | o |
              

plotille wrappers

Finally, there are a couple of small plotille wrappers that decouple updating charts and printing them. That library is great on its own, so I encourage you to check it out!

import mlvt
import numpy as np

# all charts take in width, height, color
hist = mlvt.Histogram(32, 8, color="bright_blue")
hist.update(np.random.randn(100))
print(hist)

gives us

 (Counts)  ^
8.80000000 |
7.70000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
6.60000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
5.50000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⣶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
4.40000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⢰⣶⣶⠀⠀⢸⡇⣿⠀⢰⣶⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
3.30000000 | ⠀⠀⠀⠀⠀⠀⠀⣿⢸⣿⣿⣿⣿⢸⣿⣿⣿⢸⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
2.20000000 | ⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⢸⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⠀⠀⠀⢸⡇⠀⠀
1.10000000 | ⠀⠀⢀⣀⡀⣿⣀⣿⣿⣿⣿⣿⣿⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⣇⣸⡇⠀⠀
         0 | ⠀⠀⢸⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⣿⣿⡇⠀⠀
-----------|-|---------|---------|---------|-> (X)
           | -2.124059 -0.741902 0.6402548 2.0224115
You might also like...
A data preprocessing package for time series data. Design for machine learning and deep learning.

A data preprocessing package for time series data. Design for machine learning and deep learning.

A mindmap summarising Machine Learning concepts, from Data Analysis to Deep Learning.
A mindmap summarising Machine Learning concepts, from Data Analysis to Deep Learning.

A mindmap summarising Machine Learning concepts, from Data Analysis to Deep Learning.

A comprehensive repository containing 30+ notebooks on learning machine learning!
A comprehensive repository containing 30+ notebooks on learning machine learning!

A comprehensive repository containing 30+ notebooks on learning machine learning!

Implemented four supervised learning Machine Learning algorithms

Implemented four supervised learning Machine Learning algorithms from an algorithmic family called Classification and Regression Trees (CARTs), details see README_Report.

This repository has datasets containing information of Uber pickups in NYC from April 2014 to September 2014 and January to June 2015. data Analysis , virtualization and some insights are gathered here

uber-pickups-analysis Data Source: https://www.kaggle.com/fivethirtyeight/uber-pickups-in-new-york-city Information about data set The dataset contain

2D fluid simulation implementation of Jos Stam paper on real-time fuild dynamics, including some suggested extensions.
2D fluid simulation implementation of Jos Stam paper on real-time fuild dynamics, including some suggested extensions.

Fluid Simulation Usage Download this repo and store it in your computer. Open a terminal and go to the root directory of this folder. Make sure you ha

This repo includes some graph-based CTR prediction models and other representative baselines.

Graph-based CTR prediction This is a repository designed for graph-based CTR prediction methods, it includes our graph-based CTR prediction methods: F

Automatically build ARIMA, SARIMAX, VAR, FB Prophet and XGBoost Models on Time Series data sets with a Single Line of Code. Now updated with Dask to handle millions of rows.
Automatically build ARIMA, SARIMAX, VAR, FB Prophet and XGBoost Models on Time Series data sets with a Single Line of Code. Now updated with Dask to handle millions of rows.

Auto_TS: Auto_TimeSeries Automatically build multiple Time Series models using a Single Line of Code. Now updated with Dask. Auto_timeseries is a comp

High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.
High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.

What is xLearn? xLearn is a high performance, easy-to-use, and scalable machine learning package that contains linear model (LR), factorization machin

Owner
Bram Wasti
https://twitter.com/bwasti
Bram Wasti
Microsoft contributing libraries, tools, recipes, sample codes and workshop contents for machine learning & deep learning.

Microsoft contributing libraries, tools, recipes, sample codes and workshop contents for machine learning & deep learning.

Microsoft 366 Jan 3, 2023
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Jan 9, 2023
Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Python Extreme Learning Machine (ELM) Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Augusto Almeida 84 Nov 25, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 23.6k Jan 3, 2023
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques

Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

Vowpal Wabbit 8.1k Dec 30, 2022
CD) in machine learning projectsImplementing continuous integration & delivery (CI/CD) in machine learning projects

CML with cloud compute This repository contains a sample project using CML with Terraform (via the cml-runner function) to launch an AWS EC2 instance

Iterative 19 Oct 3, 2022
🔬 A curated list of awesome machine learning strategies & tools in financial market.

?? A curated list of awesome machine learning strategies & tools in financial market.

GeorgeZou 1.6k Dec 30, 2022
Model Validation Toolkit is a collection of tools to assist with validating machine learning models prior to deploying them to production and monitoring them after deployment to production.

Model Validation Toolkit is a collection of tools to assist with validating machine learning models prior to deploying them to production and monitoring them after deployment to production.

FINRA 25 Dec 28, 2022
Covid-polygraph - a set of Machine Learning-driven fact-checking tools

Covid-polygraph, a set of Machine Learning-driven fact-checking tools that aim to address the issue of misleading information related to COVID-19.

null 1 Apr 22, 2022
MIT-Machine Learning with Python–From Linear Models to Deep Learning

MIT-Machine Learning with Python–From Linear Models to Deep Learning | One of the 5 courses in MIT MicroMasters in Statistics & Data Science Welcome t

null 2 Aug 23, 2022