if self.n > len(self.points):
raise ValueError("n can"t be higher than the number of points in the PyntCloud.")
remaining_points = self.points.values
solution_set = list()
solution_set.append(remaining_points.pop(
random.randint(0, len(remaining_points) - 1)))
for _ in range(self.n - 1):
distances = [self.cal_distance(p, solution_set[0]) for p in remaining_points]
After Change
remaining_points = self.points.values
// the sampled points set as the return
select_idx = np.random.randint(low=0, high=len(self.points))
// to remain the shape as (1, n) instead of (n, )
solution_set = remaining_points[select_idx: select_idx+1]
remaining_points = np.delete(remaining_points, select_idx)
for _ in range(self.n - 1):
distance_sum = self.cal_distance(remaining_points, solution_set)
select_idx = np.argmax(distance_sum)
solution_set = np.concatenate([solution_set, remaining_points[select_idx:select_idx+1]], axis=0)
remaining_points = np.delete(remaining_points, select_idx)
return pd.DataFrame(solution_set, columns=self.points.columns)