Permalink
Browse files

making some changes

  • Loading branch information...
Rico Angell
Rico Angell committed Sep 30, 2017
1 parent 6979d0a commit eb3bbb4e6f9b82fee43b1ea0e5fea877826f8948
Showing with 22 additions and 30 deletions.
  1. +6 −6 Themis1.0/Themis.py
  2. +13 −7 Themis1.0/main.py
  3. +3 −17 Themis2.0/themis.py
View
@@ -3,6 +3,7 @@
import commands
import random
import math
import copy
class soft:
conf_zValue = {80:1.28,90:1.645,95:1.96, 98:2.33, 99:2.58}
@@ -12,12 +13,11 @@ class soft:
cache = {}
def __init__(self, names, values, num, command, type):
self.attr_names = names
self.values = values
self.num = num
self.type = type
self.command = command
self.attr_names = copy.deepcopy(names)
self.values = copy.deepcopy(values)
self.num = copy.deepcopy(num)
self.type = copy.deepcopy(type)
self.command = copy.deepcopy(command)
def getValues(self):
return self.values
View
@@ -5,10 +5,10 @@
import Themis
def load_soft_from_settings():
names={}
types={}
values={}
num_values={}
names=[]
types=[]
values=[]
num_values=[]
tree = ET.parse('settings.xml')
root = tree.getroot()
@@ -30,17 +30,23 @@ def load_soft_from_settings():
assert false
num_values[uid] = len(values[uid])
print names
print values
print num_values
print command
print types
return Themis.soft(names, values, num_values, command, types)
if __name__ == '__main__':
soft = load_soft_from_settings()
D = soft.discriminationSearch(0.2,0.99,0.1,"groupandcausal")
soft.printSoftwareDetails()
#D = soft.discriminationSearch(0.2,0.99,0.1,"groupandcausal")
#print "\n\n\nThemis has completed \n"
print "Software discriminates against ", D
#print "Software discriminates against ", D
#X=[0,2]
#print soft.groupDiscrimination(X,99,0.1)
#print soft.causalDiscrimination(X,99,0.1)
print soft.getTestSuite()
#print soft.getTestSuite()
View
@@ -44,6 +44,8 @@ def __init__(xml_fname=""):
random.seed(int(root.find("seed").text))
self.max_samples = 50
self.min_samples = 10
self.software_name = root.find("name").text
self.command = root.find("command").text.strip
self._build_input_space(args=root.find("inputs"))
@@ -85,22 +87,6 @@ def run(self):
#TODO: make this general
group_discrimination(field=["Race"])
def construct_inputs_and_run(self, assignment=None):
"""
Run the software on the input `assignment`.
Parameters
----------
assignment : dict
dictionary of all input assignments.
Returns
-------
str
"0" or "1", the output of the software.
"""
pass
def new_random_sub_input(self, args=[]):
"""
Produce a random input for the each of the elements of `attributes`.
@@ -162,7 +148,7 @@ def get_test_result(self, assignment=None):
return self.cache[tupled_args]
cmd = self.command + " " + " ".join(tupled_args)
self.cache[tupled_args] = commands.getstatusoutput(cmd)[1]
self.cache[tupled_args] = commands.getoutput(cmd).strip
return output
def group_discrimination(self, fields=None, conf=0.99, margin=0.01):

0 comments on commit eb3bbb4

Please sign in to comment.