{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "74561943-756b-42cd-b493-cdf3b67e7c3d",
   "metadata": {},
   "source": [
    "## Introduction to Data Science\n",
    "\n",
    "#### University of Redlands - DATA 101\n",
    "#### Prof: Joanna Bieri [joanna_bieri@redlands.edu](mailto:joanna_bieri@redlands.edu)\n",
    "#### [Class Website: data101.joannabieri.com](https://data101.joannabieri.com)\n",
    "\n",
    "---------------------------------------\n",
    "# Homework Day 13\n",
    "---------------------------------------\n",
    "\n",
    "GOALS:\n",
    "\n",
    "1. Explore and respond to ideas around data ethics\n",
    "2. Recreate other peoples work to more honestly reflect data.\n",
    "\n",
    "----------------------------------------------------------\n",
    "\n",
    "This homework has **4 questions** and **1 exercise**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0c422e3-32b1-452f-89a8-2586784d3957",
   "metadata": {},
   "source": [
    "## Important Information\n",
    "\n",
    "- Email: [joanna_bieri@redlands.edu](mailto:joanna_bieri@redlands.edu)\n",
    "- Office Hours: Duke 209 <a href=\"https://joannabieri.com/schedule.html\"> Click Here for Joanna's Schedule</a>\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d0153569-41e3-4696-9b34-83ba90a0b5cf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T20:53:24.200423Z",
     "iopub.status.busy": "2026-10-07T20:53:24.200321Z",
     "iopub.status.idle": "2026-10-07T20:53:25.509568Z",
     "shell.execute_reply": "2026-10-07T20:53:25.509133Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import plotly.express as px\n",
    "from plotly.subplots import make_subplots\n",
    "import plotly.io as pio\n",
    "pio.renderers.default = 'notebook_connected'\n",
    "\n",
    "# This stops a few warning messages from showing\n",
    "pd.options.mode.chained_assignment = None \n",
    "import warnings\n",
    "warnings.simplefilter(action='ignore', category=FutureWarning)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b75d6a18-2959-4802-bb19-24a635fa9aa9",
   "metadata": {},
   "source": [
    "## Data Science Ethics\n",
    "\n",
    "## Misrepresentation\n",
    "\n",
    "Misrepresentation can happen intentionally or unintentionally. It can arise because of lack of knowledge or competence in data science. It is important to be aware of misrepresentation and be able to spot it a mile away in your work and in other peoples work!\n",
    "\n",
    "What is wrong with this picture? How would you correct it?\n",
    "\n",
    "\n",
    "![Confirmed Covid Cases](https://joannabieri.com/introdatascience/images/ga-dph-declining-bars.jpg)\n",
    "\n",
    "- Overall this looks like the heights of bars are going down.\n",
    "- Dates are on the x-axis.\n",
    "- Are covid cases going down over time?\n",
    "\n",
    "**Q1** Write in your own words what you see that is wrong with this graph. What is the story it is telling vs the real story in the data?\n",
    "\n",
    "\n",
    "**Q2** Is it okay to misrepresent your data if you are getting people to \"do the right thing\"? For example, more exercise is good for you, right? Was it so bad to misrepresent the results of the cancer and exercise studies?\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c313f413-e9c5-4a88-927f-24e251bc622a",
   "metadata": {},
   "source": [
    "## Data Privacy\n",
    "\n",
    "The question of data privacy is complicated and rests on the idea of what amount of expected privacy are we entitled to when we put our data online.\n",
    "\n",
    "## Data Privacy -  Case study: \n",
    "\n",
    "**Q3** When analyzing data that is publicly shared, how can you make sure that you are not violating a persons reasonable expectation of privacy? What do you think the rules should be here? How would you want your data treated?\n",
    "\n",
    "**Q4** Does the answer to the question \"Should I scrape this data\" vary based on what the data is about? Give two examples where the answer might be different.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6252c36c-2895-4e10-9918-7ab674192598",
   "metadata": {},
   "source": [
    "## Exercise 1\n",
    "\n",
    "Consider the following visualization that was shared on Twitter:\n",
    "\n",
    "Originally from: https://twitter.com/JonBoeckenstedt/status/1291602888376999936\n",
    "\n",
    "![Masks v. No Masks](https://joannabieri.com/introdatascience/images/masks-v-nomasks.png)\n",
    "\n",
    "You are going to construct the data by reading (approximate is okay) the numbers from the picture. \n",
    "\n",
    "1. What is most misleading about this graph - essay answer\n",
    "\n",
    "2.  Create a data frame that can be used to re-construct this visualization. You may need to guess some of the numbers, that's ok. You should first think about how many rows and columns you'll need and what you want to call your variables.\n",
    "\n",
    "\n",
    "Here is some code to get you started:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7d4bc2c6-8218-4c4d-9def-d9270ea74233",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T20:53:25.511292Z",
     "iopub.status.busy": "2026-10-07T20:53:25.511169Z",
     "iopub.status.idle": "2026-10-07T20:53:25.518719Z",
     "shell.execute_reply": "2026-10-07T20:53:25.518336Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>count_mask</th>\n",
       "      <th>count_nomask</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [date, count_mask, count_nomask]\n",
       "Index: []"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Literally read the x, y numbers and enter them into a pandas dataframe. Then re-do the graph.\n",
    "\n",
    "# Dates from the x-axis\n",
    "date = []\n",
    "# Numbers for mask data line y-axis LEFT SIDE\n",
    "count_mask = []\n",
    "# Numbers for the nomask data line y-axis RIGHT SIDE\n",
    "count_nomask = []\n",
    "\n",
    "DF = pd.DataFrame()\n",
    "DF['date']=date\n",
    "DF['count_mask']=count_mask\n",
    "DF['count_nomask']=count_nomask\n",
    "DF"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1cf33f04-f1a2-42b5-b60d-03745563e1db",
   "metadata": {},
   "source": [
    "3. Make a visualization of this data that is more accurate. Your visualization should more honestly tell the story.\n",
    "\n",
    "               fig = px.line(DF,x= ,y= )\n",
    "\n",
    "   \n",
    "4. What message is more clear in your visualization, compared to the one posted on twitter?\n",
    "5. What, if any, useful information do these data and your visualization tell us about mask wearing and COVID? It’ll be difficult to set aside what you already know about mask wearing, but you should try to focus only on what this visualization tells. Feel free to also comment on whether that lines up with what you know about mask wearing.\n",
    "6. Could there be confounding data? What can you actually say about the data as given?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54d2b899-307c-4eff-b046-26b9299c3e00",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.13.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
