Community-sensitive recommendation system for personalized matching between patients and doctors in bipartite graphs

Kunumi

20 min

Community-sensitive recommendation system for personalized matching between patients and doctors in bipartite graphs

Doctors, maps and machines: reinventing trust networks in health

In large cities, the simple act of finding a doctor can turn into a game of trial and error. Trust networks among health professionals exist, but remain invisible and inaccessible to patients. When a general practitioner recommends a specialist, that advice is not always followed — especially if the recommendation involves long commutes. The problem is old and recurring: how to match efficient access to healthcare with interpersonal trust?

The paper “Community-Aware Recommender System for Personalized Patient–Physician Matchmaking on Bipartite Graphs”, signed by researchers from Kunumi in partnership with Unimed-BH, revisits this dilemma with a provocative proposal: to transform the network of relationships between doctors into an intelligent recommendation system. For this, they combine community detection algorithms, complex network techniques, and real data from nearly 10 million medical consultations in the metropolitan region of Belo Horizonte.

Motivation is not just technical. It is a human, logistical, and ethical challenge. How to create personalized recommendations that respect patients' preferences, the trust networks among doctors, and at the same time avoid exhausting displacements? Before this work, the field had solutions that, in general, ignored the geographic factor or required explicit user inputs — such as ratings or declared preferences. It was a fertile field for innovation.

Trust shortcuts: a network that explains itself from within

The central proposal of the paper is, at first glance, simple: to use the community structure in the network of relationships between doctors as shortcuts in a bipartite graph that connects patients to doctors. But, as always in data science, the devil is in the details.

The work starts from the recognition that doctors tend to form clusters of trust, fueled by interactions such as co-authorships, congresses, academic exchanges and even simple professional coexistence. These communities — analogous to “neighborhoods” of medical cooperation — directly influence the dynamics of referrals. If a patient frequents doctors from the same community, it is more likely that they trust the recommendations within that group.

What the system proposes is to use these communities as a support structure to refine recommendation algorithms. The innovation lies in the way these communities are detected: from real medical attendance data, with temporal analysis, geographic location and patient co-occurrence. The idea is to build a graph between doctors, where each edge represents patients in common. From there, an adaptation of the Louvain algorithm is used to identify communities — respecting not only the density of connections but also the geolocation of medical offices.

Instead of recommending any doctor based on generic criteria (such as specialty or rating), the system prioritizes doctors from the same community that the patient has already frequented — and who are physically nearby. The logic is as follows: if the patient trusts a doctor, and that doctor is part of a network with other colleagues who attend in the surroundings, why not prioritize these connections?

Networks, weights and trajectories: the anatomy of a conscious recommendation system

The backbone of the method is a recommendation system based on bipartite graphs, where one set of nodes represents patients and the other, doctors. An edge between the two indicates that there was an appointment. The weight of this connection reflects the number of appointments held — a kind of “strength” of the relationship.

The first step is the construction of the doctor-doctor graph, which uses as a criterion the co-occurrence of patients within intervals of up to 180 days between appointments. This allows identifying implicit relationships between professionals. To avoid noise, connections with lower weight (the bottom 70%) are discarded. On average, the resulting graph has about 2,000 doctors and more than 150 thousand connections per year. The second graph connects patients and doctors — and serves as the basis for the recommendation stage.

But what makes this system “community-aware” is not just the presence of communities, but how they are used as shortcuts in the recommendation. Instead of blindly navigating through possibilities, the system resorts to BiRank, a ranking algorithm that favors indirect but reliable connections. The logic is similar to the idea of “friend of a friend”: if the patient went to doctor A, and A usually attends patients who also visit doctor B, then B is a good candidate.

The twist here is that this transition between A and B is facilitated by the communities. Instead of scouring the entire graph, the algorithm restricts itself to the medical communities that the patient has already frequented — and that are located in nearby geographic areas. This results in more cohesive recommendations, both from a clinical and logistical point of view.

