[docs]classNoSplit(BaseSplit):'''No split, usually used in reconstruction tasks. Designed for reconstruction tasks, where training, validation and testing use the same full set of samples. `NoSplit` supports negative sampling. '''def__init__(self,X:spmatrix,seed=None):super().__init__(X)print("[I] NoSplit, sampling positives")# self.check_params(seed=seed)self.rs=RatioSplit(self.X,seed=seed)self.pos_size=self.rs.pos_train_sizeself.X_train=self.Xself.X_val=self.Xself.X_test=self.X
[docs]defnegative_sample(self,size,type='uniform',seed=None):'''Select and append negative samples onto train, val and test set. Parameters ---------- size : int Number of negative samples. type : str Type of negative sampling. seed : int Random seed. '''self.rs.negative_sample(train_size=size,type=type,seed=seed)self.neg_size=self.rs.neg_train_sizeself.X_train=self.rs.X_trainself.X_val=self.rs.X_trainself.X_test=self.rs.X_train