Second order link-based features
In this exercise, you will compute the number and ratio of churn and non-churn neighbors in the second order neighborhood. The procedure is the same as in the previous exercise, except now you use the second order adjacency matrix.
Diese Übung ist Teil des Kurses
Predictive Analytics using Networked Data in R
Anleitung zur Übung
- Compute the number of churn neighbors in the second order neighborhood using
SecondOrderMatrix
and theChurn
attribute. Convert the result withas.vector()
and add it asChurnNeighbors2
tonetwork
. - Also compute
NonChurnNeighbors2
, the number of non-churn neighbors in the second order neighborhood. - Calculate
RelationalNeighbor2
, the ratio of churners in the second order neighborhood, by dividingChurnNeighbors2
with the sum ofChurnNeighbors2
andNonChurnNeighbors2
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Compute the number of churners in the second order neighborhood
V(network)$ChurnNeighbors2 <- as.vector(___ %*% V(network)$___)
# Compute the number of non-churners in the second order neighborhood
V(network)$___ <- as.vector(___ %*% (1 - V(network)$___))
# Compute the relational neighbor probability in the second order neighborhood
V(network)$___ <- as.vector(V(network)$___ /
(V(network)$___ + V(network)$___))