biasaware / app.py
freyam's picture
Add Blocks and Plots
5da6a2b
raw
history blame
4.26 kB
import gradio as gr
import pandas as pd
data = [
["Category", "Value", "Percentage"],
["Total Reviews", 50000, None],
["Total Sentences", 621647, None],
["Pronouns in Sentences", None, None],
["Male Pronouns", 85615, None],
["Female Pronouns", 39372, None],
["Both Male and Female Pronouns", 7765, None],
["Exclusive Usage of Pronouns", None, None],
["Only Male Pronouns", 77860, 13.77],
["Only Female Pronouns", 31617, 6.33],
["Pronouns and Professions in Sentences", None, None],
["Male Pronouns with Professions", 5580, 0.9],
["Female Pronouns with Professions", 2618, 0.42],
["Exclusive Usage of Pronouns with Professions", None, None],
["Only Male Pronouns with Professions", 5011, 0.81],
["Only Female Pronouns with Professions", 2049, 0.33],
["Pronouns and Professions in Combination", None, None],
["Male or Female Pronouns with Professions", 7629, 1.23],
["Male and Female Pronouns with Professions", 569, 0.09]
]
def display_methodology(methodology):
title = methodology
description = ""
details = ""
if methodology == "Term Identity Diversity Analysis":
description = "111"
details = "222"
elif methodology == "Textual Gender Label Evaluation":
description = "333"
details = "444"
elif methodology == "GenBit":
description = "555"
details = "666"
return title, description, details
def run_evaluation(dataset, methodology):
return f"Running evaluation for {dataset} with {methodology}"
if methodology == "A":
run_a(dataset)
elif methodology == "B":
run_b(dataset)
elif methodology == "C":
run_c(dataset)
demo = gr.Blocks(title="BiasAware: Dataset Bias Detection",
theme=gr.themes.Soft())
with demo:
gr.Markdown("# BiasAware: Dataset Bias Detection")
gr.Markdown(
"Natural Language Processing (NLP) training datasets often reflect the biases present in the data sources they are compiled from, leading to the **perpetuation of stereotypes, underrepresentation, and skewed perspectives in AI models**. BiasAware is designed to **identify and quantify biases present in text data**, making it an invaluable resource for data scientists, machine learning practitioners, and organizations committed to **mitigating bias in AI systems**."
)
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("Select a dataset to analyze")
dataset = gr.Text(label="Dataset")
gr.Examples(
examples=["imdb", "amazon_reviews_multi", "tweet_eval"],
fn=run_evaluation,
inputs=[dataset],
)
methodology = gr.Radio(
[
"Term Identity Diversity Analysis",
"Textual Gender Label Evaluation",
"GenBit",
],
label="Methodology",
)
button = gr.Button("Run Evaluation")
with gr.Column(scale=4):
gr.Markdown("### Results")
with gr.Box():
methodology_title = gr.Markdown("### Title")
methodology_description = gr.Markdown("lorem ipsum")
methodology_details = gr.Markdown("lorem ipsum")
# outputs = gr.Markdown()
outputs = gr.DataFrame(pd.DataFrame(data), headers=[
"", "Count", "Percentage"])
gr.Error("No results to display")
with gr.Column(scale=1):
gr.Markdown("### Leaderboard")
gr.DataFrame(
headers=["Dataset", "Score"],
value=[
["imdb", 0.9],
["amazon_reviews_multi", 0.8],
["tweet_eval", 0.7],
],
interactive=False,
)
methodology.change(
fn=display_methodology,
inputs=[methodology],
outputs=[
methodology_title,
methodology_description,
methodology_details,
],
)
button.click(fn=run_evaluation, inputs=[
dataset, methodology], outputs=[outputs])
demo.launch()