liveBook · Manning

Preprocessing

As explained in Ensemble Methods for Machine Learning

Preprocessing is the transformation of raw data into a representation suitable for machine-learning algorithms.

Preprocessing turns raw data into a representation that learning algorithms can use. For text, it converts free-form reviews into structured features; for numeric data, it can place features on comparable scales. section 3.4.1 section 7.2

A practical preprocessing workflow can include:

  • Clean text by removing special symbols, then tokenize it into words. section 3.4.1
  • Use lemmatization to treat related word forms such as organize, organizes, and organizing as the same word. section 3.4.1
  • Build a bag-of-words term-document matrix whose rows represent examples and columns represent word features. section 3.4.1
  • Remove selected stop words or transform counts into TF-IDF features when the representation benefits from reduced or reweighted vocabulary. section 3.4.1
  • Encode categorical values because most machine-learning algorithms require numeric inputs, and standardize numeric features when scale differences matter. section 8.0 section 7.2

From review text to features

The sentence “this is a terrible terrible movie” becomes a count vector over a vocabulary such as {this, is, a, brilliant, terrible, movie}. The count for “terrible” is 2, while “brilliant” is 0. A larger review corpus can then be filtered, transformed with TF-IDF, and saved for modeling. section 3.4.1

Standardizing AutoMPG

For AutoMPG regression, engine-related features are split into training and test data, fitted with StandardScaler on the training data, and transformed before learning. section 7.2

How Ensemble Methods for Machine Learning covers it

How deep it goes
Walks through cleaning, tokenization, lemmatization, vectorization, vocabulary filtering, TF-IDF, encoding, and standardization with implementation examples.
Examples
Uses movie reviews, a term-document matrix, TF-IDF extraction, categorical variables, and the AutoMPG regression data set.
What it assumes
Assumes familiarity with features, labels, training data, and learning algorithms while explaining why categorical values need encoding.
What you can do after
Apply it via NLTK and scikit-learn to clean, encode, vectorize, reweight, and standardize data before training.
How it connects
Connects tokenization, lemmatization, bag-of-words, TF-IDF, stop-word removal, categorical encoding, and standardization.

Also explained in

Compare how 22 books explain preprocessing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.