{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "245 valid participants\n",
      "{'control': 61, 'dashboard': 61, 'chatxai': 62, 'chatxaiboost': 61, 'chatxaiAuto': 0}\n",
      "91 participants blindly rely on AI advice\n",
      "{'control': 8, 'dashboard': 27, 'chatxai': 32, 'chatxaiboost': 24, 'chatxaiAuto': 0}\n",
      "61 valid participants\n",
      "{'control': 0, 'dashboard': 0, 'chatxai': 0, 'chatxaiboost': 0, 'chatxaiAuto': 61}\n",
      "25 participants blindly rely on AI advice\n",
      "{'control': 0, 'dashboard': 0, 'chatxai': 0, 'chatxaiboost': 0, 'chatxaiAuto': 25}\n",
      "Propensity to Trust, 306\n",
      "M: 2.88, SD: 0.71\n",
      "Familiarity, 306\n",
      "M: 2.67, SD: 1.10\n",
      "ATI, 306\n",
      "M: 3.99, SD: 0.90\n",
      "mlbackground, 306\n",
      "M: 0.23, SD: 0.42\n"
     ]
    }
   ],
   "source": [
    "from util import load_user_data\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "# Load explanation understanding, no control condition\n",
    "valid_users, tp_data, _ = load_user_data(filename=\"../data/xailabdata_all.csv\")\n",
    "valid_users_2, tp_data_2, _ = load_user_data(filename=\"../data/xailabdata_llm_agent.csv\")\n",
    "\n",
    "valid_users = valid_users | valid_users_2\n",
    "tp_data.update(tp_data_2)\n",
    "\n",
    "variable_dict = {}\n",
    "reliance_dimensions = [\"accuracy\", \"agreement_fraction\", \"switch_fraction\", \"accuracy-wid\", \"RAIR\", \"RSR\"]\n",
    "covariates_dimensions = [\"Propensity to Trust\", \"Familiarity\", \"ATI\", \"mlbackground\"]\n",
    "trust_dimensions = [\"Reliability/Competence\", \"Understandability/Predictability\", \"Trust in Automation\"]\n",
    "for dimension in reliance_dimensions:\n",
    "    variable_dict[dimension] = []\n",
    "for dimension in covariates_dimensions:\n",
    "    variable_dict[dimension] = []\n",
    "for dimension in trust_dimensions:\n",
    "    variable_dict[dimension] = []\n",
    "for user in valid_users:\n",
    "    tp_condition = tp_data[user][\"condition\"]\n",
    "    # variable_dict[\"condition\"].append(tp_condition)\n",
    "\n",
    "    # for participants in all conditions, load covariates and trust\n",
    "    trust = tp_data[user][\"Trust_in_automation\"]\n",
    "    for dimension in [\"Propensity to Trust\", \"Familiarity\"]:\n",
    "        variable_dict[dimension].append(trust[dimension])\n",
    "    for dimension in [\"ATI\", \"mlbackground\"]:\n",
    "        variable_dict[dimension].append(tp_data[user][dimension])\n",
    "    # for users in all conditions, load reliance\n",
    "    reliance_measures = tp_data[user][\"reliance_measures\"]\n",
    "    for dimension in reliance_dimensions:\n",
    "        variable_dict[dimension].append(reliance_measures[dimension])\n",
    "     # for participants in all conditions, load covariates and trust\n",
    "    trust = tp_data[user][\"Trust_in_automation\"]\n",
    "    for dimension in trust_dimensions:\n",
    "        variable_dict[dimension].append(trust[dimension])\n",
    "\n",
    "\n",
    "# Distribution of covariates\n",
    "for dimension in covariates_dimensions:\n",
    "    print(\"{}, {}\".format(dimension, len(variable_dict[dimension])))\n",
    "    print(\"M: {:.2f}, SD: {:.2f}\".format(np.mean(variable_dict[dimension]), np.std(variable_dict[dimension])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuracy, 306\n",
      "M: 0.645, SD: 0.11\n",
      "agreement_fraction, 306\n",
      "M: 0.847, SD: 0.16\n",
      "switch_fraction, 306\n",
      "M: 0.522, SD: 0.41\n",
      "accuracy-wid, 306\n",
      "M: 0.490, SD: 0.35\n",
      "RAIR, 306\n",
      "M: 0.489, SD: 0.44\n",
      "RSR, 306\n",
      "M: 0.292, SD: 0.43\n"
     ]
    }
   ],
   "source": [
    "# Performance Overview\n",
    "for dimension in reliance_dimensions:\n",
    "    print(\"{}, {}\".format(dimension, len(variable_dict[dimension])))\n",
    "    print(\"M: {:.3f}, SD: {:.2f}\".format(np.mean(variable_dict[dimension]), np.std(variable_dict[dimension])))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "agreement_phi",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
