Skip to content
Harshith Varma
All writing

Data Science

End To End Machine Learning Project — Part I

2024-06-25 · 10 min read

Most machine learning tutorials stop at a trained model in a notebook. An end-to-end project is different: it's the complete workflow of developing and deploying a model, from problem definition through to something that keeps running after the notebook is closed.

This is Part I of a series built around one real project — a Toxic Comment Detection system — and it covers the notebook phase: getting from raw, messy comment data to a model worth deploying.

Why build the whole pipeline, not just the model

Treating "the model" as the whole project is a common shortcut, and it skips the parts that make a project actually usable:

  • It gives comprehensive coverage of the entire ML lifecycle, not just the modeling step.
  • It builds the technical and project-management skills that a single notebook doesn't exercise.
  • It results in something deployable — a solution that keeps running, not a one-off script.
  • It strengthens a portfolio with proof of shipped work, not just experiments.
  • It forces the model to stay aligned with the actual problem it's meant to solve.

The data problem: imbalance

Toxic comments are, thankfully, the minority class in most real datasets — which is exactly what makes them hard to detect. A classifier trained naively on imbalanced data learns to predict "not toxic" and still scores well on accuracy while being useless in practice.

The dataset here combines sources from Kaggle and YouTube comment data, and the imbalance is corrected with SMOTE (Synthetic Minority Over-sampling Technique) — generating synthetic examples of the minority class rather than simply duplicating or discarding data.

From text to features

Raw comment text isn't something a neural network can consume directly. TF-IDF (term frequency–inverse document frequency) turns each comment into a weighted vector of the terms that actually distinguish it, ahead of anything getting near a model.

The model

A custom neural network, built with TensorFlow/Keras, is trained on the balanced, vectorized data and reaches 98.01% accuracy on the classification task. The trained model is serialized at the end of this phase — ready for the deployment work that the next part in this series picks up.


This is Part I of the Toxic Comment Detection series — the notebook phase. Later parts cover the deployment and monitoring stages that turn this into a running system.

Originally published on Medium

2024-06-25

Read on Medium (opens in a new tab)

Continue reading

All writing