src/new_dset/concentric2.py
def generate_circle2(n=1200, noise_sigma=0.1, train_set_fraction=0.5):
    '''
    Generates and returns 2 concentric example dataset 
    '''
    pts_per_cluster = int(n / 2)
    r = 1

    # generate clusters
    theta1 = (np.random.uniform(0, 1, pts_per_cluster) * 2 * np.pi).reshape(pts_per_cluster, 1)
    theta2 = (np.random.uniform(0, 1, pts_per_cluster) * 2 * np.pi).reshape(pts_per_cluster, 1)

    cluster1 = np.concatenate((np.cos(theta1) * r, np.sin(theta1) * r), axis=1)
    cluster2 = np.concatenate((np.cos(theta2) * r, np.sin(theta2) * r), axis=1)

    # shift and reverse cluster 2, radius = 2
    cluster2[:, 0] = 2 * cluster2[:, 0] 
    cluster2[:, 1] = 2 * cluster2[:, 1] 

    # combine clusters
    x = np.concatenate((cluster1, cluster2), axis=0)

    # add noise to x
    x = x + np.random.randn(x.shape[0], 2) * noise_sigma

    # generate labels
    y = np.concatenate((np.zeros(shape=(pts_per_cluster, 1)), np.ones(shape=(pts_per_cluster, 1))), axis=0)

    # shuffle
    p = np.random.permutation(n)
    y = y[p]
    x = x[p]

    # make train and test splits
    n_train = int(n * train_set_fraction)
    x_train, x_test = x[:n_train], x[n_train:]
    y_train, y_test = y[:n_train].flatten(), y[n_train:].flatten()

    return x_train, x_test, y_train, y_test

    Generates and returns 2 concentric example dataset 
    
Generates and returns 2 concentric example dataset
Generates and returns 2 concentric example dataset
def generate_circle2(n=1200, noise_sigma=0.1, train_set_fraction=0.5):
    pts_per_cluster = int(n / 2)
    r = 1
    theta1 = (np.random.uniform(0, 1, pts_per_cluster) * 2 * np.pi).reshape(pts_per_cluster, 1)
    theta2 = (np.random.uniform(0, 1, pts_per_cluster) * 2 * np.pi).reshape(pts_per_cluster, 1)
    cluster1 = np.concatenate((np.cos(theta1) * r, np.sin(theta1) * r), axis=1)
    cluster2 = np.concatenate((np.cos(theta2) * r, np.sin(theta2) * r), axis=1)
    cluster2[:, 0] = 2 * cluster2[:, 0] 
    cluster2[:, 1] = 2 * cluster2[:, 1] 
    x = np.concatenate((cluster1, cluster2), axis=0)
    x = x + np.random.randn(x.shape[0], 2) * noise_sigma
    y = np.concatenate((np.zeros(shape=(pts_per_cluster, 1)), np.ones(shape=(pts_per_cluster, 1))), axis=0)
    p = np.random.permutation(n)
    y = y[p]
    x = x[p]
    n_train = int(n * train_set_fraction)
    x_train, x_test = x[:n_train], x[n_train:]
    y_train, y_test = y[:n_train].flatten(), y[n_train:].flatten()
    return x_train, x_test, y_train, y_test
def generate_circle2 ( n = 1200 , noise_sigma = 0.1 , train_set_fraction = 0.5 ) : pts_per_cluster = int ( n / 2 ) r = 1 theta1 = ( np . random . uniform ( 0 , 1 , pts_per_cluster ) * 2 * np . pi ) . reshape ( pts_per_cluster , 1 ) theta2 = ( np . random . uniform ( 0 , 1 , pts_per_cluster ) * 2 * np . pi ) . reshape ( pts_per_cluster , 1 ) cluster1 = np . concatenate ( ( np . cos ( theta1 ) * r , np . sin ( theta1 ) * r ) , axis = 1 ) cluster2 = np . concatenate ( ( np . cos ( theta2 ) * r , np . sin ( theta2 ) * r ) , axis = 1 ) cluster2 [ : , 0 ] = 2 * cluster2 [ : , 0 ] cluster2 [ : , 1 ] = 2 * cluster2 [ : , 1 ] x = np . concatenate ( ( cluster1 , cluster2 ) , axis = 0 ) x = x + np . random . randn ( x . shape [ 0 ] , 2 ) * noise_sigma y = np . concatenate ( ( np . zeros ( shape = ( pts_per_cluster , 1 ) ) , np . ones ( shape = ( pts_per_cluster , 1 ) ) ) , axis = 0 ) p = np . random . permutation ( n ) y = y [ p ] x = x [ p ] n_train = int ( n * train_set_fraction ) x_train , x_test = x [ : n_train ] , x [ n_train : ] y_train , y_test = y [ : n_train ] . flatten ( ) , y [ n_train : ] . flatten ( ) return x_train , x_test , y_train , y_test
Generates and returns 2 concentric example dataset
Generates and returns 2 concentric example dataset
'''
    Generates and returns 2 concentric example dataset 
    ''' # generate clusters # shift and reverse cluster 2, radius = 2 # combine clusters # add noise to x # generate labels # shuffle # make train and test splits
n
noise_sigma
train_set_fraction