def get_note_tag_aggregates(
  ratings: pd.DataFrame, noteParams: pd.DataFrame, raterParams: pd.DataFrame
) -> pd.DataFrame:
  """Computes non-helpful tag aggregates for each note.

  Args:
    ratings: initial input ratings DF containing all ratings
    noteParams: MF results for notes
    raterParams: MF results for raters

  Returns:
    pd.DataFrame containing one row per note that was scored during MF.  Columns correspond to
    aggregates for the Not-Helpful tags, including raw totals, totals adjusted based on the
    distance between the rater and the note and ratios based on the adjusted weight totals.
  """
  # Obtain a weight for each rating.  Note that since weights are defined using the note and rater
  # embedding factors, obtaining a weight inherently filters out ratings where either the note or
  # rater were not included in matrix factorization.
  ratingWeights = _get_rating_weight(ratings, noteParams, raterParams)
  # Filter ratings to only the columns which we need.
  ratings = ratings[[c.noteIdKey, c.raterParticipantIdKey] + c.notHelpfulTagsTSVOrder]
  # Add weights to ratings, which will inherently filter out ratings where either the note or
  # rater were not included in matrix factorization.
  ratings = ratings.merge(ratingWeights, on=[c.noteIdKey, c.raterParticipantIdKey], how="inner")
  # Introduce scaled tag columns, and drop original columns
  adjustedRatings = ratings[c.notHelpfulTagsTSVOrder].multiply(
    ratings[c.ratingWeightKey], axis="rows"
  )
  adjustedRatings.columns = c.notHelpfulTagsAdjustedColumns
  ratings = ratings.drop(columns=c.notHelpfulTagsTSVOrder)
  ratings = pd.concat([ratings, adjustedRatings], axis="columns")
  # Aggregate by note to get adjusted tag and weight totals for each note.
  ratings = ratings.drop(columns=c.raterParticipantIdKey)
  noteTagAggregates = ratings.groupby(c.noteIdKey).sum().reset_index()
  adjustedRatioRatings = noteTagAggregates[c.notHelpfulTagsAdjustedColumns].divide(
    noteTagAggregates[c.ratingWeightKey], axis="rows"
  )
  adjustedRatioRatings.columns = c.notHelpfulTagsAdjustedRatioColumns
  noteTagAggregates = pd.concat([noteTagAggregates, adjustedRatioRatings], axis="columns")
  return noteTagAggregates
Computes non-helpful tag aggregates for each note.

  Args:
    ratings: initial input ratings DF containing all ratings
    noteParams: MF results for notes
    raterParams: MF results for raters

  Returns:
    pd.DataFrame containing one row per note that was scored during MF.  Columns correspond to
    aggregates for the Not-Helpful tags, including raw totals, totals adjusted based on the
    distance between the rater and the note and ratios based on the adjusted weight totals.
  
sourcecode/scoring/tag_filter.py