feat(recommender): ✨ initial sketch of the activity recommender#142
Draft
dvorka wants to merge 1 commit into
Draft
feat(recommender): ✨ initial sketch of the activity recommender#142dvorka wants to merge 1 commit into
dvorka wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an initial activity recommender feature to MyTraL, exposing a new UI page that ranks a user’s historical activities by similarity to a target duration/distance/elevation, and optionally visualizes clustered matches.
Changes:
- Introduces a pure-numpy recommender module (cosine similarity over normalized features) plus clustering/PCA support.
- Adds a new
/app/recommenderroute, form, and UI template, and wires it into the navigation and app startup. - Adds Bokeh scatter plotting for clustered matches and a dedicated pytest suite covering the recommender logic.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
mytral/recommender.py |
Core recommendation + clustering logic (normalize, cosine similarity, k-means, PCA projection). |
mytral/blueprints/recommender_uri_space.py |
New route handling form submission, running recommender, and preparing chart data. |
mytral/forms.py |
Adds ActivityRecommenderForm (filters + numeric query inputs). |
mytral/templates/activity-recommender.html |
New page UI for inputs, results table, and scatter plot container. |
mytral/charts.py |
Adds Bokeh scatter plot renderer for clustered recommender matches. |
mytral/views.py |
Adds ActivityRecommendationView adapter for template-friendly rendering of matches. |
mytral/templates/layout.html |
Adds a navigation entry to reach the recommender page. |
mytral/run.py |
Registers the recommender route module in the web entrypoint. |
mytral/run_desktop.py |
Registers the recommender route module in the desktop entrypoint. |
tests/test_recommender.py |
New unit tests for filtering, normalization, ranking, type voting, and clustering behavior. |
|
|
||
| distance_m = None | ||
| if form.distance_km.data is not None: | ||
| distance_m = int(form.distance_km.data * 1000) |
| <div class="card-body"> | ||
| <p> | ||
| Describe a target session - duration, distance and elevation - and MyTraL ranks your past | ||
| activities by similarity (cosine distance over normalized features), recommends the best |
Comment on lines
+784
to
+791
| class ActivityRecommendationView: | ||
| """Template-friendly wrapper around a scored recommender match.""" | ||
|
|
||
| def __init__(self, activity, score, rank, activity_types): | ||
| self._activity = activity | ||
| self._score = score | ||
| self._rank = rank | ||
| self._activity_types = activity_types |
dvorka
marked this pull request as draft
July 15, 2026 13:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks:
This PR brings initial sketch of the activity recommender.