Build Naive Bayes spam classifier with F1

Quick Overview

This question evaluates understanding of probabilistic text classification with Naive Bayes, text preprocessing and feature extraction, and use of the F1 score for performance measurement in a binary spam detection task.

Build Naive Bayes spam classifier with F1

Company: Disney

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

You are given a text classification dataset for **spam detection** (binary labels: `spam` vs `not_spam`) in a Jupyter notebook environment. ### Task 1. Preprocess the text (basic cleaning/tokenization is sufficient). 2. Convert text to features suitable for Naive Bayes (e.g., bag-of-words or TF-IDF). 3. Train a **Naive Bayes** classifier. 4. Evaluate the model using **F1 score** (clearly state whether it is the F1 for the positive class or a specific averaging scheme). 5. Run the trained model on a few test examples and show predicted labels (and optionally probabilities). ### Constraints / Notes - The dataset may be class-imbalanced. - You should avoid data leakage (fit text vectorizer only on training data). - You may choose reasonable train/validation splitting if only one labeled set is provided.

Overview: This question evaluates understanding of probabilistic text classification with Naive Bayes, text preprocessing and feature extraction, and use of the F1 score for performance measurement in a binary spam detection task.

|Home/Machine Learning/Disney
Disney logo
Disney
Nov 1, 2025
mediumMachine Learning EngineerTechnical ScreenMachine Learning
6
0

You are given a text classification dataset for spam detection (binary labels: spam vs not_spam) in a Jupyter notebook environment.

Task

  1. Preprocess the text (basic cleaning/tokenization is sufficient).
  2. Convert text to features suitable for Naive Bayes (e.g., bag-of-words or TF-IDF).
  3. Train a Naive Bayes classifier.
  4. Evaluate the model using F1 score (clearly state whether it is the F1 for the positive class or a specific averaging scheme).
  5. Run the trained model on a few test examples and show predicted labels (and optionally probabilities).

Constraints / Notes

  • The dataset may be class-imbalanced.
  • You should avoid data leakage (fit text vectorizer only on training data).
  • You may choose reasonable train/validation splitting if only one labeled set is provided.
Loading comments...