Relational neighbor classifier
A relation model is based on the idea that the behavior between nodes is correlated, meaning that connected nodes have a propensity to belong to the same class. The relational neighbor classifier, in particular, predicts a node's class based on its neighboring nodes and adjacent edges.
The dataset transfers consists of transactions from different accounts. The account_info data contains which of these accounts are money mules. However, it is unknown whether account "I41" is a money mule. Predict the money mule propensity of account "I41" using a relational neighbor classifier.
Cet exercice fait partie du cours
Fraud Detection in R
Instructions
- Create an undirected graph called
netbased ontransfers. Setdirectedto the appropriate boolean (TRUEorFALSE). - Specify a color for each node: set
V(net)$colorto"darkorange"ifaccount_info$isMoneyMule == TRUEand"slateblue1"otherwise. - Use
subgraph()onnetto create a subgraph calledsubsetcontaining vertices"I41","I47","I87"and"I20". - Use function
strength()onsubnetand onnetto compute the money mule probability of node"I41"as the fraction of mule neighbors
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# From data frame to graph
net <- graph_from_data_frame(___, directed = ___)
# Plot the network; color nodes according to isMoneyMule-variable
___(___)$color <- ifelse(___$___ == TRUE, ___, ___)
plot(net, vertex.label.color = "black", vertex.label.font = 2, vertex.size = 18)
# The id's of the money mule accounts:
print(account_info$id[account_info$isMoneyMule == TRUE])
# Create subgraph containing node "I41" and all money mules nodes "I47", "I87", "I20":
subnet <- ___(___, v = c(___))
# Compute the money mule probability of node "I41" based on the neighbors
___(___, v = "I41") / ___(___, v = "I41")