Neighborhood link-based features
Sometimes, the feature values of neighboring nodes have an effect on behavior. In this exercise, you will look at the attribute value of neighboring nodes and compute their average. You will do this for degree, triangles, transitivity, and betweenness.
You need to:
- Multiply the adjacency matrix with the network attribute you want to find the average of, to obtain the overall value in the neighborhood.
- To get the average, divide by the node's degree, given by the vector
degreewhich has been pre-loaded. - Finally, convert the result to a vector and assign to
networkas a node attribute.
本练习是课程的一部分
Predictive Analytics using Networked Data in R
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Extract the average degree of neighboring nodes
V(network)$averageDegree <-
as.vector(AdjacencyMatrix %*% V(network)$___) / degree