Stop Using PowerPoint for Your ML Presentations and Try This Instead | by Matt Chapman | Jul, 2023

Gradio is a surefire way to impress both technical and non-technical stakeholders — Why aren’t more Data Scientists and MLEs using it?

Image by Will Porada on Unsplash

PowerPoint presentations suck.

At least, bad ones do.

Bad PowerPoints create distracted audiences (who turn off their cameras and multitask), and they make it easy for presenters to get away with bad habits like using too much technical jargon and waffling on for too long.

So why do Data Scientists use PowerPoint so much?

On a recent Reddit thread on this topic, respondents working in DS reported spending anywhere between 10–60% of their time making slide decks or giving presentations. I realise that’s not a very robust statistic, but regardless of the true distribution, the sentiment chimes true for many of us working in Data Science: we use PowerPoint – A LOT – to showcase everything from model cards to screenshots of ROC curves and Shapley values.

Like it or not, PowerPoint is a big part of modern Machine Learning stacks, and it’s not going anywhere.

Or is it?

In this article, I’m going to introduce you to Gradio, a free tool which lets you:

  1. Visualise ML models via your browser or Jupyter Notebook
  2. Impress your non-technical stakeholders via interactive, easy-to-understand visualisations
  3. Test your models and identify weaknesses and feature importances

I have no affiliation with Gradio and I’m not trying to sell you anything — I simply want to show you a tool which has worked well for me in my job as a Data Scientist, ESPECIALLY for models that use tabular data, like XGBoost.

In the developers’ own words,

Gradio is the fastest way to demo your machine learning model with a friendly web interface so that anyone can use it, anywhere!

How does this work? It’s surprisingly simple.

First, install Gradio via pip.

pip install gradio

Next, import Gradio and define a function that can take an input. Then, wrap your model in a ‘gradio.Interace()’ class, and – hey presto – your model is given a friendly, interactive interface which can be embedded in a notebook or webpage. Here’s an example using a very simple “Hello {user}!” function:

import gradio as gr

def greet(name):
return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")


Image by author

If you run that in a Jupyter Notebook, the demo above will appear automatically in a new cell. If you run it in a script, the demo will appear in your browser at http://localhost:7860. If you like, you can also “automatically generate a public link you can share with colleagues that lets them interact with the model on your computer remotely from their own devices” (docs).

To take a slightly more complex example, let’s say we had an ML model which could recognise hand-drawn images. Using Gradio, we could create a sketch pad which accepts user input…

import gradio as gr
def sketch_recognition(img):
pass# Implement your sketch recognition model here...

gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs="label").launch()

… giving us a nifty way to draw sketches, pass them to the model, and demo the model in live-time:

Image by author

Note: to keep this article to a manageable length, I’m not including details on the model itself; if you’re looking for models, you might want to check out HuggingFace, a great repository of pre-trained models which can be easily loaded into a Jupyter notebook or Python script and used with Gradio.

With just a few lines of code, Gradio makes it easy to showcase your models in an interactive way that anyone can understand. Think about the possibilities in your team – how much easier could this make it to showcase your models to your team or stakeholders?

Source link

Leave a Comment