Question: Complete the calculate _ best _ partition function to find the resolution associated with the partition that generates the highest NMI. Additionally, complete the plot

Complete the calculate_best_partition function to find the resolution associated with
the partition that generates the highest NMI.
Additionally, complete the plot_best_partition function to visualize the network with
both the ground truth community assignments and the best partition assignments. Plot
both networks side by side as subplots within a single figure. Make sure to label which
graph is which (louvain vs ground truth).
def calculate_best_partition(G: nx.Graph, resolutions: List[int], nmis: List[float])-> Tuple[int, List[str]]:
"""
Inputs:
G: NetworkX graph object
resolutions : a list of integer
nmis :a list of float
Returns:
Tuple of resolution and partition
"""
return resolution, partition
def plot_best_partition(G: nx.Graph, partition: List[str], save: bool=False)-> None:
"""
Inputs:
G: NetworkX graph object
partition : List[str]
save: boolean
Returns:
None
"""
if save:
plt.savefig('1_2_2.png')
plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!