Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small improvements to comment and logging messages for _filter_misleading_notes #206

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions sourcecode/scoring/process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,13 @@ def _filter_misleading_notes(
"""
This function actually filters ratings (not notes), based on which notes they rate.

Filter out ratings of notes that say the Tweet isn't misleading.
Also filter out ratings of deleted notes, unless they were deleted after
c.deletedNotesTombstoneLaunchTime, and appear in noteStatusHistory.
Keep ratings of undeleted notes that either:
- say the Tweet is misleading
- OR it's after the new UI launch time, c.notMisleadingUILaunchTime.
(After that timestamp, we start assessing the helpfulness of notes that say the Tweet isn't misleading.
Before that timestamp, we did not assess the helpfulness of such notes.)
Also keep ratings of deleted notes if:
- they were scored in noteStatusHistory

Args:
notes (pd.DataFrame): _description_
Expand Down Expand Up @@ -228,13 +232,16 @@ def _filter_misleading_notes(
f"Preprocess Data: Filter misleading notes, starting with {len(ratings)} ratings on {len(np.unique(ratings[c.noteIdKey]))} notes"
)
print(
f" Keeping {ratings[notDeletedMisleadingKey].sum()} ratings on {len(np.unique(ratings.loc[ratings[notDeletedMisleadingKey],c.noteIdKey]))} misleading notes"
f" Keeping {ratings[notDeletedMisleadingKey].sum()} ratings on {len(np.unique(ratings.loc[ratings[notDeletedMisleadingKey],c.noteIdKey]))} notes that claim the tweet is misleading"
)
print(
f" Keeping {ratings[deletedButInNSHKey].sum()} ratings on {len(np.unique(ratings.loc[ratings[deletedButInNSHKey],c.noteIdKey]))} deleted notes that were previously scored (in note status history)"
)
print(
f" Removing {notDeletedNotMisleadingOldUI.sum()} ratings on {len(np.unique(ratings.loc[notDeletedNotMisleadingOldUI, c.noteIdKey]))} older notes that aren't deleted, but are not-misleading."
f" Keeping {notDeletedNotMisleadingNewUI.sum()} ratings on {len(np.unique(ratings.loc[notDeletedNotMisleadingNewUI,c.noteIdKey]))} notes that do not claim the tweet is misleading, but after the new UI launch time"
)
print(
f" Removing {notDeletedNotMisleadingOldUI.sum()} ratings on {len(np.unique(ratings.loc[notDeletedNotMisleadingOldUI, c.noteIdKey]))} older notes that aren't deleted, but do not claim the tweet is misleading."
)
print(
f" Removing {deletedNotInNSH.sum()} ratings on {len(np.unique(ratings.loc[deletedNotInNSH, c.noteIdKey]))} notes that were deleted and not in note status history (e.g. old)."
Expand All @@ -255,7 +262,7 @@ def _filter_misleading_notes(
return ratings


def remove_duplicate_ratings(ratings: pd.DataFrame) -> pd.DataFrame:
def remove_duplicate_ratings(ratings: pd.DataFrame) -> pd.DataFrame:
"""Drop duplicate ratings, then assert that there is exactly one rating per noteId per raterId.

Args:
Expand Down