Skip to content

Commit c2bfe0d

Browse files
committed
Merge branch 'main' of https://github.com/NGO-Algorithm-Audit/AI-web-tool into synthetic-data
2 parents 8f7cc46 + 94ed00b commit c2bfe0d

23 files changed

+1632
-167
lines changed

package-lock.json

Lines changed: 1081 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"react-dom": "^18.3.1",
4242
"react-dropzone": "^14.2.3",
4343
"react-hook-form": "^7.53.0",
44+
"react-markdown": "^9.0.1",
4445
"react-to-print": "^3.0.1",
4546
"tailwind-merge": "^2.5.2",
4647
"tailwindcss-animate": "^1.0.7",

public/iris.csv

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
"sepal.length","sepal.width","petal.length","petal.width","variety"
2+
5.1,3.5,1.4,.2,"Setosa"
3+
4.9,3,1.4,.2,"Setosa"
4+
4.7,3.2,1.3,.2,"Setosa"
5+
4.6,3.1,1.5,.2,"Setosa"
6+
5,3.6,1.4,.2,"Setosa"
7+
5.4,3.9,1.7,.4,"Setosa"
8+
4.6,3.4,1.4,.3,"Setosa"
9+
5,3.4,1.5,.2,"Setosa"
10+
4.4,2.9,1.4,.2,"Setosa"
11+
4.9,3.1,1.5,.1,"Setosa"
12+
5.4,3.7,1.5,.2,"Setosa"
13+
4.8,3.4,1.6,.2,"Setosa"
14+
4.8,3,1.4,.1,"Setosa"
15+
4.3,3,1.1,.1,"Setosa"
16+
5.8,4,1.2,.2,"Setosa"
17+
5.7,4.4,1.5,.4,"Setosa"
18+
5.4,3.9,1.3,.4,"Setosa"
19+
5.1,3.5,1.4,.3,"Setosa"
20+
5.7,3.8,1.7,.3,"Setosa"
21+
5.1,3.8,1.5,.3,"Setosa"
22+
5.4,3.4,1.7,.2,"Setosa"
23+
5.1,3.7,1.5,.4,"Setosa"
24+
4.6,3.6,1,.2,"Setosa"
25+
5.1,3.3,1.7,.5,"Setosa"
26+
4.8,3.4,1.9,.2,"Setosa"
27+
5,3,1.6,.2,"Setosa"
28+
5,3.4,1.6,.4,"Setosa"
29+
5.2,3.5,1.5,.2,"Setosa"
30+
5.2,3.4,1.4,.2,"Setosa"
31+
4.7,3.2,1.6,.2,"Setosa"
32+
4.8,3.1,1.6,.2,"Setosa"
33+
5.4,3.4,1.5,.4,"Setosa"
34+
5.2,4.1,1.5,.1,"Setosa"
35+
5.5,4.2,1.4,.2,"Setosa"
36+
4.9,3.1,1.5,.2,"Setosa"
37+
5,3.2,1.2,.2,"Setosa"
38+
5.5,3.5,1.3,.2,"Setosa"
39+
4.9,3.6,1.4,.1,"Setosa"
40+
4.4,3,1.3,.2,"Setosa"
41+
5.1,3.4,1.5,.2,"Setosa"
42+
5,3.5,1.3,.3,"Setosa"
43+
4.5,2.3,1.3,.3,"Setosa"
44+
4.4,3.2,1.3,.2,"Setosa"
45+
5,3.5,1.6,.6,"Setosa"
46+
5.1,3.8,1.9,.4,"Setosa"
47+
4.8,3,1.4,.3,"Setosa"
48+
5.1,3.8,1.6,.2,"Setosa"
49+
4.6,3.2,1.4,.2,"Setosa"
50+
5.3,3.7,1.5,.2,"Setosa"
51+
5,3.3,1.4,.2,"Setosa"
52+
7,3.2,4.7,1.4,"Versicolor"
53+
6.4,3.2,4.5,1.5,"Versicolor"
54+
6.9,3.1,4.9,1.5,"Versicolor"
55+
5.5,2.3,4,1.3,"Versicolor"
56+
6.5,2.8,4.6,1.5,"Versicolor"
57+
5.7,2.8,4.5,1.3,"Versicolor"
58+
6.3,3.3,4.7,1.6,"Versicolor"
59+
4.9,2.4,3.3,1,"Versicolor"
60+
6.6,2.9,4.6,1.3,"Versicolor"
61+
5.2,2.7,3.9,1.4,"Versicolor"
62+
5,2,3.5,1,"Versicolor"
63+
5.9,3,4.2,1.5,"Versicolor"
64+
6,2.2,4,1,"Versicolor"
65+
6.1,2.9,4.7,1.4,"Versicolor"
66+
5.6,2.9,3.6,1.3,"Versicolor"
67+
6.7,3.1,4.4,1.4,"Versicolor"
68+
5.6,3,4.5,1.5,"Versicolor"
69+
5.8,2.7,4.1,1,"Versicolor"
70+
6.2,2.2,4.5,1.5,"Versicolor"
71+
5.6,2.5,3.9,1.1,"Versicolor"
72+
5.9,3.2,4.8,1.8,"Versicolor"
73+
6.1,2.8,4,1.3,"Versicolor"
74+
6.3,2.5,4.9,1.5,"Versicolor"
75+
6.1,2.8,4.7,1.2,"Versicolor"
76+
6.4,2.9,4.3,1.3,"Versicolor"
77+
6.6,3,4.4,1.4,"Versicolor"
78+
6.8,2.8,4.8,1.4,"Versicolor"
79+
6.7,3,5,1.7,"Versicolor"
80+
6,2.9,4.5,1.5,"Versicolor"
81+
5.7,2.6,3.5,1,"Versicolor"
82+
5.5,2.4,3.8,1.1,"Versicolor"
83+
5.5,2.4,3.7,1,"Versicolor"
84+
5.8,2.7,3.9,1.2,"Versicolor"
85+
6,2.7,5.1,1.6,"Versicolor"
86+
5.4,3,4.5,1.5,"Versicolor"
87+
6,3.4,4.5,1.6,"Versicolor"
88+
6.7,3.1,4.7,1.5,"Versicolor"
89+
6.3,2.3,4.4,1.3,"Versicolor"
90+
5.6,3,4.1,1.3,"Versicolor"
91+
5.5,2.5,4,1.3,"Versicolor"
92+
5.5,2.6,4.4,1.2,"Versicolor"
93+
6.1,3,4.6,1.4,"Versicolor"
94+
5.8,2.6,4,1.2,"Versicolor"
95+
5,2.3,3.3,1,"Versicolor"
96+
5.6,2.7,4.2,1.3,"Versicolor"
97+
5.7,3,4.2,1.2,"Versicolor"
98+
5.7,2.9,4.2,1.3,"Versicolor"
99+
6.2,2.9,4.3,1.3,"Versicolor"
100+
5.1,2.5,3,1.1,"Versicolor"
101+
5.7,2.8,4.1,1.3,"Versicolor"
102+
6.3,3.3,6,2.5,"Virginica"
103+
5.8,2.7,5.1,1.9,"Virginica"
104+
7.1,3,5.9,2.1,"Virginica"
105+
6.3,2.9,5.6,1.8,"Virginica"
106+
6.5,3,5.8,2.2,"Virginica"
107+
7.6,3,6.6,2.1,"Virginica"
108+
4.9,2.5,4.5,1.7,"Virginica"
109+
7.3,2.9,6.3,1.8,"Virginica"
110+
6.7,2.5,5.8,1.8,"Virginica"
111+
7.2,3.6,6.1,2.5,"Virginica"
112+
6.5,3.2,5.1,2,"Virginica"
113+
6.4,2.7,5.3,1.9,"Virginica"
114+
6.8,3,5.5,2.1,"Virginica"
115+
5.7,2.5,5,2,"Virginica"
116+
5.8,2.8,5.1,2.4,"Virginica"
117+
6.4,3.2,5.3,2.3,"Virginica"
118+
6.5,3,5.5,1.8,"Virginica"
119+
7.7,3.8,6.7,2.2,"Virginica"
120+
7.7,2.6,6.9,2.3,"Virginica"
121+
6,2.2,5,1.5,"Virginica"
122+
6.9,3.2,5.7,2.3,"Virginica"
123+
5.6,2.8,4.9,2,"Virginica"
124+
7.7,2.8,6.7,2,"Virginica"
125+
6.3,2.7,4.9,1.8,"Virginica"
126+
6.7,3.3,5.7,2.1,"Virginica"
127+
7.2,3.2,6,1.8,"Virginica"
128+
6.2,2.8,4.8,1.8,"Virginica"
129+
6.1,3,4.9,1.8,"Virginica"
130+
6.4,2.8,5.6,2.1,"Virginica"
131+
7.2,3,5.8,1.6,"Virginica"
132+
7.4,2.8,6.1,1.9,"Virginica"
133+
7.9,3.8,6.4,2,"Virginica"
134+
6.4,2.8,5.6,2.2,"Virginica"
135+
6.3,2.8,5.1,1.5,"Virginica"
136+
6.1,2.6,5.6,1.4,"Virginica"
137+
7.7,3,6.1,2.3,"Virginica"
138+
6.3,3.4,5.6,2.4,"Virginica"
139+
6.4,3.1,5.5,1.8,"Virginica"
140+
6,3,4.8,1.8,"Virginica"
141+
6.9,3.1,5.4,2.1,"Virginica"
142+
6.7,3.1,5.6,2.4,"Virginica"
143+
6.9,3.1,5.1,2.3,"Virginica"
144+
5.8,2.7,5.1,1.9,"Virginica"
145+
6.8,3.2,5.9,2.3,"Virginica"
146+
6.7,3.3,5.7,2.5,"Virginica"
147+
6.7,3,5.2,2.3,"Virginica"
148+
6.3,2.5,5,1.9,"Virginica"
149+
6.5,3,5.2,2,"Virginica"
150+
6.2,3.4,5.4,2.3,"Virginica"
151+
5.9,3,5.1,1.8,"Virginica"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a,b,c
2+
d,e,f

