Skip to main content

Machine learning dashboard that integrates with tensorflow. Great for monitoring training. Has tools for classification and images

Project description

MLDashboard

Tests Badge Python Version Badge License Badge

Image

Monitoring solution for tensorflow training. Particulary useful for image classification models. Not compatible with google colab or other notebook based runtimes.

Getting Started

This guide assumes you already understand python and tensorflow.

Installation

pip install MLDashboard

Examples

See Examples for usage.

Quick Start

To start, you need a dashboard.json config file. This should be in the same directory as your script. Here is an example:

{
    "modules":[
        [
            ["LossMetricsGraph", {}],
            ["LossMetricsNumerical", {}]
        ],
        [
            ["StatusModule",{}],
            ["EmptyModule", {}]
        ]
    ]
}

NOTE: All code in this demo should be protected by

if __name__ == '__main__':

to prevent multiprocessing conflicts.

The dashboard can easily by added to an existing machine learning project. Import the dashboard as shown.

from MLDashboard.MLDashboardBackend import createDashboard
from MLDashboard.MLCallbacksBackend import DashboardCallbacks, CallbackConfig
from MLDashboard.MLCommunicationBackend import Message, MessageMode

Before training starts, create the dashboard.

#MAKE SURE YOU HAVE A DASHBOARD.JSON FILE IN THE SAME DIRECTORY AS YOUR SCRIPT
dashboardProcess, updatelist, returnlist = createDashboard(config='dashboard.json')

Connect the callbacks to your training.

config = CallbackConfig()
labels = list(range(0,10)) #labels should be customized for the data. This is for mnist number recognition
callback = DashboardCallbacks(updatelist, returnlist, model, x_train, y_train, x_test, y_test, labels, config)

model.fit(x_train, y_train, epochs=10, callbacks=[callback])

After training ends, you can send evaluation stats to the dashboard.

model.evaluate(x_test, y_test, batch_size=128, callbacks=[callback])

To exit the dashboard cleanly, use the following code:

updatelist.append(Message(MessageMode.End, {}))
print("Exiting cleanly...")
dashboardProcess.join()
print("Dashboard exited.")
#This handles any extra data that the dashboard sent, such as save commands
callback.HandleRemaingCommands()

Here is a full example with python code:

import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2' #stops agressive error message printing
import tensorflow as tf
from tensorflow import keras
from MLDashboard.MLDashboardBackend import createDashboard
from MLDashboard.MLCallbacksBackend import DashboardCallbacks, CallbackConfig
from MLDashboard.MLCommunicationBackend import Message, MessageMode

def run():
    print("Starting interactive dashboard demo...")
    print("Setting up dashboard...")

    #Create dashboard and return communication tools (this starts the process)
    #MAKE SURE YOU HAVE A DASHBOARD.JSON FILE IN THE SAME DIRECTORY AS YOUR SCRIPT
    dashboardProcess, updatelist, returnlist = createDashboard(config='dashboard.json')

    print("Loading data...")
    (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

    print("Formatting data...")
    x_train = x_train.reshape(-1, 784).astype("float32") / 255.0
    x_test = x_test.reshape(-1, 784).astype("float32") / 255.0

    print("Sampling data...")
    # Limit the train data to 10000 samples
    x_train = x_train[:10000]
    y_train = y_train[:10000]
    # Limit test data to 1000 samples
    x_test = x_test[:1000]
    y_test = y_test[:1000]

    print("Creating model...")
    model = keras.Sequential([keras.layers.Dense(128, activation='relu'), keras.layers.Dense(10)])

    model.compile(optimizer='adam', metrics=["accuracy"], 
                  loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True))


    print("Creating callbacks...")
    #Callbacks require update and return list for communicating with dashboard
    #Model and datasets are useful for sending that data to certain modules
    config = CallbackConfig()
    labels = list(range(0,10))
    callback = DashboardCallbacks(updatelist, returnlist, model, x_train, y_train, x_test, y_test, labels, config)

    model.fit(x_train, y_train, epochs=50, callbacks=[callback])

    print("Evaluating model...")
    #This is connected to the callback so the data is sent to the dashboard
    model.evaluate(x_test, y_test, batch_size=128, callbacks=[callback])

    updatelist.append(Message(MessageMode.End, {}))
    print("Exiting cleanly...")
    dashboardProcess.join()
    print("Dashboard exited.")
    #This handles any extra data that the dashboard sent, such as save commands
    callback.HandleRemaingCommands()

if __name__ == '__main__':
    run()

Other guides:

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

mldashboard-1.4.5.tar.gz (71.2 kB view details)

Uploaded Source

Built Distribution

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

mldashboard-1.4.5-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file mldashboard-1.4.5.tar.gz.

File metadata

  • Download URL: mldashboard-1.4.5.tar.gz
  • Upload date:
  • Size: 71.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mldashboard-1.4.5.tar.gz
Algorithm Hash digest
SHA256 f3d5933d181fa868728307999057fb9494d191848271edcfbddaf37dcd36a999
MD5 c244f5704d55c3dc39eb24fee3d240e3
BLAKE2b-256 2e11b6ff94d86e216a7d596424ecd8ede406224a268a6bbe679a15da0c3b1f4e

See more details on using hashes here.

File details

Details for the file mldashboard-1.4.5-py3-none-any.whl.

File metadata

  • Download URL: mldashboard-1.4.5-py3-none-any.whl
  • Upload date:
  • Size: 77.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mldashboard-1.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2afbb86d2db2bfc77813203db74bf5794137475bae0febb7a6a245ea88a313ff
MD5 bec5db15f5c2840641c5dd5211157e22
BLAKE2b-256 9a11986c508344f40e038014a632691313837e5f8ddfbf59850d4f14372a667a

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