def get_parameters(self): """ This function creates some parameters to be used with DBScan. @return: A tuple with the generated parameters and an empty list corresponding to the clusterings. """ run_parameters = [] # (minpts, eps tuples) if "max" in self.parameters["clustering"]["algorithms"]["dbscan"]: max_eps_tries = self.parameters["clustering"]["algorithms"]["dbscan"]["max"] else: max_eps_tries = 10 num_elements = self.distance_matrix.row_length klist = k_scale_gen(math.log(num_elements)) buffer = numpy.empty(num_elements) kdist_matrix = k_dist(klist, buffer, self.distance_matrix) dbscan_param_pairs = dbscanTools.dbscan_param_space_search(self.parameters["clustering"]["evaluation"]["maximum_noise"], max_eps_tries, num_elements, klist, kdist_matrix) +\ zhou_adaptative_determination(kdist_matrix, self.distance_matrix) for (minpts, eps) in dbscan_param_pairs: run_parameter = ParametersGenerator.get_base_parameters() run_parameter["minpts"] = minpts run_parameter["eps"] = eps run_parameters.append(run_parameter) return run_parameters, []
def test_dbscan_param_space_search(self): distances = CondensedMatrix( [0., 0., 2., 2., 2., 0., 2., 2., 3., 2., 2., 3., 4., 4., 0.]) k_list = numpy.array([2, 4]) N = distances.row_length #5 kdist_matrix = numpy.array([[1., 2., 3., 4., 5., 6.], [5., 6., 7., 8., 9., 7.]]) param_pairs = dbscan_param_space_search( 90, # 90# noise 2, N, k_list, kdist_matrix) self.assertItemsEqual(param_pairs, [(2, 1.0), (4, 5.0), (2, 3.0), (4, 7.0), (2, 5.0), (4, 9.0)])
def test_dbscan_param_space_search(self): distances = CondensedMatrix([ 0., 0., 2., 2., 2., 0., 2., 2., 3., 2., 2., 3., 4., 4., 0.]) k_list = numpy.array([2,4]) N = distances.row_length #5 kdist_matrix = numpy.array([[1.,2.,3.,4.,5.,6.], [5.,6.,7.,8.,9.,7.]]) param_pairs = dbscan_param_space_search( 90, # 90# noise 2, N, k_list, kdist_matrix) self.assertItemsEqual(param_pairs, [(2, 1.0), (4, 5.0), (2, 3.0), (4, 7.0), (2, 5.0), (4, 9.0)])