growingspheres/utils/gs_utils.py
def perturb_continuous_features(continuous_features, n, feature_variance, segment, center, matrix_perturb_instances):
        """
        Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment
        Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
        """
        d = len(continuous_features)
        generated_instances = np.zeros((n,d))
        for feature, (min_feature, max_feature) in enumerate(zip(min_features, max_features)):
            range_feature = max_feature - min_feature
            # Modify the generation of artificial instance depending on the variance of each feature
            y = - segment[0] * range_feature
            z = segment[1] * range_feature
            variance = feature_variance[feature] * segment[1]
            k = (12 * variance)**0.5
            a1 = min(y, z - k)
            b1 = a1 + k
            nb_instances = int (n / 2)
            generated_instances[:nb_instances, feature] = np.random.uniform(a1, b1, nb_instances)
            generated_instances[nb_instances:, feature] = np.random.uniform(-a1, -b1, n-nb_instances)
            np.random.shuffle(generated_instances[:,feature])
        generated_instances += center[continuous_features]
        for nb, continuous in enumerate(continuous_features):
            matrix_perturb_instances[:,continuous] = generated_instances[:,nb].ravel()
        return matrix_perturb_instances

        Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment
        Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
        
Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment
Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
def perturb_continuous_features(continuous_features, n, feature_variance, segment, center, matrix_perturb_instances):
        d = len(continuous_features)
        generated_instances = np.zeros((n,d))
        for feature, (min_feature, max_feature) in enumerate(zip(min_features, max_features)):
            range_feature = max_feature - min_feature
            y = - segment[0] * range_feature
            z = segment[1] * range_feature
            variance = feature_variance[feature] * segment[1]
            k = (12 * variance)**0.5
            a1 = min(y, z - k)
            b1 = a1 + k
            nb_instances = int (n / 2)
            generated_instances[:nb_instances, feature] = np.random.uniform(a1, b1, nb_instances)
            generated_instances[nb_instances:, feature] = np.random.uniform(-a1, -b1, n-nb_instances)
            np.random.shuffle(generated_instances[:,feature])
        generated_instances += center[continuous_features]
        for nb, continuous in enumerate(continuous_features):
            matrix_perturb_instances[:,continuous] = generated_instances[:,nb].ravel()
        return matrix_perturb_instances
def perturb_continuous_features ( continuous_features , n , feature_variance , segment , center , matrix_perturb_instances ) : d = len ( continuous_features ) generated_instances = np . zeros ( ( n , d ) ) for feature , ( min_feature , max_feature ) in enumerate ( zip ( min_features , max_features ) ) : range_feature = max_feature - min_feature y = - segment [ 0 ] * range_feature z = segment [ 1 ] * range_feature variance = feature_variance [ feature ] * segment [ 1 ] k = ( 12 * variance ) ** 0.5 a1 = min ( y , z - k ) b1 = a1 + k nb_instances = int ( n / 2 ) generated_instances [ : nb_instances , feature ] = np . random . uniform ( a1 , b1 , nb_instances ) generated_instances [ nb_instances : , feature ] = np . random . uniform ( - a1 , - b1 , n - nb_instances ) np . random . shuffle ( generated_instances [ : , feature ] ) generated_instances += center [ continuous_features ] for nb , continuous in enumerate ( continuous_features ) : matrix_perturb_instances [ : , continuous ] = generated_instances [ : , nb ] . ravel ( ) return matrix_perturb_instances
Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment
Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
"""
        Perturb each continuous features of the n instances around center in the area of a sphere of radius equals to segment
        Return a matrix of n instances of d dimension perturbed based on the distribution of the dataset
        """ # Modify the generation of artificial instance depending on the variance of each feature
continuous_features
n
feature_variance
segment
center
matrix_perturb_instances