Algorithm for finding anomalous groups in networks
Project description
Python package for the CItation-Donor-REcipient (CIDRE) algorithm.
Please cite:
Sadamori Kojaku, Giacomo Livan, Naoki Masuda. Detecting citation cartels in journal networks. arXiv:2009.09097 (2020)
Install
pip install cidre
Minimal example
import cidre
alg = cidre.Cidre(group_membership)
groups = alg.detect(A, threshold = 0.15)
group_membership
: If the network has communities, and the communities are not anomalous, tell the community membership to CIDRE through this argument, wheregroup_membership[i]
indicates the group to which node i belongs. Otherwise, setgroup_membership=None
.A
: Adjacency matrix of the input network (can be weighted and directed). nx.Graph or scipy.sparse_matrix. if scipy.sparse_matrix format, A[i,j] indicates the weight of edge from node i to j.threshold
: Threshold for the donor and recipient nodes. A larger threshold will yield tighter and smaller groupsgroups
: Detected groups. This is a list of special class,Group
.
The donors of group can be obtained by
groups[0].donors # {node_id: donor_score}
group.donors
is a dict object, with keys and values corresponding to the node ID and the donor score.
Similarly, the recipients of a group together with their recipient scores are given by
group.recipient # {node_id: recipient_score}
Visualization
ax = plt.gca()
dc = cidre.DrawCartel()
dc.draw(group, ax = ax)
The labels beside the nodes are the ID of the nodes, or equivalently row ids of the adjacency matrix A
.
To put the node labels, make a dictionary from the ID to label, like node_labels = {0:"name", 1:"name 2"}
, and pass it by node_labels = node_labels
.
Example script
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cidre-0.0.0.tar.gz
(11.4 kB
view hashes)
Built Distribution
cidre-0.0.0-py3-none-any.whl
(15.9 kB
view hashes)