liveBook · Manning

Feature engineering

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Feature processing is the transformation or elaboration of input features to make them suitable or more informative for machine learning models.

Feature engineering transforms, extracts, combines, or elaborates raw inputs so a machine-learning model receives information in a useful form. It selects signal from noise, adapts data to model requirements, can expose nonlinear relationships, and embeds domain knowledge. In tabular modeling, this work is often central to predictive performance and generalization. section 1.3

The process is guided by a business hypothesis, the target, and exploratory analysis—not by arbitrary feature combinations. Inspect predictors and outcomes for outliers, extreme values, missing data, and other peculiarities; then decide which records or variables warrant adjustment, exclusion, or transformation. Keep validation and the eventual model pipeline in view, since models handle data types differently. section 7.1 section 7.4

Common feature-engineering moves include:

  • Extract structured fields from text, such as accommodation type, area, star rating, and counts of bedrooms, beds, and baths. section 7.1.2
  • Create Boolean indicators from meaningful terms, such as whether a listing is new, a studio, or has a shared or half bath. section 7.1.2
  • Derive time and ratio features, such as days since last review and recent reviews relative to total reviews. section 7.1.2
  • Aggregate related records to construct a target or feature, such as mean, minimum, and maximum adjusted price per listing. section 7.1.2
  • Encode location through geographic bins, distance from a city center, or distance to nearby facilities and transportation. section 7.1.3
  • Apply advanced processing when appropriate, including multivariate missing-value imputation, target encoding, feature reduction, and target-guided transformations. section 6.0

Airbnb price prediction

For Tokyo listings, text descriptions can yield structured property attributes, while calendar records can be aggregated into an effective-market-price target. Location hypotheses then motivate geographic cells, distance from the Imperial Palace, and nearest convenience-store, train-station, airport, bus-station, or subway distances. These features make location-related differences available to a predictive model. section 7.1.2 section 7.1.3

Table 7.1 Regex commands for feature engineering (view table figure)

Matched description

Regex

Resulting feature

Text that starts with “in,” followed by a space, then captures any characters until another space, and ends with a dot

r'in\s(.*?)\s·'

Area of Tokyo of the listing

Text that starts with the character “★” (a star), followed by one or more digits, a dot, and one or more additional digits (e.g., ★4.5)

r'★(\d+\.\d+)'

Star ratings

Text containing a numerical value followed by zero or more whitespace characters and the words “bedroom” or “bedrooms” (with or without the “s” at the end)

r'(\d+)\s*(?:bedroom|bedrooms)'

Number of bedrooms

Text containing a numerical value followed by one or more whitespace characters and the word “bed” or “beds” as a whole word (with or without the “s” at the end)

r'(\d+)\s+(?:beds?\b)'

Number of beds

Text containing a numerical value representing the number of baths

r'(?P<baths>\d+)\s*(shared\s+)?(?:half-)?baths?\b'

Number of baths

Use the regex table to connect repeated listing-description patterns with the fields they produce, then adapt the patterns to similarly formatted text. section 7.1.2

Feature engineering differs from representation learning. Classical machine learning depends on deliberate transformations tailored to the data and domain, whereas deep learning can learn transformations end to end from unstructured inputs. LLMs can assist with feature ideas, text summarization or categorization, regular expressions, and processing code, but generated solutions still require checking. section 1.3 section 1.5

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Develops an end-to-end workflow from text extraction and aggregation through geographic features, while also naming advanced imputation and encoding methods.
Examples
Demonstrates Tokyo Airbnb price prediction with regex fields, keyword flags, review recency, price aggregation, geographic bins, and proximity distances.
What it assumes
Assumes a tabular dataset, a prediction target, domain hypotheses, and basic exploratory analysis before modeling.
What you can do after
Apply it via pandas, regular expressions, aggregation, and scikit-learn KDTree to create and assess tabular features for a prediction task.
How it connects
Connects feature engineering with exploratory data analysis, validation strategy, baseline models, XGBoost, target encoding, and deep learning.

Also explained in

Compare how 16 books explain feature engineering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.