Comments (2)
I do not fully understand the following code (because of variable names):
staticcommunities= teneto.communitydetection.temporal_louvain(G, intersliceweight=0.1, n_iter=1)
Does not look like this is "staticcommunities".
Also, the teneto communitydetection's intersliceweight is not necessarily in line with some other implementations. Something I've needed to look back on but never had the time.
But in essence this looks fine.
If you think something is wrong, let me know.
from teneto.
Thanks for the quick response. I had amended the variables names for clarity.
But, upon Googling, I found there is a dedicated function to measure 'consensus_iterative' written in Matlab from this weebly website.
function [S2, Q2, X_new3, qpc] = consensus_iterative(C)
%CONSENSUS_ITERATIVE Construct a consensus (representative) partition
%using the iterative thresholding procedure
%
% [S2 Q2 X_new3 qpc] = CONSENSUS_ITERATIVE(C) identifies a single
% representative partition from a set of C partitions, based on
% statistical testing in comparison to a null model. A thresholded nodal
% association matrix is obtained by subtracting a random nodal
% association matrix (null model) from the original matrix. The
% representative partition is then obtained by using a Generalized
% Louvain algorithm with the thresholded nodal association matrix.
%
% NOTE: This code requires genlouvain.m to be on the MATLAB path
%
% Inputs: C, pxn matrix of community assignments where p is the
% number of optimizations and n the number of nodes
%
% Outputs: S2, pxn matrix of new community assignments
% Q2, associated modularity value
% X_new3, thresholded nodal association matrix
% qpc, quality of the consensus (lower == better)
%
%
% Bassett, D. S., Porter, M. A., Wymbs, N. F., Grafton, S. T., Carlson,
% J. M., & Mucha, P. J. (2013). Robust detection of dynamic community
% structure in networks. Chaos: An Interdisciplinary Journal of Nonlinear
% Science, 23(1), 013142.
npart = numel(C(:,1)); % number of partitions
m = numel(C(1,:)); % size of the network
% initialize
C_rand3 = zeros(size(C)); % permuted version of C
X = zeros(m,m); % Nodal association matrix for C
X_rand3 = X; % Random nodal association matrix for C_rand3
%% NODAL ASSOCIATION MATRIX
% try a random permutation approach
for i = 1:npart;
pr = randperm(m);
C_rand3(i,:) = C(i,pr); % C_rand3 is the same as C, but with each row permuted
end
% Calculate the nodal association matrices X and
% X_rand3
for i = 1:npart;
ii=i
tic
for k = 1:m
for p = 1:m;
% element (i,j) indicate the number of times node i and node j
% have been assigned to the same community
if isequal(C(i,k),C(i,p))
X(k,p) = X(k,p) + 1;
else
X(k,p) = X(k,p) + 0;
end
% element (i,j) indicate the number of times node i and node j
% are expected to be assigned to the same community by chance
if isequal(C_rand3(i,k),C_rand3(i,p))
X_rand3(k,p) = X_rand3(k,p)+1;
else
X_rand3(k,p) = X_rand3(k,p)+ 0;
end
end
end
toc
end
%% THRESHOLDING
% keep only associated assignments that occur more often than expected in
% the random data
X_new3 = zeros(m,m);
X_new3(X>max(max(triu(X_rand3,1)))) = X(X>max(max(triu(X_rand3,1))));
%% GENERATE THE REPRESENTATIVE PARTITION
% recompute optimal partition on this new matrix of kept community
% association assignments
for i = 1:npart;
ii=i
[S2(i,:) Q2(i)] = multislice_static_unsigned(X_new3,1);
end
% define the quality of the consensus
qpc = sum(sum(abs(diff(S2))));
Now im confuse whether it is correct to get the consensus partition using the line below
# Get the community/consensus partition
communities_static= teneto.communitydetection.temporal_louvain(tnet_static, intersliceweight=0.1, n_iter=1)
or using the logic as in the consensus_iterative
.
Sorry for out-topic question, but appreciate if you can share some insight to a beginner like myself
from teneto.
Related Issues (20)
- Closeness centrality running without interruption HOT 9
- Remove dependencies on neural-specific modules but issue a warning if a function is trying to be used that requires it HOT 21
- [Question] shortest_temporal_path HOT 6
- MemoryError while loading graph HOT 14
- Control colormap of temporal graph nodes HOT 4
- Plotting slice_plot will fail if dataframe columns in wrong order HOT 4
- Improve shortest temporal paths (speed issues) HOT 1
- [ENH] Prewhiten prior to derive_temporalnetwork
- AttributeError: module 'sqlalchemy.util' has no attribute 'dependencies' after importing TemporalNetworks() HOT 3
- wrong number of nodes from TN.N and in netshape HOT 2
- Speed up the shortest path calculation speed HOT 1
- An error: The object 'TemporalNetwork' can't import dataframe data of weighted network HOT 3
- Label node on temporalnetwork ploting HOT 1
- Inconsistency when plotting slice plot a temporal network HOT 6
- How to make a community slice plot HOT 2
- Possible Typo in test_communitydetection.py
- Network Properties calculation speed problem HOT 3
- Deprecated call to scipy.temporal.distance.matching
- Minor wording error in what_is_tnt.rst HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teneto.