|
|
|
|
|
|
|
|
import gradio as gr |
|
|
from cear_model import CEARModel |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
|
|
|
cear_analyzer = CEARModel() |
|
|
|
|
|
def analyze_user_data(input_table): |
|
|
|
|
|
user_data_df = pd.DataFrame(input_table, columns=['platform_name', 'minutes_per_week']) |
|
|
user_data_df['minutes_per_week'] = pd.to_numeric(user_data_df['minutes_per_week'], errors='coerce').fillna(0) |
|
|
|
|
|
|
|
|
raw_scores = cear_analyzer.calculate_scores(user_data_df) |
|
|
|
|
|
|
|
|
summary = f""" |
|
|
## π Analysis Summary |
|
|
- **Cultural Connectedness Score (C-Score):** **{raw_scores['C_Score']:.2f}** |
|
|
- **Algorithmic Risk Score (A-Risk):** **{raw_scores['A_Risk']:.2f}** |
|
|
- **Platform Diversity Index (D-Index):** **{raw_scores['D_Index']:.2f}** |
|
|
--- |
|
|
### π Interpretation |
|
|
*Your C-Score is based on logarithmically scaled time, reflecting diminishing returns. Your A-Risk is based on raw time, reflecting concentrated attention.* |
|
|
""" |
|
|
|
|
|
|
|
|
return summary, pd.DataFrame(raw_scores['Per_Platform_Efficiency']) |
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=analyze_user_data, |
|
|
inputs=gr.Dataframe( |
|
|
headers=['platform_name', 'minutes_per_week'], |
|
|
row_count=5, |
|
|
col_count=(2, 'fixed'), |
|
|
label="Weekly Screen Time Input (Source data from OS Tracker)" |
|
|
), |
|
|
outputs=[ |
|
|
gr.Markdown(label="Score Results"), |
|
|
gr.Dataframe(label="Per-Platform Cultural Efficiency") |
|
|
], |
|
|
title="CEAR Baseline: Cultural Exposure & Algorithmic Risk Analyzer" |
|
|
) |
|
|
|
|
|
iface.launch(server_name="0.0.0.0", server_port=7860) |