code: def membership_vector(clusterer, points_to_predict):
      """Predict soft cluster membership. The result produces a vector
      for each point in ``points_to_predict`` that gives a probability that
      the given point is a member of a cluster for each of the selected clusters
      of the ``clusterer``.
  
      Parameters
      ----------
      clusterer : HDBSCAN
          A clustering object that has been fit to the data and
          either had ``prediction_data=True`` set, or called the
          ``generate_prediction_data`` method after the fact.
  
      points_to_predict : array, or array-like (n_samples, n_features)
          The new data points to predict cluster labels for. They should
          have the same dimensionality as the original dataset over which
          clusterer was fit.
  
      Returns
      -------
      membership_vectors : array (n_samples, n_clusters)
          The probability that point ``i`` is a member of cluster ``j`` is
          in ``membership_vectors[i, j]``.
  
      See Also
      --------
      :py:func:`hdbscan.predict.predict`
      :py:func:`hdbscan.predict.all_points_membership_vectors`"""
  
      points_to_predict = points_to_predict.astype(np.float64)
      clusters = np.array(
          sorted(list(clusterer.condensed_tree_._select_clusters()))
      ).astype(np.intp)
  
      result = np.empty(
          (points_to_predict.shape[0], clusters.shape[0]),
          dtype=np.float64,
      )
  
      min_samples = clusterer.min_samples or clusterer.min_cluster_size
      (
          neighbor_distances,
          neighbor_indices,
      ) = clusterer.prediction_data_.tree.query(
          points_to_predict, k=2 * min_samples
      )
  
      for i in range(points_to_predict.shape[0]):
          # We need to find where in the tree the new point would go
          # for the purposes of outlier membership approximation
          nearest_neighbor, lambda_ = _find_neighbor_and_lambda(
              neighbor_indices[i],
              neighbor_distances[i],
              clusterer.prediction_data_.core_distances,
              min_samples,
          )
  
          neighbor_tree_row = get_tree_row_with_child(
              clusterer.condensed_tree_._raw_tree, nearest_neighbor
          )
  
          if neighbor_tree_row["lambda_val"] <= lambda_:
              lambda_ = neighbor_tree_row["lambda_val"]
  
          distance_vec = dist_membership_vector(
              points_to_predict[i],
              clusterer.prediction_data_.exemplars,
              clusterer.prediction_data_.dist_metric,
          )
          outlier_vec = outlier_membership_vector(
              nearest_neighbor,
              lambda_,
              clusters,
              clusterer.condensed_tree_._raw_tree,
              clusterer.prediction_data_.leaf_max_lambdas,
              clusterer.prediction_data_.cluster_tree,
          )
  
          result[i] = distance_vec**0.5 * outlier_vec**2.0
          result[i] /= result[i].sum()
  
          result[i] *= prob_in_some_cluster(
              nearest_neighbor,
              lambda_,
              clusters,
              clusterer.condensed_tree_._raw_tree,
              clusterer.prediction_data_.leaf_max_lambdas,
              clusterer.prediction_data_.cluster_tree,
          )
  
      return result
  
file_path: hdbscan/hdbscan/prediction.py
imports: import numpy
  from sklearn.neighbors import KDTree, BallTree
  from .dist_metrics import DistanceMetric
  from ._hdbscan_tree import recurse_leaf_dfs
  from ._prediction_utils import get_tree_row_with_child, dist_membership_vector, outlier_membership_vector, prob_in_some_cluster, all_points_dist_membership_vector, all_points_outlier_membership_vector, all_points_prob_in_some_cluster
  from warnings import warn
label_desc: Use image node_id 6 for calling a global function with example usage: membership_vector(clusterer, points_to_predict) and returns: result