vector<common::sfv_t> kmeans_clustering_method::get_k_center() const {
  if (kcenters_.empty()) {
    throw JUBATUS_EXCEPTION(not_performed());
  }

  return kcenters_;
}
int64_t kmeans_clustering_method::get_nearest_center_index(
    const common::sfv_t& point) const {
  if (kcenters_.empty()) {
    throw JUBATUS_EXCEPTION(not_performed());
  }

  return min_dist(point, kcenters_).first;
}
예제 #3
0
std::vector<wplist> dbscan_clustering_method::get_clusters(
    const wplist& points) const {
  std::vector<wplist> clusters = dbscan_.get_clusters();
  if (clusters.empty()) {
    throw JUBATUS_EXCEPTION(not_performed());
  }
  return clusters;
}
vector<wplist> kmeans_clustering_method::get_clusters(
    const wplist& points) const {
  if (kcenters_.empty()) {
    throw JUBATUS_EXCEPTION(not_performed());
  }

  vector<wplist> ret(k_);
  for (wplist::const_iterator it = points.begin(); it != points.end(); ++it) {
    pair<int64_t, double> m = min_dist(it->data, kcenters_);
    ret[m.first].push_back(*it);
  }
  return ret;
}