code: def _bulk_precision(recs, truth, k=None):
      if k is not None:
          recs = recs[recs["rank"] <= k]
          lcounts = pd.Series(k, index=recs["LKRecID"].unique())
          lcounts.index.name = "LKRecID"
      else:
          lcounts = recs.groupby(["LKRecID"])["item"].count()
  
      good = recs.join(truth, on=["LKTruthID", "item"], how="inner")
      gcounts = good.groupby(["LKRecID"])["item"].count()
  
      lcounts, gcounts = lcounts.align(
          gcounts, join="left", fill_value=0
      )
  
      return gcounts / lcounts
  
file_path: lkpy/lenskit/metrics/topn.py
imports: import logging
  import warnings
  import numpy
  import pandas
label_desc: Use image node_id 3 for calling a global function with example usage: _bulk_precision(recs, truth, k) and returns: unknown