The scikit-learn workbench

Pyodide, preloaded np, pd, and plt, files, joblib, and privacy.

The scikit-learn app is a Python editor that runs in WebAssembly (Pyodide). When the status line says scikit-learn is ready, these names already exist:

  • np — NumPy
  • pd — pandas
  • plt — matplotlib.pyplot

You still write from sklearn… imports. sklearn is loaded; the short names are not.

Goal

Know how Run, print, plt.show(), files, Reset, and joblib.dump work before a blank console surprises you.

Run code

Paste into the editor and press Ctrl+Enter (Windows/Linux) or Cmd+Enter (macOS). The console is stdout. The Plot panel is for figures.

import sklearn
from sklearn.linear_model import LogisticRegression

print("sklearn", sklearn.__version__)
print(LogisticRegression)

A tiny fit

from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression

X, y = make_classification(n_samples=80, n_features=4, random_state=0)
clf = LogisticRegression(max_iter=200)
clf.fit(X, y)
print("classes", clf.classes_)
print("predict first 5", clf.predict(X[:5]))

A bare clf at the end of the script is not displayed the way Jupyter would. print it.

Files live in /uploads

Click Add files and choose a CSV. After that:

import os

print(os.listdir("/uploads"))

Readable paths: kiosk.csv or /uploads/kiosk.csv.

Writes become download chips

import os
import joblib
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification

X, y = make_classification(n_samples=40, n_features=4, random_state=0)
clf = LogisticRegression(max_iter=200)
clf.fit(X, y)
joblib.dump(clf, "model.joblib")
print("uploads:", os.listdir("/uploads"))

After Run, click on the file chip. Nothing is uploaded to Swiftener’s servers.

Privacy

Python runs in this tab. Uploads live in IndexedDB on this device. Lesson pages are public HTML; they never see your models.

Pitfall

Do not call fetch_openml or download CSVs from the internet — this editor has no outbound HTTP for datasets. Use make_classification, make_blobs, load_iris (bundled), or attach a banner CSV.