src/assets/bias-detection-python-code.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ start = time.time()
1616
1717
from js import data
1818
from js import setResult
19-
from js import setMostBiasedCluster
20-
from js import setOtherClusters
21-
from js import iter
22-
from js import clusters
19+
from js import setOutputData
20+
from js import iterations
21+
from js import clusterSize
2322
from js import targetColumn
2423
from js import dataType
2524
from js import higherIsBetter
25+
from js import isDemo
2626
2727
def diffDataframe(df, features, type=None, cluster1=None, cluster2=None):
2828
'''
@@ -149,22 +149,34 @@ def run():
149149
y = scaleY * df[targetColumn]
150150
151151
if dataType == 'numeric':
152-
hbac = BiasAwareHierarchicalKMeans(n_iter=iter, min_cluster_size=clusters).fit(X, y)
152+
hbac = BiasAwareHierarchicalKMeans(n_iter=iterations, min_cluster_size=clusterSize).fit(X, y)
153153
else:
154-
hbac = BiasAwareHierarchicalKModes(n_iter=iter, min_cluster_size=clusters).fit(X, y)
154+
hbac = BiasAwareHierarchicalKModes(n_iter=iterations, min_cluster_size=clusterSize).fit(X, y)
155155
156156
cluster_df = pd.DataFrame(hbac.scores_, columns=['Cluster scores'])
157157
158158
df['Cluster'] = hbac.labels_
159159
160+
if isDemo:
161+
setResult(json.dumps(
162+
{'type': 'text', 'data': '''A demo dataset is loaded below. Using a subset of the [Twitter15](https://www.dropbox.com/s/7ewzdrbelpmrnxu/rumdetect2017.zip?e=1&file_subpath=%2Frumor_detection_acl2017%2FREADME.txt&st=mvtnttvx&dl=0) dataset, a BERT-based classifier has predicted, based on tweet characteristics, whether a message is fake news or not. False positive classifications are marked in the FP colomn and will be used as performance metric in this example.'''}
163+
))
164+
165+
setResult(json.dumps(
166+
{'type': 'data-set-preview', 'data': ''}
167+
))
168+
160169
setResult(json.dumps(
161170
{'type': 'heading', 'data': 'Parameters selected'}
162171
))
172+
173+
174+
163175
setResult(json.dumps(
164-
{'type': 'text', 'data': f'Number of iterations: {iter}'}
176+
{'type': 'text', 'data': f'Number of iterations: {iterations}'}
165177
))
166178
setResult(json.dumps(
167-
{'type': 'text', 'data': f'Minimal cluster size: {clusters}'}
179+
{'type': 'text', 'data': f'Minimal cluster size: {clusterSize}'}
168180
))
169181
setResult(json.dumps(
170182
{'type': 'text', 'data': f'Performance metric column: {targetColumn}'}
@@ -205,8 +217,8 @@ def run():
205217
full_df = pd.concat(clusters_array, ignore_index=True)
206218
full_df.head()
207219
208-
setMostBiasedCluster(df_most_biased_cluster.to_json(orient='records'))
209-
setOtherClusters(df_other.to_json(orient='records'))
220+
setOutputData("mostBiasedCluster", df_most_biased_cluster.to_json(orient='records'))
221+
setOutputData("otherClusters", df_other.to_json(orient='records'))
210222
211223
212224
setResult(json.dumps(

src/bias-detection.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<title>Algorithm Audit Bias Detection</title>
77
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
88
<meta http-equiv="PRAGMA" content="NO-CACHE" />
9+
<link
10+
rel="stylesheet"
11+
href="https://fonts.googleapis.com/css2?family=Avenir:wght@600&amp;display=swap"
12+
media="all"
13+
/>
914
</head>
1015

1116
<body>

0 commit comments

Comments
 (0)