Mean Expertise Contribution (MEC) in a tag for a specific user

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- http://yangjiera.github.io/home/works/umap2014_experts.pdf

declare @tag_debate float = (
  select avg(1.0*AnswerCount)
  from Posts q
       join PostTags on q.Id = PostId
       join Tags t on TagId = t.Id
  where TagName = '##tag##'
);

declare @inputid int = ##UserId##;

/* The paper reported 2.27+/-1.74 as the average number of answers to 
   C# questions. I tried using that number, but it didn't radically 
   change the results. */
--declare @tag_debate float = 2.27;

with answers as (
  select a.OwnerUserId UserId,
         1.0/rank() over (partition by q.Id order by a.Score desc) utility,
         1.0*q.AnswerCount debatableness,
         1.0/rank() over (partition by q.Id order by a.Score desc) *
         q.AnswerCount/@tag_debate EC
  from Posts q
       join Posts a on q.Id = a.ParentId
       join PostTags on q.Id = PostId
       join Tags t on TagId = t.Id
  where TagName = '##tag##'
),

user_MEC as (
  select UserId,
         sum(EC)/count(*) MEC,
         avg(utility) AU, 
         avg(debatableness) D,
         @tag_debate D_avg_t,
         count(*) Q_u_t
  from answers
  group by UserId  
)

select * 
from user_MEC
where userid = @inputid

order by MEC desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results