- class ModelLinkPrediction(number_of_trials: int, device: torch.device = 'cuda', loss_name: str = 'APP', emb_conv_name: str = 'SAGE')
Bases:
object
Model for Link Prediction task with unsupervised embeddings
- Parameters:
dataset – (Graph): Input Graph
(int) (number_of_trials) – Number of trials for optuna tuning embeddings
device – (device): Device ‘cuda’ or ‘cpu’
emb_conv_name – (str): Name of convolution for embedding learning
loss_name – (str): Name of loss function for embedding learning
- test(clf: sklearn.base.BaseEstimator, test_edges: List[List[int]], neg_samples_test: List[List[int]]) float
Calculate f1 measure for test edges
- Param:
cl (BaseEstimator)
- Parameters:
test_edges – (List): List of existing edges to test on
neg_samples_test – (List): List of negative samples to test on
- Returns:
(float): Value of f1 measure
- train_cl(train_edges: List[List[int]], neg_samples_train: List[List[int]]) sklearn.base.BaseEstimator
Train classifier for link prediction
- Parameters:
train_edges – (List): List of existing edges
neg_samples_train – (List): List of negative samples to train
- Returns:
(BaseEstimator): Classifier which support fit predict notation
- train_test_edges(dataset: Graph) Tuple[List[Any], List[int], List[Any], List[int]]
Split dataset to train and test and calculate negative samples
- Parameters:
dataset – (Graph): Data to split on train, test and negatives
- Returns:
(Tuple): Tuple of four lists of train edges, negativу train samples, test and negative test samples edges