liveBook · Manning

Feature engineering

As explained in Knowledge Graphs and LLMs in Action

Manual feature extraction is the hand-designed selection or computation of features from raw data.

Feature engineering converts graph structures into numerical vectors that conventional machine-learning algorithms can process. Manual feature extraction selects or computes interpretable features from graph properties and domain knowledge, trading creation effort for explainability. section 9.3 section 10.0

A practical graph feature-engineering pipeline proceeds as follows:

  • Define the prediction task, such as node classification, link prediction, or graph classification. section 9.3 section 9.4
  • Represent nodes or relationships with interpretable measurements, combining local metrics, global measures, node attributes, or domain-specific patterns. section 10.4 section 10.0
  • Convert the representations into vectors and apply the same featurization during training and prediction. section 9.3.1
  • Train and evaluate a downstream classifier, inspecting precision, recall, F-score, and the confusion matrix. section 9.3.1
  • Prune or select features by considering correlation, relevance, interpretability needs, computational resources, and available domain expertise. section 10.4

Karate club node classification

Representing each node only by total degree produces unstable, weak predictions. A three-element vector—total degree, connections to the “Mr. Hi” group, and connections to the “Officer” group—uses homophily to encode social context and yields results close to 100% across repeated runs. The example demonstrates that domain-informed representation can matter more than changing the classifier. section 9.3.1

Path-based relationship features

In the Hetionet biomedical graph, compound–disease pairs are represented by metapaths of lengths two to four. Degree-weighted path count (DWPC) summarizes these paths while discounting highly connected nodes, producing features for treatment-probability prediction even without a direct compound–disease connection. section 10.2.2

Figure 9.6 A graph-based classification approach (collective) versus traditional algorithms for classification
figure

Compare direct graph algorithms with the traditional pipeline that featurizes graph structures before passing vectors to standard machine-learning algorithms. section 9.3

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Descends from manual node metrics to homophily vectors, relationship combinations, metapaths, and DWPC, while contrasting semiautomated and neural alternatives.
Examples
Uses karate-club degree features, homophily-based vectors, Node2Vec comparisons, and Hetionet compound–disease metapaths with DWPC.
What it assumes
Assumes graph structure, node and relationship concepts, vectorization, and basic classifier evaluation while grounding feature choice in domain knowledge.
What you can do after
Apply it via NetworkX, tabular classifiers, and graph queries to build interpretable vectors and diagnose representation-driven performance.
How it connects
Connects graph machine learning with node embeddings, node classification, link prediction, homophily, metapaths, and domain expertise.

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 Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.