Add two tabular PyTorch examples: bank fraud detection + ads CTR reco…#255
Merged
Conversation
…mmendation
Both live under weightslab/examples/PyTorch/ and follow the existing
wl-classification pattern (main.py + config.yaml + utils/{data,model}.py +
README.md + requirements.txt), wired into the wl.watch_or_edit/serve flow.
Tabular data pairs naturally with the List Exploration (tabular) view.
wl-fraud-detection: MLP binary classifier over 16 synthetic bank
card-transaction features (~12% fraud). README points to real drop-in
datasets (Kaggle Credit Card Fraud / PaySim).
wl-ads-recommendation: Wide & Deep CTR model (8 embedded categorical fields +
8 numeric) predicting click-through at a calibrated ~20% CTR. README points to
Criteo / Avazu / MovieLens.
Datasets/models are pure-PyTorch (numpy+torch only, no weightslab import) so
each ships an offline pytest smoke suite (8 tests each, all passing): shapes,
determinism, class balance, forward pass, and that training reduces loss —
fraud reaches >90% accuracy; ads learns to rank clicks (held-out rank-AUC >0.6).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ify e2e
Samples in these examples are rows (transactions / ad impressions), not images.
Expose every feature as a real, sortable per-sample column so interacting with
Weights Studio works exactly like MNIST classification (sort, lock, histograms,
discard, neuron ops — all driven by the ledger, not pixels).
- Datasets now implement the WeightsLab ledger-init contract
get_items(idx, include_metadata, include_labels, include_images) returning
(image, uid, target, metadata); the metadata dict flattens into columns.
Fraud surfaces the 16 raw (human-readable) transaction features; ads surfaces
the 8 categorical fields as readable labels + 8 numeric features.
- main.py sets preload_metadata=True so the columns load at init.
- Fraud generator now returns standardized (model) + raw (display) features.
Added verify_integration.py to each example: drives the real WeightsLab stack
(tracked loaders, watched loss/metric, gRPC server, per-sample ledger), then
asserts the sample dataframe the UI reads has per-sample rows, every feature as
a column, target/prediction/loss, and a live gRPC endpoint.
Verified locally:
fraud -> 800 rows, 16 feature cols + target/prediction/prediction_raw/
discarded + signals//{train,test}-loss-CE; gRPC listening -> PASS
ads -> 1000 rows, 16 field cols (+readable categoricals) + target/
prediction + loss signals; gRPC listening -> PASS
Unit suites: fraud 9 passed, ads 10 passed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously a tabular sample had to be faked as a small image; the model was fed
a reshaped 4x4 and the real feature values never reached the UI (the grid path
WebP-compresses to uint8). Now the feature vector IS the model input and its
actual values flow through gRPC to the UI.
weightslab core:
- data_image_utils: looks_like_tabular() + render_tabular_heatmap() +
build_tabular_raw_data_stat() — emits raw_data as type 'vector' carrying the
exact values (DataStat.value, shape=[N]) plus a heatmap thumbnail for display.
- data_utils.load_raw_image_array: 1-D inputs no longer crash the image path;
they return the vector + a heatmap PIL.
- data_service: both the preview-cache and full-res record builders emit the
vector raw_data stat for tabular inputs instead of an image.
examples (fraud + ads): __getitem__/get_items now feed the flat feature vector
(no fake 4x4); model input_shape updated; unit tests updated for the new shape.
verify_integration.py (both examples) now also does a real gRPC GetDataSamples
round-trip and asserts raw_data.type == 'vector' with N feature values.
Verified end-to-end (PYTHONPATH=worktree):
fraud -> raw_data type='vector', 16 values reach UI over gRPC; 800 rows;
feature columns + target/prediction/loss -> VERIFY PASSED
ads -> raw_data type='vector', 16 values; 1000 rows -> VERIFY PASSED
unit: fraud 9 passed, ads 10 passed.
Note: the value transport (inputs+labels+metadata) reaches the UI; rendering a
'vector' raw_data cell in the grid is a weights_studio follow-up (the List
Exploration view already shows the feature columns).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…usecases - Add an examples gallery (weightslab/examples/README.md) with cards for every runnable example: folder link, run command, and a one-click Colab badge. The new Tabular section features Bank Fraud Detection and Advertising CTR Recommendation, plus a "how tabular works" explainer. - Add self-contained Colab notebooks (Notebooks/PyTorch/ws-fraud-detection.ipynb and ws-ads-recommendation.ipynb) in the same format as the other ws-* notebooks (Open In Colab badge, install, inline dataset+model, wl wiring, serve+bore, live-curation section). Validated with nbformat; the inlined data/model code runs (fraud loss 0.59->0.00, ads 1.09->0.00; 16 feature columns each). - Cross-link the notebooks from each folder README (Colab badge) and point the root README quickstart at the gallery. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Tabular examples to WeightsLab: