Question: Complete the sweep _ louvain _ resolutions function to identify community structures within the graph. Use the Louvain algorithm to find the best partition. Use
Complete the sweeplouvainresolutions function to identify community structures within the graph. Use the Louvain algorithm to find the best partition. Use different resolution parameters from minresolution to maxresolution inclusive and compare the result of each partition to the ground truth you can find the ground truth in the value field associated with each node in the graph using the normalized mutual information function. Return the list of resolutions and NMIs from the resulting community assignments. Additionally, complete the plotnmivsresolution function to display the NMI for each resolution as a line plot.
When I use normalizedmutualinfoscore function I run into this error: Found input variables with inconsistent numbers of samples: any guidance?
def sweeplouvainresolutionsG: nxGraph, minresolution: int maxresolution: int TupleListint Listfloat:
Inputs:
G: NetworkX graph object
minresolution : integer
maxresolution : integer
Returns:
Tuple of list of resolutions and list of NMIs
resolutions
nmis
communities listnxcommunity.louvaincommunitiesG
for i in rangeminresolution, maxresolution:
res listlouvaincommunitiesG resolutioni
resolutions.appendi
nmiscores normalizedmutualinfoscorecommunities res
#nmis.appendnmiscores
return resolutions, nmis
def plotnmivsresolutionresolutions: Listint nmis: Listfloat save: boolFalse None:
Inputs:
minresolution : integer
maxresolution : integer
save: boolean
Returns:
None
if save:
pltsavefigpng
pltshow
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
