Sampling¶
- class netin.sampling.Sampling(g: Graph, pseeds: float, max_tries: int = 20, random_seed: object | None = None, **kwargs)¶
Base class for sampling methods.
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
Notes¶
- The original graph
g
(passed as parameter) is not modified. The sampling method creates a copy of it, and stores it in
self.g
.
- The original graph
This class does not create a subgraph.
- info()¶
Prints a summary of the training sample subgraph, including its attributes.
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.RandomNodes(g: Graph, pseeds: float, max_tries: int = 20, random_seed: object | None = None, **kwargs)¶
Random node sampling.
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.RandomEdges(g: Graph, pseeds: float, max_tries: int = 20, random_seed: object | None = None, **kwargs)¶
Random edge sampling.
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.RandomNeighbor(g: Graph, pseeds: float, max_tries: int = 20, random_seed: object | None = None)¶
Random neighbor sampling.
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.DegreeRank(g: Graph, pseeds: float, random_seed: object | None = None, **kwargs)¶
Sampling by degree rank
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
- order: str
order of nodes by degree. Options: “asc” | “desc”
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.DegreeGroupRank(g: Graph, pseeds: float, random_seed: object | None = None, **kwargs)¶
Sampling by degree group rank (by degree rank per class)
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
- order: str
order of nodes by degree. Options: “asc” | “desc”
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.
- class netin.sampling.PartialCrawls(g: Graph, pseeds: float, max_tries: int = 20, random_seed: object | None = None, **kwargs)¶
Sampling by partial crawls.
Parameters¶
- g: netin.Graph | netin.DiGraph
global network
- pseeds: float
fraction of seeds to sample
- max_tries: int
maximum number of tries to sample a subgraph with enough classes and edges
- random_seed: object
seed for random number generator
- kwargs: dict
additional parameters for the sampling method
References¶
[Yang2017]Yang, B. Ribeiro, & J. Neville “Should We Be Confident in Peer Effects Estimated From Social Network Crawls?” ICWSM (Vol. 11, No. 1, pp. 708-711), 2017.
- property method_name: str¶
Name of sampling method.
- sampling()¶
Creates a new instance of the respective sampling method, and calls its respective extract_subgraph method.