FairLens AI: A Python-based auditing framework designed to detect and mitigate algorithmic bias in AI models, ensuring ethical and unbiased automated decision-making. #SolutionChallenge #ResponsibleAI #LogicLegends import pandas as pd
def check_bias(dataset, decision_column, sensitive_attr): # Calculate the percentage of positive outcomes for each group results = dataset.groupby(sensitive_attr)[decision_column].mean()
print(f"--- Bias Analysis for {sensitive_attr} ---")
for group, rate in results.items():
print(f"Group: {group} | Success Rate: {rate*100:.2f}%")
# Simple Logic: If difference is more than 20%, it's biased
diff = results.max() - results.min()
if diff > 0.2:
return "⚠️ BIAS DETECTED: Outcome is unfair."
else:
return "✅ FAIR: Outcome distribution is acceptable."
data = { 'Name': ['A', 'B', 'C', 'D'], 'Gender': ['Male', 'Female', 'Male', 'Female'], 'Hired': [1, 0, 1, 0] # 1 = Yes, 0 = No } df = pd.DataFrame(data)
print(check_bias(df, 'Hired', 'Gender'))