liveBook · Manning

Vectorization

As explained in Knowledge Graphs and LLMs in Action

Featurization is the transformation of raw data or graph objects into numerical features suitable for machine-learning models.

Vectorization, also called featurization, transforms graph elements—nodes, relationships, or whole graphs—into numerical vectors that machine-learning algorithms can process. The representation affects downstream tasks such as node classification, link prediction, and graph analysis. Manual features favor interpretability but require more labor; automated features improve efficiency while making the resulting signals harder to interpret. section 10.0

A reliable graph-ML pipeline treats vectorization as a consistent, testable stage:

  • Represent each graph element with numerical features, such as a node's total degree or counts of neighbors belonging to selected groups. section 9.3.1
  • Choose between interpretable manual features and richer automated embeddings such as Node2Vec, balancing feature meaning against extraction effort. section 9.3.1 section 10.0
  • Attach vectors to labels, split the data, scale training vectors, and fit a classifier such as logistic regression. section 9.3.1
  • Apply the identical featurization and scaling procedure during prediction; otherwise, the trained model cannot operate correctly. section 9.3.1
  • Validate predictions with precision, recall, F-score, and a confusion matrix rather than treating generated classifications as self-validating. section 9.3.1

Karate-club node classification

A 34-member karate-club network supplies a compact test case. Nodes receive labels based on whether members joined the instructor's or administrator's faction. A one-dimensional degree vector performs poorly, while Node2Vec improves the reported F-score. A three-value vector—total degree, neighbors affiliated with Mr. Hi, and neighbors affiliated with an Officer—raises the reported F-score to approximately 0.927. section 9.3.1

Figure 9.7 Training flow for node classification and link prediction. A critical step is the featurization of nodes and relationships. When this process is finished, the vectors can be passed to a classic algorithm. Both node classification and link prediction can be seen as classification tasks.
figure

Use the training-flow diagram to trace vector creation before classification and connect it to the separate prediction flow, where the same transformation is required. section 9.3.1

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains manual, typed, and Node2Vec features through training, prediction, scaling, and metric evaluation.
Examples
Uses the Zachary Karate Club, degree vectors, Node2Vec embeddings, typed degree vectors, and confusion matrices.
What it assumes
Assumes graph elements and machine-learning tasks, while building feature construction from basic degree counts upward.
What you can do after
Apply via NetworkX, Node2Vec, and classifier pipelines that transform, scale, train, predict, and evaluate graph features.
How it connects
Connects graph representation with node classification, link prediction, feature engineering, embeddings, and logistic regression.

Also explained in

Compare how 18 books explain vectorization →

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.