I built a content recommender as a graph, and it found similarities I wasn't looking for
Most beginner recommendation projects are a dictionary lookup. You type "comedy", it returns the comedy list. That works, and it is also the reason those projects are forgettable: a dictionary can tell you what is similar, but it can never tell you what is interestingly different . I wanted the second thing. So I modelled the catalogue as a weighted graph instead, and ended up finding a kind of…
The author developed a content recommender using a weighted graph structure, which enabled it to discover similarities the system hadn't initially anticipated. This project, called CreatorRoute, focuses on recommending short-form video content. Users input a video they like, and the system suggests similar videos, as well as a few unexpected recommendations.
The dataset for CreatorRoute consisted of 40 short-form videos, each with five attributes: id, title, niche, hook type, length, editing style, and call-to-action type. Crucially, each attribute value had to appear in several videos, preventing isolated nodes in the graph. If all videos had distinct hook types, for example, there would be no edges to traverse between them.
To construct the graph, each video served as a node, and edges connected nodes that shared at least one attribute. The weight of each edge was determined by the inverse of the number of shared attributes. For instance, if two videos had four attributes in common, the edge weight would be 0.25; if they shared just one, the weight would be 1.0.
This weighting system ensured that videos with more similarities were considered more closely related, and shortest-path algorithms could rank them accordingly, without the need for additional calculations.
Initially, the author planned to use breadth-first search (BFS) to achieve this. However, BFS proved inadequate. With a small catalogue, nearly every video shared attributes with nearly every other video, resulting in brev distances that did not effectively rank similarity. Dijkstra's algorithm proved more successful. This algorithm walks the graph while accumulating the accumulated weights, resulting in a ranking of similarities that accurately reflected the relationships between videos.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.