Mystic-Trooper / bug-triaging-2

Major II
0 stars 0 forks source link

How to validate the results #2

Open Amitpatil215 opened 1 year ago

Amitpatil215 commented 1 year ago

Here are two functions that use the query you provided to test the accuracy of the recommended developer for a particular bug, one using the MATCH clause and the other using the Adamic-Adar similarity measure:

Using MATCH:

// Function to test accuracy of recommended developer using MATCH
// Parameters:
// - bug_id: ID of the bug to test
// - component: Component of the bug
// - severity: Severity level of the bug
// Returns:
// - A map containing the recommended developer, the actual developer who resolved the bug,
//   and a boolean value indicating whether the recommended developer matches the actual developer
MATCH (b:Bug {bug_id: $bug_id})-[:RESOLVED_BY]->(r:Developer)
WITH r
MATCH (b:Bug)-[:TOSS_TO]->(d:Developer)
WHERE b.component = $component AND b.severity = $severity AND d <> r
WITH d, SUM(CASE b.severity 
             WHEN 'LOW' THEN 1 
             WHEN 'MEDIUM' THEN 2 
             WHEN 'HIGH' THEN 3 
             ELSE 0 END) AS severity_weight, COUNT(*) AS tosses
ORDER BY (tosses * 0.5 + severity_weight * 0.5) ASC
LIMIT 1
RETURN {
  recommended_developer: d.name,
  actual_developer: r.name,
  accuracy: d = r
} AS result

In this function, we first match the developer who actually resolved the bug. We then match all developers who have worked on bugs with the specified component and severity level, except for the developer who resolved the bug. We use the same query you provided to get the recommended developer based on the number of tosses and the severity weight of the bugs they have worked on. Finally, we return a map containing the recommended developer, the actual developer who resolved the bug, and a boolean value indicating whether the recommended developer matches the actual developer.

Using Adamic-Adar:

// Function to test accuracy of recommended developer using Adamic-Adar similarity measure
// Parameters:
// - bug_id: ID of the bug to test
// - component: Component of the bug
// Returns:
// - A map containing the recommended developer, the actual developer who resolved the bug,
//   and the Adamic-Adar similarity score between the recommended developer and the actual developer
MATCH (b:Bug {bug_id: $bug_id})-[:RESOLVED_BY]->(r:Developer)
WITH r, COLLECT(DISTINCT b.component) AS r_components
MATCH (b:Bug)-[:TOSS_TO]->(d:Developer)
WHERE b.component = $component AND d <> r
WITH r, d, COLLECT(DISTINCT b.component) AS d_components
WITH r, d, REDUCE(similarity = 0, component IN FILTER(component IN r_components WHERE component IN d_components) | similarity + 1 / log(SIZE((:Bug {component: component})-[:TOSS_TO]->(d))))
AS adamic_adar_similarity
ORDER BY adamic_adar_similarity DESC
RETURN {
  recommended_developer: d.name,
  actual_developer: r.name,
  adamic_adar_similarity: adamic_adar_similarity
} AS result

In this function, we first match the developer who actually resolved the bug. We then match all developers who have worked on bugs with the specified component, except for the developer who resolved the bug. We calculate the Adamic-Adar similarity between each developer and the developer who resolved the bug, and then order the developers by their similarity score in descending order. Finally, we return a map containing the recommended developer, the actual developer who resolved the bug, and the Adamic-Adar similarity score between the two developers.

Amitpatil215 commented 1 year ago

chatwithgpt.netlify.app-Chat History.pdf