probinet.model_selection.masking#
This module provides functions for shuffling indices and extracting masks for selecting the held-out set in the adjacency tensor and design matrix.
Functions
|
Extract a non-symmetric mask using KFold cross-validation. |
|
Return the masks for selecting the held out set in the adjacency tensor and design matrix. |
|
Shuffle the indices of the adjacency tensor. |
|
|
|
Extract a maskX using KFold. |
|
Shuffle the indices of the adjacency tensor. |
- probinet.model_selection.masking.extract_mask_kfold(indices: List[ndarray], N: int, fold: int = 0, NFold: int = 5) ndarray [source]#
Extract a non-symmetric mask using KFold cross-validation. It contains pairs (i,j) but possibly not (j,i). KFold means no train/test sets intersect across the K folds.
- Parameters:
indices – Indices of the adjacency tensor in a shuffled order.
N – Number of nodes.
fold – Current fold.
NFold – Number of total folds.
- Returns:
Mask for selecting the held out set in the adjacency tensor. It is made of 0s and 1s, where 1s represent that the element (i,j) should be used. where 1s represent that the element (i,j) should be used.
- Return type:
mask
- probinet.model_selection.masking.extract_masks(N: int, L: int, idxG: list[list[Tuple[int, int]]], idxX: Sequence[int], cv_type: str = 'kfold', NFold: int = 5, fold: int = 0, rng: Generator | None = None) Tuple[ndarray, ndarray] [source]#
Return the masks for selecting the held out set in the adjacency tensor and design matrix.
- Parameters:
N – Number of nodes.
L – Number of layers.
idxG – Each list has the indexes of the entries of the adjacency matrix of layer L, when cv is set to kfold.
idxX – List with the indexes of the entries of design matrix, when cv is set to kfold.
cv_type – Type of cross-validation: kfold or random, by default ‘kfold’.
NFold – Number of C-fold, by default 5.
fold – Current fold, by default 0.
rng – Random number generator.
- Returns:
Mask for selecting the held out set in the adjacency tensor and design matrix.
- Return type:
Mask for selecting the held out set in the adjacency tensor and design matrix.
- probinet.model_selection.masking.shuffle_indices(N: int, L: int, rng: Generator | None = None) List[ndarray] [source]#
Shuffle the indices of the adjacency tensor.
- Parameters:
N – Number of nodes.
L – Number of layers.
rng – Random number generator.
- Returns:
Indices in a shuffled order.
- Return type:
Indices in a shuffled order.
- probinet.model_selection.masking.shuffle_indicesG(N: int, L: int, rng: Generator | None = None) List[List[Tuple[int, int]]] [source]#
- Parameters:
N – Number of nodes.
L – Number of layers.
rng – Random number generator.
- Return type:
Shuffled indices for each layer.
- probinet.model_selection.masking.shuffle_indicesX(N: int, rng: Generator | None = None) ndarray [source]#
Extract a maskX using KFold.
- Parameters:
N – Number of nodes.
rng – Random number generator.
- Return type:
Shuffled indices.
- probinet.model_selection.masking.shuffle_indices_all_matrix(N: int, L: int, rng: Generator | None = None) List[ndarray] [source]#
Shuffle the indices of the adjacency tensor.
- Parameters:
N – Number of nodes.
L – Number of layers.
rng – Random number generator.
- Returns:
Indices in a shuffled order. Indices in a shuffled order.
- Return type:
indices