Skip to content

Commit

Permalink
revise significant change
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed Jan 3, 2017
1 parent 72db781 commit 444a2f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions associations/associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Associator():
possible. Feed it a simpler histogram to test broader
subpopulations.
"""
def __init__(self, histogram, desired, notable=1, significant=3):
def __init__(self, histogram, desired, notable=1, significant=10):
# Ratio with average (or inverse) to be included.
self.notable = notable
# Number of items to be statistically significant.
Expand Down Expand Up @@ -91,18 +91,21 @@ def find(self):
} } }
Return all associations with both data structures: pairs and subpops
"""
sig = self.significant
for pair_type in combinations(self.hist.fields, 2):
subpop_type = [f for f in self.hist.fields if f not in pair_type]
simple_subpops_hist = self.hist.simplify(*subpop_type)
for subpop, subtotal in simple_subpops_hist.nonzeros():
if subtotal < self.significant:
if subtotal < sig:
continue
subpop_hist = self.hist.slice(*subpop)
mini_hists = [
subpop_hist.simplify(field_type) for field_type in pair_type
]
for pair, pair_total in subpop_hist.nonzeros():
totals = [mini_hists[i].get(f) for i, f in enumerate(pair)]
if totals[0] < sig or totals[1] < sig:
continue
assoc_ratio = pair_total * subtotal / (totals[0] * totals[1])
self.add(pair_type, pair, subpop, assoc_ratio)
return self.pairs, self.subpops
Expand Down

0 comments on commit 444a2f7

Please sign in to comment.