A feature vector is a compact numerical representation of data. In graph machine learning, its components encode measurable properties of nodes, relationships, or whole graphs so conventional machine-learning algorithms can process them. section 9.3 section 10.0
Vectors turn graph structure into an interface for the broader machine-learning ecosystem. Manual feature engineering can produce interpretable values such as node degree, clustering coefficient, centrality, or path-based scores, while representation learning automatically discovers less interpretable features. section 9.3 section 10.0
A practical vector-construction pipeline can proceed as follows:
- Identify properties relevant to the prediction task, such as node characteristics, graph relationships, or selected metapaths. section 9.3
- Encode those properties as numerical components; binary components can indicate whether a movie belongs to each genre. section 12.2.2
- Align vector rows with graph entities and map original identifiers to consecutive indices before constructing graph connectivity. section 12.2.2
- Use the resulting vectors with downstream tasks such as node classification, link prediction, or graph classification. section 9.3 section 12.2.2
Movie genre vectors
A movie vector uses one column per genre. A value of 1 marks membership and 0 marks absence, so an Adventure movie and a Drama movie receive different components; multiple genre components may be active for one movie. The resulting tensor contains 9,742 rows and 20 genre features. section 12.2.2
Path-based drug–disease feature
A vector for a compound–disease pair can include a metapath feature computed with a degree-weighted path score. For metformin and type 2 diabetes, the CbGaD feature has a DWPC value of 0.0007; selecting useful metapaths reduces computational cost and noise. section 10.2.2
Listing 12.14 Transforming genre information into a vector of features
movies_df = pd.read_csv(movies_path, index_col='movieId') #1
genres = movies_df['genres'].str.get_dummies('|') #2
movie_feat = torch.from_numpy(genres.values).to(torch.float) #3
assert movie_feat.size() == (9742, 20) #4
Inspect the pandas and PyTorch pipeline that converts pipe-separated movie genres into a floating-point feature tensor. section 12.2.2














































