CDlib Logo
  • Overview
    • Goals
    • EU H2020
  • Installing CDlib
    • Quick install
    • Optional Dependencies
      • Advanced
    • Installing from source
      • Source archive file
      • GitHub
    • Requirements
      • Python
  • Quick Start
    • Tutorial
    • FAQ
  • Reference
    • Community Objects
      • Node Clustering
      • Fuzzy Node Clustering
      • Attributed Node Clustering
      • Biparite Node Clustering
      • Edge Clustering
      • Temporal Clustering
      • Using Clustering objects with your own algorithm
    • Community Discovery algorithms
      • Static Community Discovery
      • Dynamic Community Discovery
      • Ensemble Methods
      • Summary
    • Evaluation and Benchmarking
      • Internal Evaluation: Fitness scores
      • External Evaluation: Partition Comparisons
      • Synthetic Benchmarks
      • Networks With Annotated Communities
      • Ranking Algorithms
    • Visual Analytics
      • Network Visualization
      • Analytics plots
    • Input-Output
      • CSV format
      • JSON format
    • Utilities
      • Graph Transformation
      • Identifier mapping
  • Bibliography
    • Algorithms
    • Evaluation measures
    • Researches using CDlib
CDlib
  • Docs »
  • Reference »
  • Community Discovery algorithms »
  • Ensemble Methods »
  • cdlib.ensemble.random_search
  • Edit on GitHub

cdlib.ensemble.random_search¶

random_search(graph: <Mock id='140410181329248'>, method: Callable[[<Mock id='140410181329440'>, dict], object], parameters: list, quality_score: Callable[[<Mock id='140410181329536'>, object], object], instances: int = 10, aggregate: Callable[[list], object] = <built-in function max>) → tuple¶

Returns the optimal partition of the specified graph w.r.t. the selected algorithm and quality score over a randomized sample of the input parameters.

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)
  • instances – number of randomly selected parameters configurations
  • 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.random_search(graph=g, method=algorithms.louvain,
>>>                                                       parameters=[resolution, randomize],
>>>                                                       quality_score=evaluation.erdos_renyi_modularity,
>>>                                                       instances=5, aggregate=max)
>>> print(communities, scoring)
Next Previous

© Copyright 2019, Giulio Rossetti Revision 1df247c4.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
v0.2.6
v0.2.5
v0.2.4
v0.2.3
v0.2.2
v0.2.1
0.2.0
v0.1.9
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.