def setUp(self): self.dataArray1 = np.array([[0, 0, 0], [18, 18, 21], [4, 11, 9], [22, 0, 25], [23, 1, 29], [24, 2, 26], [5, 8, 10], [20, 19, 18], [10, 15, 15], [3, 13, 11], [19, 20, 19], [21, 19, 20]]) self.data1 = read_database(self.dataArray1) self.data_base_sort_with_ref_point_1 = distance_from_ref_point( self.data1) self.dataArray2 = np.array([[30, 30, 30], [18, 18, 21], [4, 11, 9], [22, 0, 25], [23, 1, 29], [24, 2, 26], [5, 8, 10], [20, 19, 18], [10, 15, 15], [3, 13, 11], [19, 20, 19], [21, 19, 20]]) self.data2 = read_database(self.dataArray2) self.minPts = 3 self.eps = 4
def algorythm_swdbscan(minPts, eps, data): max_cluster_label_1 = -1 max_cluster_label_2 = -1 dataBase = read_database(data) grid_clustering(dataBase, minPts, eps, 0) grid_clustering(dataBase, minPts, eps, 1) for p in dataBase: if p.label[1] == "UNDEFINED": p.label[1] = -1 if p.label[0] == "UNDEFINED": p.label[0] = -1 for i in range(0, len(dataBase)): if dataBase[i].label[0] > max_cluster_label_1: max_cluster_label_1 = dataBase[i].label[0] if dataBase[i].label[1] > max_cluster_label_2: max_cluster_label_2 = dataBase[i].label[1] max_cluster_label_1 = max_cluster_label_1 + 1 max_cluster_label_2 = max_cluster_label_2 + 1 matrix_M = get_matrix_M(max_cluster_label_1, max_cluster_label_2, dataBase) smaller_matrix_M = concatenate_rows(matrix_M, max_cluster_label_1, max_cluster_label_2, minPts) compute_ending_clusters(smaller_matrix_M, max_cluster_label_2) for p in dataBase: if p.label[2] == "UNDEFINED": p.label[2] = -1 return dataBase
def algorythm_dbscan(minPts, eps, data, label_number): dataBase = read_database(data) algorythm_dbscan_without_read(minPts, eps, dataBase, label_number, 0) return dataBase