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.
Este exercício faz parte do curso
Fraud Detection in R
Instruções do exercício
- Create an undirected graph called
net
based ontransfers
. Setdirected
to the appropriate boolean (TRUE
orFALSE
). - Specify a color for each node: set
V(net)$color
to"darkorange"
ifaccount_info$isMoneyMule == TRUE
and"slateblue1"
otherwise. - Use
subgraph()
onnet
to create a subgraph calledsubset
containing vertices"I41"
,"I47"
,"I87"
and"I20"
. - Use function
strength()
onsubnet
and onnet
to compute the money mule probability of node"I41"
as the fraction of mule neighbors
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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")