IniziaInizia gratis

Looking for homophily in a network

Often nodes have features or attributes associated with them. Data frame account_info contains the type of each account. Homophily is a concept which stems from sociology. In a fraud network, homophily implies that fraudsters are more likely to be connected to other fraudsters, and legitimate people are more likely to be connected to other legitimate people. Depending upon the business context and type of fraud, homophily may be present or absent. Let's check for homophily in the network based on the attribute account_type.

Attributes can be added to the nodes of your network with V(my_network)$new_node_attribute.

The igraph package and the network net from the previous exercise are loaded in your workspace.

Questo esercizio fa parte del corso

Fraud Detection in R

Visualizza il corso

Istruzioni dell'esercizio

  • Add the variable type from account_info as an attribute account_type to the nodes of network net.
  • Print the vertex attributes of net.
  • Since account_type is a nominal variable, check for homophily in the network based on account_type by using assortativity_nominal.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Add account_type as an attribute to the nodes of the network
___(net)$___ <- ___$___

# Have a look at the vertex attributes
print(___(___))

# Check for homophily based on account_type
___(___, types = ___, directed = FALSE)
Modifica ed esegui il codice