growingspheres/utils/gs_utils.py
def generate_inside_field(center, segment, n, max_features, min_features, feature_variance):
    """
    Args:
        "center" corresponds to the target instance to explain
        Segment corresponds to the size of the hypersphere
        n corresponds to the number of instances generated
        feature_variance: Array of variance for each continuous feature
    """
    #print("segment", segment)
    if segment[0] == 1 and max_features == []:
        print("IL Y A UN PROBLEME PUISQUE LE RAYON EST DE 1 et max features n'est pas initialisé", segment, center, feature_variance)
        generated_instances += 2
    d = center.shape[0]
    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
        #a2 = min(y, z + k)
        #b2 = a2 - k
        #print("k, a1, b1", variance, a1, b1)
        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
    return generated_instances

    Args:
        "center" corresponds to the target instance to explain
        Segment corresponds to the size of the hypersphere
        n corresponds to the number of instances generated
        feature_variance: Array of variance for each continuous feature
    
"center" corresponds to the target instance to explain
Segment corresponds to the size of the hypersphere
n corresponds to the number of instances generated
feature_variance: Array of variance for each continuous feature
" center " corresponds to the target instance to explain Segment corresponds to the size of the hypersphere n corresponds to the number of instances generated feature_variance : Array of variance for each continuous feature
def generate_inside_field(center, segment, n, max_features, min_features, feature_variance):
    if segment[0] == 1 and max_features == []:
        print("IL Y A UN PROBLEME PUISQUE LE RAYON EST DE 1 et max features n'est pas initialisé", segment, center, feature_variance)
        generated_instances += 2
    d = center.shape[0]
    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
    return generated_instances
def generate_inside_field ( center , segment , n , max_features , min_features , feature_variance ) : if segment [ 0 ] == 1 and max_features == [ ] : print ( "IL Y A UN PROBLEME PUISQUE LE RAYON EST DE 1 et max features n'est pas initialisé", egment, enter, eature_variance) generated_instances += 2 d = center . shape [ 0 ] 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 return generated_instances
Args:
"center" corresponds to the target instance to explain
Segment corresponds to the size of the hypersphere
n corresponds to the number of instances generated
feature_variance: Array of variance for each continuous feature
Args : " center " corresponds to the target instance to explain Segment corresponds to the size of the hypersphere n corresponds to the number of instances generated feature_variance : Array of variance for each continuous feature
"""
    Args:
        "center" corresponds to the target instance to explain
        Segment corresponds to the size of the hypersphere
        n corresponds to the number of instances generated
        feature_variance: Array of variance for each continuous feature
    """ #print("segment", segment) # Modify the generation of artificial instance depending on the variance of each feature #a2 = min(y, z + k) #b2 = a2 - k #print("k, a1, b1", variance, a1, b1)
center
segment
n
max_features
min_features
feature_variance