File size: 6,115 Bytes
89da381 830a775 83ab461 1d6b210 830a775 1d6b210 830a775 cbef240 830a775 83ab461 830a775 1d6b210 f5bf857 1d6b210 f5bf857 1d6b210 f5bf857 50fb024 f5bf857 50fb024 f5bf857 50fb024 f5bf857 50fb024 f5bf857 1d6b210 830a775 1d6b210 830a775 9f8f3c6 830a775 1d6b210 b1543d9 1d6b210 f5bf857 830a775 f5bf857 b1543d9 1d6b210 b1543d9 50fb024 b1543d9 50fb024 f5bf857 756112e 50fb024 f5bf857 756112e f5bf857 b1543d9 50fb024 b1543d9 50fb024 756112e 50fb024 1d6b210 b1543d9 1d6b210 830a775 f5bf857 b1543d9 1d6b210 b1543d9 50fb024 b1543d9 50fb024 f5bf857 756112e 50fb024 f5bf857 756112e f5bf857 830a775 b1543d9 50fb024 b1543d9 50fb024 756112e 50fb024 1d6b210 830a775 1d6b210 830a775 83ab461 2fd4b4b 83ab461 cbef240 83ab461 41097c4 cbef240 41097c4 cbef240 41097c4 cbef240 41097c4 cbef240 41097c4 cbef240 41097c4 cbef240 41097c4 cbef240 41097c4 4b89a2c cbef240 41097c4 830a775 1d6b210 830a775 1d6b210 830a775 f5bf857 5f7cfba 4b89a2c 2fd4b4b 4b89a2c 2fd4b4b 1d6b210 2fd4b4b 830a775 2fd4b4b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | import streamlit as st
st.set_page_config(layout="wide")
margin1, center, margin2 = st.columns([1,9,1])
with center:
st.title("AI Model Fairness Auditing")
# --------------------------------------------------
# Strategy Definitions
# --------------------------------------------------
model_owner_actions = {
"Overfit to One Audit Dataset": "overfit",
"Overfit to Audit Dataset-like Distributions": "overfitdist",
}
auditor_actions = {
"Audit with One Dataset": "auditone",
"Audit with Multiple Datasets": "auditmany",
"Use Private Auditing Datasets": "private",
"Audit Model Internals": "internals",
}
# --------------------------------------------------
# Session State
# --------------------------------------------------
if "owner_selected" not in st.session_state:
st.session_state.owner_selected = []
if "auditor_selected" not in st.session_state:
st.session_state.auditor_selected = []
# --------------------------------------------------
# Toggle Functions
# --------------------------------------------------
def toggle_owner(action):
if action in st.session_state.owner_selected:
st.session_state.owner_selected.remove(action)
else:
st.session_state.owner_selected.append(action)
def toggle_auditor(action):
if action in st.session_state.auditor_selected:
st.session_state.auditor_selected.remove(action)
else:
st.session_state.auditor_selected.append(action)
# --------------------------------------------------
# Layout
# --------------------------------------------------
# left, right = st.columns(2)
margin1, left, gap, right, margin2 = st.columns([1,4,1,4,1])
# --------------------------------------------------
# Model Owner
# --------------------------------------------------
with left:
st.subheader("Model Owner")
st.caption("Chosen")
with st.container(border=True):
if not st.session_state.owner_selected:
st.write("None")
for action in st.session_state.owner_selected:
st.button(
action,
key=f"owner_selected_{action}",
on_click=toggle_owner,
args=(action,),
use_container_width=True,
type="primary"
)
st.caption("Available")
with st.container(border=True):
for action in model_owner_actions:
if action not in st.session_state.owner_selected:
st.button(
action,
key=f"owner_available_{action}",
on_click=toggle_owner,
args=(action,),
use_container_width=True,
type="tertiary"
)
# --------------------------------------------------
# Auditor
# --------------------------------------------------
with right:
st.subheader("Auditor")
st.caption("Chosen")
with st.container(border=True):
if not st.session_state.auditor_selected:
st.write("None")
for action in st.session_state.auditor_selected:
st.button(
action,
key=f"auditor_selected_{action}",
on_click=toggle_auditor,
args=(action,),
use_container_width=True,
type="primary"
)
st.caption("Available")
with st.container(border=True):
for action in auditor_actions:
if action not in st.session_state.auditor_selected:
st.button(
action,
key=f"auditor_available_{action}",
on_click=toggle_auditor,
args=(action,),
use_container_width=True,
type="tertiary"
)
# --------------------------------------------------
# Score Calculation
# --------------------------------------------------
auditor_active_list = []
for action in st.session_state.auditor_selected:
auditor_active_list.append(auditor_actions[action])
owner_active_list = []
for action in st.session_state.owner_selected:
owner_active_list.append(model_owner_actions[action])
auditor_cost = "🟢 Low"
if "auditmany" in auditor_active_list:
auditor_cost = "🟡 Medium"
if "internals" in auditor_active_list:
auditor_cost = "🔴 Very High"
owner_cost = "None"
if "overfit" in owner_active_list:
owner_cost = "🟢 Low"
if "overfitdist" in owner_active_list:
owner_cost = "🟡 Medium"
reliability = "❌ Low"
if "auditone" in auditor_active_list and len(owner_active_list)==0:
reliability = "⚠️ Medium"
if "auditmany" in auditor_active_list and len(owner_active_list)==0:
reliability = "✅ High"
if "auditmany" in auditor_active_list and "overfit" in owner_active_list:
reliability = "⚠️ Medium"
if "private" in auditor_active_list and "overfitdist" not in owner_active_list:
reliability = "⚠️ Medium"
if "private" in auditor_active_list and "auditmany" in auditor_active_list and "overfitdist" not in owner_active_list:
reliability = "✅ High"
if "private" in auditor_active_list and "auditmany" in auditor_active_list and "overfitdist" in owner_active_list:
reliability = "⚠️ Medium"
if "internals" in auditor_active_list:
reliability = "✅ High"
openness = "None"
if "internals" in auditor_active_list:
openness = "🔍 High (Model Weight Sharing)"
if len(auditor_active_list)==0 and len(owner_active_list)==0:
auditor_cost, owner_cost, reliability, openness = "N/A", "N/A", "N/A", "N/A"
# --------------------------------------------------
# Dashboard
# --------------------------------------------------
st.divider()
margin1, c1, c2, c3, c4, margin2 = st.columns([1,2.25,2.25,2.25,2.25,1])
with c1:
st.write("**Auditing Cost**")
st.write(auditor_cost)
with c2:
st.write("**Cost to Cheat for Model Owner**")
st.write(owner_cost)
with c3:
st.write("**Audit Reliability**")
st.write(reliability)
with c4:
st.write("**Openness Requirements**")
st.write(openness) |