biasaware / scripts /genbit.py
freyam's picture
Add Plot for Gender Divide
0946447
raw
history blame
659 Bytes
from genbit.genbit_metrics import GenBitMetrics
import pandas as pd
def eval_genbit(data):
genbit_metrics = GenBitMetrics(
language_code="en", context_window=5, distance_weight=0.95, percentile_cutoff=80
)
data = data[data.columns[0]].to_list()
genbit_metrics.add_data(data, tokenized=False)
result_json = genbit_metrics.get_metrics(output_word_list=False)
result_df = (
pd.DataFrame.from_dict(result_json, orient="index")
.reset_index()
.rename(columns={"index": "Metric", 0: "Value"})
)
result_plot = None
result_conclusion = ""
return result_df, result_plot, result_conclusion