def __init__(self, N=64, seed=None, **kwargs): self.seed = seed if N == 64: data = utils.loadmat('pointclouds/david64') assert data['N'][0, 0] == N W = data['W'] coords = data['coords'] elif N == 500: data = utils.loadmat('pointclouds/david500') assert data['N'][0, 0] == N W = data['W'] coords = data['coords'] else: coords = np.random.RandomState(seed).rand(N, 2) target_dist_cutoff = -0.125 * N / 436.075 + 0.2183 T = 0.6 s = np.sqrt(-target_dist_cutoff**2/(2*np.log(T))) d = utils.distanz(coords.T) W = np.exp(-np.power(d, 2)/(2.*s**2)) W[W < T] = 0 W[np.diag_indices(N)] = 0 plotting = {"limits": [0, 1, 0, 1]} super(DavidSensorNet, self).__init__(W, coords=coords, plotting=plotting, **kwargs)
def __init__(self, N=64, seed=None, **kwargs): self.seed = seed if N == 64: data = utils.loadmat('pointclouds/david64') assert data['N'][0, 0] == N W = data['W'] coords = data['coords'] elif N == 500: data = utils.loadmat('pointclouds/david500') assert data['N'][0, 0] == N W = data['W'] coords = data['coords'] else: coords = np.random.RandomState(seed).rand(N, 2) target_dist_cutoff = -0.125 * N / 436.075 + 0.2183 T = 0.6 s = np.sqrt(-target_dist_cutoff**2 / (2 * np.log(T))) d = utils.distanz(coords.T) W = np.exp(-np.power(d, 2) / (2. * s**2)) W[W < T] = 0 W[np.diag_indices(N)] = 0 plotting = {"limits": [0, 1, 0, 1]} super(DavidSensorNet, self).__init__(W, coords=coords, plotting=plotting, **kwargs)
def __init__(self, connected=True, **kwargs): self.connected = connected data = utils.loadmat('pointclouds/minnesota') self.labels = data['labels'] A = data['A'] plotting = {"limits": np.array([-98, -89, 43, 50]), "vertex_size": 40} if connected: # Missing edges needed to connect the graph. A = sparse.lil_matrix(A) A[348, 354] = 1 A[354, 348] = 1 A = sparse.csc_matrix(A) # Binarize: 8 entries are equal to 2 instead of 1. A = (A > 0).astype(bool) super(Minnesota, self).__init__(A, coords=data['xy'], plotting=plotting, **kwargs)
def __init__(self, moontype='standard', dim=2, sigmag=0.05, N=400, sigmad=0.07, distance=0.5, seed=None, **kwargs): self.moontype = moontype self.dim = dim self.sigmag = sigmag self.sigmad = sigmad self.distance = distance self.seed = seed if moontype == 'standard': N1, N2 = 1000, 1000 data = utils.loadmat('pointclouds/two_moons') Xin = data['features'][:dim].T elif moontype == 'synthesized': N1 = N // 2 N2 = N - N1 coords1 = self._create_arc_moon(N1, sigmad, distance, 1, seed) coords2 = self._create_arc_moon(N2, sigmad, distance, 2, seed) Xin = np.concatenate((coords1, coords2)) else: raise ValueError('Unknown moontype {}'.format(moontype)) self.labels = np.concatenate((np.zeros(N1), np.ones(N2))) plotting = { 'vertex_size': 30, } super(TwoMoons, self).__init__(Xin=Xin, sigma=sigmag, k=5, plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/logogsp') self.info = {"idx_g": data["idx_g"], "idx_s": data["idx_s"], "idx_p": data["idx_p"]} plotting = {"limits": np.array([0, 640, -400, 0])} super(Logo, self).__init__(W=data['W'], coords=data['coords'], plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/logogsp') # Remove 1 because the index in python start at 0 and not at 1 self.info = {"idx_g": data["idx_g"]-1, "idx_s": data["idx_s"]-1, "idx_p": data["idx_p"]-1} plotting = {"limits": np.array([0, 640, -400, 0])} super(Logo, self).__init__(W=data['W'], coords=data['coords'], plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/logogsp') # Remove 1 because the index in python start at 0 and not at 1 self.info = {"idx_g": data["idx_g"]-1, "idx_s": data["idx_s"]-1, "idx_p": data["idx_p"]-1} plotting = {"limits": np.array([0, 640, -400, 0])} super(Logo, self).__init__(data['W'], coords=data['coords'], plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/bunny') plotting = { 'vertex_size': 10, 'elevation': -90, 'azimuth': 90, 'distance': 7, } super(Bunny, self).__init__(Xin=data['bunny'], epsilon=0.2, NNtype='radius', plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/bunny') plotting = { 'vertex_size': 10, 'elevation': -90, 'azimuth': 90, 'distance': 8, } super(Bunny, self).__init__(Xin=data['bunny'], epsilon=0.02, NNtype='radius', center=False, rescale=False, plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/airfoil') coords = np.concatenate((data['x'], data['y']), axis=1) i_inds = np.reshape(data['i_inds'] - 1, 12289) j_inds = np.reshape(data['j_inds'] - 1, 12289) A = sparse.coo_matrix((np.ones(12289), (i_inds, j_inds)), shape=(4253, 4253)) W = (A + A.T) / 2. plotting = {"vertex_size": 30, "limits": np.array([-1e-4, 1.01*data['x'].max(), -1e-4, 1.01*data['y'].max()])} super(Airfoil, self).__init__(W, coords=coords, plotting=plotting, **kwargs)
def __init__(self, **kwargs): data = utils.loadmat('pointclouds/airfoil') coords = np.concatenate((data['x'], data['y']), axis=1) i_inds = np.reshape(data['i_inds'] - 1, 12289) j_inds = np.reshape(data['j_inds'] - 1, 12289) A = sparse.coo_matrix((np.ones(12289), (i_inds, j_inds)), shape=(4253, 4253)) W = (A + A.T) / 2. plotting = {"vertex_size": 30, "limits": np.array([-1e-4, 1.01*data['x'].max(), -1e-4, 1.01*data['y'].max()])} super(Airfoil, self).__init__(W=W, coords=coords, plotting=plotting, **kwargs)
def __init__(self, moontype='standard', dim=2, sigmag=0.05, N=400, sigmad=0.07, distance=0.5, seed=None, **kwargs): self.moontype = moontype self.dim = dim self.sigmag = sigmag self.sigmad = sigmad self.distance = distance self.seed = seed if moontype == 'standard': N1, N2 = 1000, 1000 data = utils.loadmat('pointclouds/two_moons') Xin = data['features'][:dim].T elif moontype == 'synthesized': N1 = N // 2 N2 = N - N1 coords1 = self._create_arc_moon(N1, sigmad, distance, 1, seed) coords2 = self._create_arc_moon(N2, sigmad, distance, 2, seed) Xin = np.concatenate((coords1, coords2)) else: raise ValueError('Unknown moontype {}'.format(moontype)) self.labels = np.concatenate((np.zeros(N1), np.ones(N2))) plotting = { 'vertex_size': 30, } super(TwoMoons, self).__init__(Xin=Xin, sigma=sigmag, k=5, center=False, rescale=False, plotting=plotting, **kwargs)