Skip to content

Commit

Permalink
cluster - add minCount argument to sumAccsForQuestionGroups (and impr…
Browse files Browse the repository at this point in the history
…ove docstring)

Ignore-this: 24f98b27ec267f0b3c1be04b2fcfa063

darcs-hash:20130714175915-3a4db-dcc8acafcc8f436ad10155d62bf7a6d540588a53
  • Loading branch information
MattShannon committed Jul 14, 2013
1 parent 3a79fc3 commit d6ad12f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions armspeech/modelling/cluster.py
Expand Up @@ -101,7 +101,20 @@ def sumAccsSecondLevel(self, labelValueToAcc, question):

return accForAnswer

def sumAccsForQuestionGroups(self, labels, questionGroups):
def sumAccsForQuestionGroups(self, labels, questionGroups, minCount = 0.0):
"""Computes the acc for each labelValuer, question and answer.
The returned value is a list with zero or one elements for each
questionGroup; if one element then this element is a list with zero or
one elements for each question; if one element then this element is a
list of accs, one for each possible answer.
We say that a question violates the minimum count constraint if any of
its answers has count less than minCount.
Questions which violate this constraint, and question groups for which
all the questions violate this constraint, are not represented in the
returned value.
"""
labelValueToAccs = self.sumAccsFirstLevel(labels, questionGroups)

accsForQuestionGroups = []
Expand All @@ -112,8 +125,10 @@ def sumAccsForQuestionGroups(self, labels, questionGroups):
for question in questions:
accForAnswer = self.sumAccsSecondLevel(labelValueToAcc,
question)
accsForQuestions.append((question, accForAnswer))
accsForQuestionGroups.append((labelValuer, accsForQuestions))
if all([ acc.count() >= minCount for acc in accForAnswer ]):
accsForQuestions.append((question, accForAnswer))
if accsForQuestions:
accsForQuestionGroups.append((labelValuer, accsForQuestions))

return accsForQuestionGroups

Expand Down

0 comments on commit d6ad12f

Please sign in to comment.