Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Lesson 9 — Decision Trees + Text-as-Data (NLP) + Ethical Implications

(model reasoning, evaluation, bias risks, and careful interpretation)

Why this matters (motivation)

Decision trees and text analytics are both popular in real-world analytics:

But both can go wrong:


Part A — Decision trees (intuition-first)

What is a decision tree?

A decision tree is a flowchart-like model that repeatedly splits the data into smaller groups to make predictions.

Trees are supervised learning

We focus mainly on classification today, because it fits many business decisions.


How trees choose splits (high-level)

Trees try many candidate split points and choose the one that improves “purity” of outcomes.


Overfitting (why trees are fragile)

Trees can keep splitting until they effectively memorize the training data.

Symptoms:

Controls (practical knobs):


Evaluation: what we emphasize in this course

Confusion matrix and error costs

For binary classification (e.g., churn yes/no):

In business, FP vs FN have different costs:

We will keep this light and interpretable.


Interpretation: reading tree rules as business logic

One advantage of trees is the ability to explain decision paths:

But interpretation must be cautious:


Part B — Text as data (NLP) (practical and cautious)

Why text matters in business/economics

Text appears everywhere:

Text is rich but messy. We need a simple workflow to extract signals.

Today’s focus: sentiment analysis (simple signal, not truth)

Sentiment tools label text as positive/negative/neutral.

Useful for:

Weak for:


Part C — Ethical implications (trees + text)

Ethical risk is not an “extra topic”—it is embedded in the pipeline.

Where bias enters (structured data)

  1. Target label (what is “good/bad”?)

  2. Features (proxy variables for sensitive attributes)

  3. Sampling (who is represented?)

  4. Measurement (errors differ across groups)

  5. Objective (optimize accuracy only → harms minority groups)

Examples:

Where bias enters (text)

A simple “responsible presentation” checklist (course version)

When presenting model results, include:

  1. What the model is for (decision context)

  2. Performance summary (and what errors mean)

  3. At least one limitation (data, measurement, generalization)

  4. At least one fairness/ethics caveat (proxy risk, group disparity risk, monitoring need)

  5. A statement about human oversight (not fully automated decisions in high-stakes contexts)


Mini case 1: churn prediction with a tree (rules + evaluation)

Question: “Can we identify at-risk customers using simple, explainable rules?”

Workflow:

  1. Choose outcome (churn yes/no)

  2. Fit baseline tree

  3. Evaluate on test set and interpret errors

  4. Extract 2–3 decision rules and assess plausibility

  5. Identify proxy risk and propose monitoring


Mini case 2: review sentiment (text signal + error analysis)

Question: “What complaints are most negative, and what are we missing?”

Workflow:

  1. Compute sentiment scores for reviews

  2. Compare distributions by product category

  3. Inspect examples:

    • top 5 most negative

    • 5 that look wrongly labeled

  4. Write one limitation and propose a validation step


Mini-lab (Google Colab)

In-class checkpoints (Decision tree)

  1. Choose a classification outcome (e.g., churn yes/no) and 5–10 predictors.

  2. Split data into train/test (and optionally a validation split).

  3. Train a baseline decision tree.

  4. Control complexity:

    • try at least two settings (e.g., max_depth or min_samples_leaf)

    • compare train vs test results

  5. Report:

    • confusion matrix

    • precision/recall (or F1)

  6. Interpret:

    • extract at least two decision paths or rules

    • explain them in plain language (“If … then …”)

  7. Short reflection:

    • what kind of mistake is more costly here (FP or FN)? why?

In-class checkpoints (Text-as-data / sentiment)

  1. Load a small dataset of text reviews (provided).

  2. Preprocess text (light):

    • lowercase

    • remove obvious punctuation

  3. Compute sentiment:

  1. Error analysis:

  1. Optional extension:

In-class checkpoints (Ethics)

  1. Identify at least one potential proxy feature risk in your tree model.

  2. Identify at least one bias risk in your text workflow (language, sampling, domain mismatch).

  3. Write a short “responsible use note”:

Submission (after class)


AI check (responsible use)

Good prompt examples

Bad prompt examples


Review questions (quiz / reflection)

  1. Why do decision trees often overfit, and what are two ways to reduce overfitting?

  2. Why can accuracy be misleading in imbalanced classification problems?

  3. Give two reasons sentiment analysis might fail on business/econ text.

  4. Name one point in the pipeline where bias can enter, and one monitoring step you would propose.