Visualize Scikit Models

Visualize your scikit-learn model's performance with just a few lines of code. Made by Lavanya Shukla using Weights & Biases
Lavanya Shukla

Introduction

In this report, I'll show you how to visualize your scikit-learn model's performance with just a few lines of code. We’ll also explore how each of these plots help us understand our model better.

Creating these plots is simple.

Step 1: Import wandb and initialize a new run.

import wandb
wandb.init(project="visualize-sklearn")

Step 2: Visualize individual plots.

# Visualize single plot
wandb.sklearn.plot_confusion_matrix(y_true, y_probas, labels)

Or visualize all plots at once:

# Visualize all the plots in the Classification section below with one line of code
wandb.sklearn.plot_classifier(clf, X_train, X_test, y_train, y_test, y_pred, y_probas, labels,
                                                         model_name='SVC', feature_names=None)

# Visualize all the plots in the Regression section below with one line of code
wandb.sklearn.plot_regressor(reg, X_train, X_test, y_train, y_test,  model_name='Ridge')

# Visualize all the plots in the Clustering section below with one line of code
wandb.sklearn.plot_clusterer(kmeans, X_train, cluster_labels, labels=None, model_name='KMeans')

Try an example →

If you have any questions, we'd love to answer them in our slack community.

Classification

The Dataset

In this report, I trained several models on the Titanic dataset, which describes the passengers aboard the Titanic. Our goal is to predict whether the passenger survived or not.

Clustering

Regression