CDlib Logo
  • Overview
    • Who uses CDlib?
    • Goals
    • The Python CDlib library
    • Free software
    • EU H2020
  • Installing CDlib
    • Quick install
    • Optional Dependencies
      • (Advanced) Graph-tool
    • Installing from source
      • Source archive file
      • GitHub
    • Requirements
      • Python
  • Quick Start
    • Tutorial
    • FAQ
  • Reference
    • Community Objects
      • Which community should I use?
      • Community Types
    • Community Discovery algorithms
      • Node Clustering
      • Edge Clustering
      • Temporal Clustering
    • Ensemble Methods
      • Configuration Objects
      • Multiple Instantiation
      • Optimal Configuration Search
    • Evaluation
      • Fitness Functions
      • Partition Comparisons
    • Input-Output
      • CSV format
      • JSON format
    • Visual Analytics
      • Network Visualization
      • Analytics plots
    • Remote Datasets
      • cdlib.datasets.available_networks
      • cdlib.datasets.available_ground_truths
      • cdlib.datasets.fetch_network_data
      • cdlib.datasets.fetch_ground_truth_data
      • cdlib.datasets.fetch_network_ground_truth
    • Utilities
      • Graph Transformation
      • Identifier mapping
  • Bibliography
    • Algorithms
    • Evaluation measures
    • Researches using CDlib
CDlib
  • Docs »
  • Reference »
  • Ensemble Methods »
  • cdlib.ensemble.grid_search
  • Edit on GitHub

cdlib.ensemble.grid_search¶

grid_search(graph, method, parameters, quality_score, aggregate=<built-in function max>)¶

Returns the optimal partition of the specified graph w.r.t. the selected algorithm and quality score.

Parameters:
  • method – community discovery method (from nclib.community)
  • graph – networkx/igraph object
  • parameters – list of Parameter and BoolParameter objects
  • quality_score – a fitness function to evaluate the obtained partition (from nclib.evaluation)
  • aggregate – function to select the best fitness value. Possible values: min/max
Returns:

at each call the generator yields a tuple composed by: the optimal configuration for the given algorithm, input paramters and fitness function; the obtained communities; the fitness score

Example:
>>> import networkx as nx
>>> from cdlib import algorithms, ensemble
>>> g = nx.karate_club_graph()
>>> resolution = ensemble.Parameter(name="resolution", start=0.1, end=1, step=0.1)
>>> randomize = ensemble.BoolParameter(name="randomize")
>>> communities, scoring = ensemble.grid_search(graph=g, method=algorithms.louvain,
>>>                                                     parameters=[resolution, randomize],
>>>                                                     quality_score=evaluation.erdos_renyi_modularity,
>>>                                                     aggregate=max)
>>> print(communities, scoring)
Next Previous

© Copyright 2019, Giulio Rossetti Revision 4f0f1dd6.

Built with Sphinx using a theme provided by Read the Docs.