Skip to content

feat: replace hardcoded collaborative filter in /recommend-events with item-based similarity scoring #159

@BigBen-7

Description

@BigBen-7

Description

/recommend-events uses a toy user-based collaborative filter on a 4-user mock dict. The algorithm counts user-pair overlaps but ignores event popularity, recency, or ticket availability. Item-based similarity (events that are frequently bought together) is more robust for cold-start users and scales better.

Requirements & context

  • Implement build_item_similarity_matrix(user_events_dict) in a new src/recommender.py using cosine similarity between event co-occurrence vectors
  • Replace the current scoring loop in /recommend-events with a call to get_item_recommendations(user_id, user_events_dict, similarity_matrix, top_n=3)
  • The function must handle cold-start: if the user has no purchase history, return the 3 most popular events (highest total purchase count)
  • The user_events_dict should come from the DB (real user scan/purchase history) not the mock — use get_user_events_from_db from the earlier search fix
  • Write unit tests with a known similarity matrix asserting correct top-3 output

Suggested execution

git checkout -b feat/item-based-recommendation
  • Create src/recommender.py
  • Update src/main.py /recommend-events handler
  • Write tests

Guidelines

  • Do not use numpy for this — pure Python dict-based cosine similarity is sufficient and avoids a heavy dependency
  • PR must include: Closes #[issue_id]
  • Timeframe: 72 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or improvementsearchSearch and recommendations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions