Skip to content

feat(recommender): ✨ initial sketch of the activity recommender#142

Draft
dvorka wants to merge 1 commit into
dev/1.59.0from
feat-20260710/recommender
Draft

feat(recommender): ✨ initial sketch of the activity recommender#142
dvorka wants to merge 1 commit into
dev/1.59.0from
feat-20260710/recommender

Conversation

@dvorka

@dvorka dvorka commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Tasks:

  • as expected, vector-based activity (w/ possible feature embeddings add-on) lookup does not work quite well, it's rather useful to have some fun. Not sure whether I will have any use for it, except catchy cluster chart.
  • instead of vector/cosine design a reasonable valuation function / metric which will bring the most similar activities based on the time/distance/elevation delta (properly weighted).

This PR brings initial sketch of the activity recommender.

@dvorka dvorka self-assigned this Jul 10, 2026
Copilot AI review requested due to automatic review settings July 10, 2026 09:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/recommender route, 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 thread mytral/views.py
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
dvorka marked this pull request as draft July 15, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants