A multilayer perceptron on tabular data (and why it usually loses to boosting), text as features — TF-IDF, sentence embeddings, zero-shot LLM labels — and the AI-assisted analyst's workflow: generate, verify, own
By the end of tonight you'll have both the concept and the working code — every objective maps to a cell you run yourself.
MLPClassifier on Telco: layers, activations, epochs, and the honest result — on a 7,000-row table it ties logistic regression and loses to boosting. Neural nets earn their keep on text, images, and sequences.
TF-IDF (counts), sentence embeddings (meaning), and zero-shot LLM labels (judgment). Same reviews, three feature sets, three price points — and a clear winner for each budget.
Embed the free-text column, append it to the structured features, and let gradient boosting use both. The 2025 evidence: biggest gains on small, imbalanced, or text-rich problems.
Colab's Data Science Agent, Jupyter AI, Claude Code: generate the boilerplate, then verify the split, the leakage, and the metric yourself. The analyst who can't explain the cell didn't write it.
A business question, a dataset, a model — and the judgment to evaluate it.
Where every project stands after Milestone 3, then the model everyone has heard of: layers of weighted sums and nonlinear activations, trained by gradient descent on a loss. A logistic regression is a neural network with no hidden layer. MLPClassifier makes it three lines.
MLPClassifier on the Telco pipeline: AUC within a point of logistic regression, below the boosted model, three times slower to tune. This is the Grinsztajn result on a business table. Then where neural nets win: text, images, audio, sequences — anything without a fixed set of columns.
Meet the data: Amazon product reviews, binary sentiment. TfidfVectorizer + logistic regression is a 30-second baseline that reaches ~88% accuracy. A sentence-transformer (all-MiniLM-L6-v2) turns each review into a 384-number vector that captures meaning, not just words — and a logistic regression on those vectors does about as well with a fraction of the features.
Stretch, coffee, last project questions.
Ask an LLM to label 200 reviews with no training data: accuracy near the trained models, at a cost per call. Then the practical pattern: embed the free-text 'reason for contact' column in a churn table, append it to the structured features, and let boosting use both. The evidence says this helps most when the table is small or the text carries what the columns don't.
Live: Colab's Data Science Agent builds a churn notebook from a prompt in two minutes. We read it together and find what it got wrong — the split after the scaler, the leaked column, the metric it chose. Then the workflow that works: let the assistant draft, verify the four things that matter, and be able to explain every cell in the presentation.
Teams pair up: four minutes each with the Milestone 4 slides, two minutes of feedback on the one thing to fix. Then the map is complete: tabular → boosting and TFMs; text → embeddings and LLMs; time → lags and foundation models; everything → honest validation and a decision. Next Monday: ship it, then present.
Notebooks, readings, explorers, and the stories behind the methods.
MLPClassifier vs. boosting on Telco, TF-IDF vs. sentence embeddings on Amazon reviews, an optional zero-shot Claude cell, embeddings appended to a tabular model, and a checklist for verifying AI-generated notebooks.
Open in ColabThe best visual explanation of what a neural network computes and how gradient descent trains it. Watch the first two before class; the transformer episodes explain what powers the embedding models.
Open the playlistSentenceTransformer('all-MiniLM-L6-v2').encode(texts) — one line from text to a 384-dimensional meaning vector. The pretrained models page lists the speed/quality trade-offs.
Open the docs3.6 million Amazon reviews labeled positive/negative. We use a 5,000-review slice; the datasets library streams it with no login.
Open the dataset cardTrain a small neural network in your browser: add layers and neurons, change the activation, and watch the decision boundary bend. Ten minutes here and "hidden layer" stops being abstract.
Open the explainerForward pass, loss, backpropagation — as an interactive essay you can scroll through before class.
Open the explainerGoogle's former Chief Decision Scientist's beloved conceptual course, free on YouTube: what ML is for, how projects fail, and how to think like a decision-maker. Six hours; watch the first hour before the project.
Watch on YouTubeLLMTabBench: LLMs are competitive zero-shot on low-data binary tasks but degrade past a complexity threshold, and few-shot examples can hurt. Pair with the 2022 tree-vs-NN benchmark for the full picture.
Read the abstractEmbedding text fields and feeding them to XGBoost/CatBoost helps most on small, imbalanced, or text-rich datasets, and embedding-derived features often rank high in importance. The pattern we implement in class.
Read the paperUpload a CSV, describe the goal, get a full notebook. Free in Colab. We use it live and then audit what it produced — the exercise that defines the AI-assisted analyst.
Read the announcementA practical walkthrough of using an agentic coding assistant on notebooks and data pipelines, including the verification habits that keep it honest.
Read the guideThe PyTorch edition of the practitioner's classic. Chapters 10–11 (introduction to neural networks, training deep nets) are the natural continuation if you want to go deeper than MLPClassifier.
Open the notebooksOpen the notebook and build it with us.
5,000 Amazon reviews, positive or negative. Build TF-IDF + logistic regression, then sentence-embeddings + logistic regression, compare accuracy and feature counts, and (optionally) ask an LLM to label 100 of them zero-shot.
datasets.load_dataset('fancyzhx/amazon_polarity', split='train[:5000]'). Stratified 80/20 split on the label.
TfidfVectorizer(ngram_range=(1,2), min_df=3) → LogisticRegression. Accuracy, and the ten most positive and negative n-grams from the coefficients.
SentenceTransformer('all-MiniLM-L6-v2').encode() on the same texts → 384 features → LogisticRegression. Accuracy vs. TF-IDF; note the feature count.
With an API key, ask Claude to label 100 test reviews 'positive' or 'negative'. Accuracy vs. the two trained models, and the cost per 1,000 reviews.
from datasets import load_dataset
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sentence_transformers import SentenceTransformer
ds = load_dataset('fancyzhx/amazon_polarity', split='train[:5000]')
texts, labels = ds['content'], ds['label']
X_tr, X_te, y_tr, y_te = train_test_split(texts, labels, test_size=0.2, stratify=labels, random_state=835)
# 1) Counts: TF-IDF
tfidf = TfidfVectorizer(ngram_range=(1, 2), min_df=3, sublinear_tf=True)
clf = LogisticRegression(max_iter=2000, C=3).fit(tfidf.fit_transform(X_tr), y_tr)
print(f'TF-IDF + logistic: {accuracy_score(y_te, clf.predict(tfidf.transform(X_te))):.3f} ({len(tfidf.vocabulary_):,} features)')
# 2) Meaning: sentence embeddings (downloads a 90MB model once)
enc = SentenceTransformer('all-MiniLM-L6-v2')
E_tr, E_te = enc.encode(X_tr, batch_size=128, show_progress_bar=False), enc.encode(X_te, batch_size=128, show_progress_bar=False)
clf2 = LogisticRegression(max_iter=2000).fit(E_tr, y_tr)
print(f'embeddings + logistic: {accuracy_score(y_te, clf2.predict(E_te)):.3f} ({E_tr.shape[1]} features)')
# 3) Judgment: zero-shot LLM labels — optional, needs ANTHROPIC_API_KEY; see the notebook Three feature sets, three price points. TF-IDF is free and you can read its coefficients — 'waste of money' and 'highly recommend' sit at the two extremes. Embeddings cost one model download and capture meaning TF-IDF cannot ('not bad at all'). The LLM costs a call per review and needs no training data at all — the right tool for the first week of a project, the wrong tool for scoring a million reviews a day. The 2026 analyst picks by budget and volume, and usually ends up with embeddings feeding a model they can validate.
A neural network is stacked weighted sums with nonlinearities, trained by gradient descent. On a business table it rarely beats boosting; it wins on text, images, and sequences — anything without fixed columns.
Text becomes features three ways: TF-IDF (counts, interpretable), sentence embeddings (meaning, transferable), zero-shot LLM labels (judgment, per-call cost). Embeddings appended to a tabular model are the practical 2026 pattern.
Generate, verify, own. Let an AI assistant draft the notebook, then check the split, the leakage, the metric, and the baseline yourself — and be able to explain every cell without it.
Complete these before next Monday — they are the practice that makes the next session land.
Exam-style questions for the ideas in this session — Trees, Forests & Boosting and The Prediction Lifecycle. Every wrong answer names the misconception behind it.
Persist the pipeline, track experiments with MLflow, put a Gradio front end on a model in ten lines, watch for drift with Evidently, and the one-slide guide to the EU AI Act — then your presentations and the Signal Award.