Mathematical modeling incorporates adaptations to Louvain, a traditional community detection algorithm. Three variations were proposed:

  • Louvain-Connected: restriction to geographic contiguity;
  • Louvain-DBSCAN: use of clustering to divide the graph into dense zones;
  • Louvain-Dual: simultaneous integration of relation and location graphs, optimizing modularity in both.

From these variations, communities are identified and used as recommendation hubs. The intuition is clear: communities are shortcuts, not barriers.

When doctors form neighborhoods and algorithms become guides: a new cartography of health

The strength of labor appears clearly in the experimental section. The analysis starts from three essential questions: how does the inclusion of geographic data affect community detection? How do these communities improve recommendation? And to what extent does the BiRank model, enhanced by these communities, generate more efficient referral networks?

Doctors from the same block: when trust is also geographical

The communities identified by Louvain-Dual presented modularity of 0.199, with silhouette of 0.622 and average internal distance of only 0.017 km — numbers significantly higher than those of the traditional version of Louvain. This shows that the generated clusters are more cohesive and spatially organized. The analogy here is direct: doctors who share patients and attend close to each other indeed form “medical neighborhoods”

This behavior was corroborated by the temporal stability of the communities. The ARI (Adjusted Rand Index) metric revealed values above 0.7 in consecutive years, indicating that the communities are robust and persist even with the entry of new professionals or changes of address.

Recommending with neighborhood precision: an algorithmic neighborhood

In the recommendation tests, the Community-Based BiRank approach outperformed the traditional BiRank and the current Unimed-BH system. The NDCG@5% — which measures the quality of the recommendation in the top 5% of the ranking — was 0.435 for the proposed method, against 0.413 for BiRank and 0.046 for the current baseline. This represents a jump of almost 10 times compared to the original system.

More interesting is the spatial behavior of the recommendations. The average distance between the patient and the highest ranked doctor dropped to 0.7 km with the new method, while in the traditional BiRank it was 4.31 km. This means that the system not only recommends more accurately, but does so respecting the real displacement of people.

Imagine scheduling an appointment and receiving as a suggestion a doctor a few blocks away, who works in the same area as the doctors you already visit — and who is part of the same trusted network. This is the experience that the system proposes.

Breaking down the logic of superconnected doctors

Another important gain is in mitigating the rich-club effect. In the doctor-patient graph, certain doctors have a high degree of connectivity — usually because they are older or famous. BiRank tends to favor these central figures. But the use of communities allows new doctors, less connected globally and well positioned locally, to gain visibility. This makes the system more inclusive, plural, and fair.

The metaphor here is powerful: instead of building prestigious skyscrapers, the algorithm builds neighborhoods of trust. And neighborhoods have corners, new neighbors, and alternative paths.

An invitation to boldness: can health systems listen better?

Work is not limited to proposing an efficient recommendation system. It invites us to rethink how invisible networks — of trust, co-occurrence, proximity — can be explored ethically and usefully for real people. In times of algorithms that often ignore context, this research reminds us that location, bonds, and past experiences are too valuable to be discarded.

More than a technical solution, we have here a model of algorithmic citizenship: respecting where people live, where they circulate and who they trust. The next step? Test the system with real users, incorporate feedback, adapt communities to the rhythm of cities.

What if we go further? What if we include the waiting time to schedule an appointment? Or the days each doctor attends? Or even the empathy and communication evaluations made by patients? The architecture is ready. Now, it is time to feed the system with multiple voices and perspectives.

This work shows that it is possible to do more than just recommend. We can build routes. Map neighborhoods. Cultivate trust. The algorithm, in this case, is not just a filter. It is a guide — and perhaps, a new compass for urban health.

Want to better understand how this was done? The full article offers valuable details about the data used, the variations of the Louvain algorithm, and how BiRank was adapted. It is worth reading for those who want to delve into the meeting point of complex networks, public health, and artificial intelligence.

Kunumi is a research collective from the Global South to the world.
I want to learn aboutScience
Network of laboratories and strategic alliances for scientific development

Debug Parameters

Press K to toggle this modal