Skip to content

Commit

Permalink
chore: typos
Browse files Browse the repository at this point in the history
  • Loading branch information
alee committed May 11, 2024
1 parent b773365 commit 590a4c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions django/curator/spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ def choices(cls):
class SpamDetectionContext:
"""
Manages the spam detection process, including setting up classifiers, encoders, and handling data.
specific to Users + MemberProfile + UserSpamStatus
"""

def __init__(self, contex_id: PresetContextID):
def __init__(self, context_id: PresetContextID):
"""
Initializes a spam detection context with a specified context configuration.
Params:
context_id (PresetContextID): The context ID from PresetContextID enum defining the configuration.
"""
self.contex_id = contex_id
self.context_id = context_id
self.classifier: SpamClassifier = None
self.encoder: Encoder = None
self.categorical_encoder = CategoricalFieldEncoder()
Expand Down Expand Up @@ -182,7 +184,7 @@ def predict(self, user_ids: List[int] = None):

model = self.classifier.load()
result_df = self.classifier.predict(model, feats)
processor.save_predictions(result_df, self.contex_id)
processor.save_predictions(result_df, self.context_id)


class SpamDetectionContextFactory:
Expand All @@ -203,18 +205,18 @@ def create(
Returns:
SpamDetectionContext: The newly created spam detection context.
"""
spam_detection_contex = SpamDetectionContext(context_id)
spam_detection_context = SpamDetectionContext(context_id)
context_id_value = context_id.value.split()

classifier_class_ = getattr(spam_classifiers, context_id_value[0])
selected_classifier = classifier_class_(context_id.name)
spam_detection_contex.set_classifier(selected_classifier)
spam_detection_context.set_classifier(selected_classifier)

encoder_class_ = getattr(spam_classifiers, context_id_value[1])
selected_encoder = encoder_class_(context_id.name)
spam_detection_contex.set_encoder(selected_encoder)
spam_detection_context.set_encoder(selected_encoder)

selected_fields = PresetContextID.fields(context_id.value)
spam_detection_contex.set_fields(selected_fields)
spam_detection_context.set_fields(selected_fields)

return spam_detection_contex
return spam_detection_context
2 changes: 2 additions & 0 deletions django/curator/spam_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def __init__(self):
"numerical": ["user_id", "label"],
}

# bidirectional map
self.db_df_field_mapping = {
# FIXME: could probably build this dynamically from the two lists
self.db_fields[0]: self.df_fields[0],
self.db_fields[1]: self.df_fields[1],
self.db_fields[2]: self.df_fields[2],
Expand Down

0 comments on commit 590a4c4

Please sign in to comment.