def test_2d_1cluster(self): #create simple data: a = range(0, 11) print a d = [] for i in a: for j in a: d.append([i * 1.0, j * 1.0]) dbscanner = Dbscan(np.array(d), 3, 2.0) dbscanner.run() plotting.plotting(dbscanner.getClusterList(), dbscanner.getNoise())
def test_2d_1cluster(self): #create simple data: a = range(0, 11) print a d = [] for i in a: for j in a: d.append([i*1.0, j*1.0]) dbscanner = Dbscan(np.array(d), 3, 2.0) dbscanner.run() plotting.plotting(dbscanner.getClusterList(),dbscanner.getNoise())
def test_plotting(self): #some dummy data number, x_coordinate, y_coordinate = loadtxt('testdata/eps3-minpts5-cluster5-noise20.dat', unpack = True) D=[None]*len(x_coordinate) for ii in range(len(x_coordinate)): D[ii]=[x_coordinate[ii],y_coordinate[ii]] #put in the data we want to use minNeighbors = 5 epsilon = 3. data = np.array(D, dtype=np.float64) # use dbscan dbscanner = Dbscan(data, minNeighbors, epsilon) dbscanner.run() # use plotting plotting.plotting(dbscanner.getClusterList(),dbscanner.getNoise())
def test_plotting(self): #some dummy data number, x_coordinate, y_coordinate = loadtxt( 'testdata/eps3-minpts5-cluster5-noise20.dat', unpack=True) D = [None] * len(x_coordinate) for ii in range(len(x_coordinate)): D[ii] = [x_coordinate[ii], y_coordinate[ii]] #put in the data we want to use minNeighbors = 5 epsilon = 3. data = np.array(D, dtype=np.float64) # use dbscan dbscanner = Dbscan(data, minNeighbors, epsilon) dbscanner.run() # use plotting plotting.plotting(dbscanner.getClusterList(), dbscanner.getNoise())
def test_dbscan2(self): testdata2='testdata/eps0p01-minpts1-cluster0-noise100.dat' number, x_coordinate, y_coordinate = np.loadtxt(testdata2, unpack = True) D=[None]*len(x_coordinate) for ii in range(len(x_coordinate)): D[ii]=[x_coordinate[ii],y_coordinate[ii]] D=np.array(D) epsilon=0.01 minNeighbors=1 dbscanner = Dbscan(D, minNeighbors, epsilon) dbscanner.run() datennoise=dbscanner.getNoise() datennoise=np.array(datennoise) b=[] cluster1=dbscanner.getClusterList() np.testing.assert_array_equal(cluster1,b) np.testing.assert_array_equal(datennoise,D)
def test_dbscan2(self): testdata2 = 'testdata/eps0p01-minpts1-cluster0-noise100.dat' number, x_coordinate, y_coordinate = np.loadtxt(testdata2, unpack=True) D = [None] * len(x_coordinate) for ii in range(len(x_coordinate)): D[ii] = [x_coordinate[ii], y_coordinate[ii]] D = np.array(D) epsilon = 0.01 minNeighbors = 1 dbscanner = Dbscan(D, minNeighbors, epsilon) dbscanner.run() datennoise = dbscanner.getNoise() datennoise = np.array(datennoise) b = [] cluster1 = dbscanner.getClusterList() np.testing.assert_array_equal(cluster1, b) np.testing.assert_array_equal(datennoise, D)
def test_dbscan1(self): testdata='testdata/eps2-minpts3-cluster1-noise0.dat' number, x_coordinate, y_coordinate = np.loadtxt(testdata, unpack = True) D=[None]*len(x_coordinate) for ii in range(len(x_coordinate)): D[ii]=[x_coordinate[ii],y_coordinate[ii]] D=np.array(D) epsilon=4.0 minNeighbors=3 dbscanner = Dbscan(D, minNeighbors, epsilon) dbscanner.run() datennoise=dbscanner.getNoise() Dresultall=[] for daten in dbscanner.getClusterList(): Dresult=[] for item in daten: Dresult.append(item) Dresultall.append(Dresult) # #assert D==a Dr=np.array(Dresultall) a=np.array([]) np.testing.assert_array_equal(a,datennoise)
def test_dbscan1(self): testdata = 'testdata/eps2-minpts3-cluster1-noise0.dat' number, x_coordinate, y_coordinate = np.loadtxt(testdata, unpack=True) D = [None] * len(x_coordinate) for ii in range(len(x_coordinate)): D[ii] = [x_coordinate[ii], y_coordinate[ii]] D = np.array(D) epsilon = 4.0 minNeighbors = 3 dbscanner = Dbscan(D, minNeighbors, epsilon) dbscanner.run() datennoise = dbscanner.getNoise() Dresultall = [] for daten in dbscanner.getClusterList(): Dresult = [] for item in daten: Dresult.append(item) Dresultall.append(Dresult) # #assert D==a Dr = np.array(Dresultall) a = np.array([]) np.testing.assert_array_equal(a, datennoise)