Skip to content

feat: sort course name autocomplete results by totalStudents#620

Open
SinhSinhAn wants to merge 7 commits into
developfrom
517-course-name-sort-by-students
Open

feat: sort course name autocomplete results by totalStudents#620
SinhSinhAn wants to merge 7 commits into
developfrom
517-course-name-sort-by-students

Conversation

@SinhSinhAn
Copy link
Copy Markdown

@SinhSinhAn SinhSinhAn commented Apr 18, 2026

Summary

When a user searches by course name (e.g. "machine learning" instead of "CS 4375"), the autocomplete results were ranked purely by text relevance. This meant that obscure or graduate-level courses could appear above popular undergrad ones even when they were equally relevant matches for example, CS 6375 showing up before CS 4375.

This PR fixes that by using enrollment data as a tiebreaker. Here is what changed:

src/scripts/generateCourseNameTable.ts The script that builds course_name_table.json now computes a totalStudents value for each course entry by summing total_students across every section across every academic session in the aggregated data. This follows the same pattern already used in generateAutocompleteGraph.ts from PR #572.

src/app/api/courseNameAutocomplete/route.ts After the existing relevance filter (distance + standard deviation cutoff), results are now sorted by totalStudents descending before being returned. Courses that more students have taken will rank above equally-relevant but less popular ones.

Note: course_name_table.json needs to be regenerated via npm run buildcoursenames for the totalStudents values to appear in the output.

Closes #517

@SinhSinhAn SinhSinhAn requested a review from egsch as a code owner April 18, 2026 18:49
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
utd-trends Ready Ready Preview, Comment May 5, 2026 11:20pm

Request Review

Comment thread src/app/api/courseNameAutocomplete/route.ts Outdated
Comment thread src/app/planner/Planner.tsx Outdated
Comment thread src/scripts/generateCourseNameTable.ts
Comment thread src/scripts/generateCourseNameTable.ts
Comment thread src/app/api/courseNameAutocomplete/route.ts
@AbhiramTadepalli
Copy link
Copy Markdown
Contributor

Question: should we include totalStudents as a weighted parameter in the algo as well? Searching for "Machine Learning" doesn't show CS 4375 because it misses the cutoff ("Introduction to Machine Learning" has a bigger edit distance than, say "Statistical Machine Learning")

@TyHil
Copy link
Copy Markdown
Member

TyHil commented Apr 20, 2026

I think the issue was to use totalStudents as a weighted parameter. Since the results of the course name search are already sorted by the algorithms determined similarity, we don't need to override that and sort by totalStudents but instead factor that into the existing sorting

Add totalStudents to each entry in course_name_table.json by summing
total_students across all sections and academic sessions. Use this as
a secondary sort in courseNameAutocomplete so more popular courses
(e.g. CS 4375) surface above obscure ones when search terms are equal.

Closes #517
Use log10(totalStudents) as a weighted popularity bonus in the distance
calculation so popular courses survive the std dev cutoff. This helps
courses like CS 4375 rank above CS 6375 for "machine learning" even
though "Introduction to Machine Learning" has a larger edit distance
than "Statistical Machine Learning".
Copy link
Copy Markdown
Contributor

@AbhiramTadepalli AbhiramTadepalli left a comment

Choose a reason for hiding this comment

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

LGTM

@TyHil
Copy link
Copy Markdown
Member

TyHil commented May 6, 2026

Once this is merged, would whoever merges it add a quick issue to Notebook to replicate this functionality there? Just link to this PR and say the issue is waiting on UTDNebula/utd-notebook#173 if that PR is not already merged.

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.

[Feature Request] Improve homepage search result

4 participants