Skip to content

Commit

Permalink
working on discrimination search
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Angell committed Oct 2, 2017
1 parent 237a5ba commit 1c82903
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.*.swp
*.pyc
*.DS_Store
.*
21 changes: 18 additions & 3 deletions Themis2.0/themis.py
Expand Up @@ -5,7 +5,7 @@
from __future__ import division

import commands
import itertools
from itertools import chain, combinations, product
import math
import random
import scipy.stats as st
Expand Down Expand Up @@ -132,7 +132,7 @@ def gen_all_sub_inputs(self, args=[]):
"""
assert args
vals_of_args = [self.inputs[arg].values for arg in args]
combos = [list(elt) for elt in list(itertools.product(*vals_of_args))]
combos = [list(elt) for elt in list(product(*vals_of_args))]
return ({arg : elt[idx] for idx, arg in enumerate(args)} \
for elt in combos)

Expand Down Expand Up @@ -185,6 +185,16 @@ def _merge_assignments(self, assign1, assign2):
merged.update(assign2)
return merged

def _all_relevant_subs(self, xs):
return chain.from_iterable(combinations(xs, n) \
for n in range(1, len(xs)))

def _is_subset(self, small, big):
for x in small:
if x not in big:
return False
return True

def group_discrimination(self, i_fields=None, conf=0.99, margin=0.01):
"""
Compute the group discrimination for characteristics `i_fields`.
Expand Down Expand Up @@ -266,14 +276,19 @@ def causal_discrimination(self, i_fields=None, conf=0.99, margin=0.01):
continue
fixed_assign.update(dyn_sub_assign)
self._add_assignment(test_suite, assign)
count += self.get_test_result(assign=assign)
if self.get_test_result(assign=assign):
count += 1
break

p, end = self._end_condition(count, num_sampled, conf, margin)
if end:
break

return test_suite, p

def discrimination_search(self, threshold=0.3, conf=0.99, margin=0.01):
pass


if __name__ == '__main__':
pass

0 comments on commit 1c82903

Please sign in to comment.