(self, n_samples)
return S
Generate samples.

        Parameters
        ----------
        n_samples : int
            Number of new synthetic samples.

        Returns
        -------
        S : array, shape = [n_samples, n_features]
            Returns synthetic samples.
Generate samples.
Generate samples .
def sample(self, n_samples):
        """Generate samples.

        Parameters
        ----------
        n_samples : int
            Number of new synthetic samples.

        Returns
        -------
        S : array, shape = [n_samples, n_features]
            Returns synthetic samples.
        """
        np.random.seed(seed=self.random_state)

        S = np.zeros(shape=(n_samples, self.n_features))
        # Calculate synthetic samples.
        for i in range(n_samples):
            # Choose a sample according to the sampling distribution, r.
            j = np.random.choice(self.n_minority_samples, p=self.r)

            # Find the NN for each sample.
            # Exclude the sample itself.
            nn = self.neigh_2.kneighbors(self.X_min[j].reshape(1, -1),
                                         return_distance=False)[:, 1:]
            nn_index = np.random.choice(nn[0])

            dif = self.X_min[nn_index] - self.X_min[j]
            gap = np.random.random()

            S[i, :] = self.X_min[j, :] + gap * dif[:]

        return S
def sample ( self , n_samples ) : np . random . seed ( seed = self . random_state ) S = np . zeros ( shape = ( n_samples , self . n_features ) ) # Calculate synthetic samples. for i in range ( n_samples ) : # Choose a sample according to the sampling distribution, r. j = np . random . choice ( self . n_minority_samples , p = self . r ) # Find the NN for each sample. # Exclude the sample itself. nn = self . neigh_2 . kneighbors ( self . X_min [ j ] . reshape ( 1 , - 1 ) , return_distance = False ) [ : , 1 : ] nn_index = np . random . choice ( nn [ 0 ] ) dif = self . X_min [ nn_index ] - self . X_min [ j ] gap = np . random . random ( ) S [ i , : ] = self . X_min [ j , : ] + gap * dif [ : ] return S