Skip to content

Commit

Permalink
final stages
Browse files Browse the repository at this point in the history
:wq
Merge branch 'master' of github.com:DS-100/textbook
  • Loading branch information
debnolan committed May 23, 2023
2 parents bb3c6c1 + 3accfea commit 90ba6f9
Show file tree
Hide file tree
Showing 22 changed files with 87,110 additions and 86,615 deletions.
1 change: 0 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
layout anaconda textbook
dotenv_if_exists secrets.env
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ secrets.env

# Ignore scratchpad notebook
/scratch.ipynb
/.virtual_documents

##############################################################################
# Auto-generated ignores
Expand Down
17 changes: 9 additions & 8 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ These instructions were tested for OSX 10.15. We assume that you know how to
run commands on the `bash` command line. We also assume you have the following
command-line tools installed:

- `conda`, the Python package manager ([installation instructions][conda])
- `conda`, the Python package manager ([installation instructions for `mamba`,
which implements a much faster version of `conda`][conda])
- `git`, the version control tool ([installation instructions][git])
- `brew`, the macOS package manager ([installation instructions][brew])

[conda]: https://docs.anaconda.com/anaconda/install/
[conda]: https://mamba.readthedocs.io/en/latest/installation.html
[git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[brew]: https://brew.sh/

Expand All @@ -35,13 +36,13 @@ command-line tools installed:
the following command:

```bash
conda env create -f environment.yml
mamba env create -f environment.yml
```

To check that this command succeeds, run:

```bash
conda info --envs
mamba env list
```

And verify that the `textbook` environment appears in the list.
Expand All @@ -63,7 +64,7 @@ Follow these steps **each time** you begin working on the book.
1. **Activate the `textbook` Python environment.** Run:

```bash
source activate textbook
mamba activate textbook
```

1. **Checkout a `git` branch for your work.** To make book changes easier to
Expand Down Expand Up @@ -119,12 +120,12 @@ Follow these steps **each time** you begin working on the book.
rebuilds the book whenever you change book content. Once this process
is running, open http://localhost:8000/ to view the book locally.

1. **Start a Jupyter notebook server.** In a new terminal tab or window,
navigate to the `textbook/` folder and run `source activate textbook` again.
1. **Start a JupyterLab notebook server.** In a new terminal tab or window,
conda to the `textbook/` folder and run `mamba activate textbook` again.
Then, run:

```bash
jupyter notebook
jupyter lab
```

This should open your browser to a Jupyter server that lists the textbook
Expand Down
28 changes: 20 additions & 8 deletions content/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,38 @@ li.current > ul {
* Footer styling
*****************************************************************************/

.footer {
padding-left: 0;
/* Mimic JBook theme padding for body */

@media (min-width: 768px) {
.footer {
padding-left: 1rem;
}
}

.footer > .container {
padding-left: 0;
@media (min-width: 960px) {
.footer {
padding-left: 3rem;
}
}

/*****************************************************************************
* Notebook styling
*****************************************************************************/

#main-content {
max-width: 72rem;
padding-left: 0rem;
}

@media (min-width: 768px) {
#main-content {
padding-left: 0.6rem;
/* 70% is the JBook theme default, and we set a hard max-width so that
* lines don't get too long on wide screens */
max-width: min(70%, 640px);
}

footer.footer-article .prev-next-area {
max-width: min(70%, 640px);
}
}

Expand Down Expand Up @@ -198,8 +210,8 @@ img {
}

/* don't top-align footnotes */
.footnote-reference {
vertical-align: baseline;
a.footnote-reference {
vertical-align: initial;
}

/* Make bibliography font smaller */
Expand All @@ -211,7 +223,7 @@ img {
* MathJax
*****************************************************************************/

.MathJax_Display {
div.math {
font-size: 1.21rem;
}

Expand Down
2 changes: 0 additions & 2 deletions content/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ parts:
- caption: Frontmatter
chapters:
- file: preface
- file: prereqs
- file: notation

- caption: The Data Science Lifecycle
numbered: true
Expand Down
85 changes: 54 additions & 31 deletions content/ch/02/data_scope_accuracy.ipynb

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions content/ch/02/data_scope_big_data_hubris.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,56 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"(sec:scope_bigdata)=\n",
"# Big Data and New Opportunities \n",
"\n",
"The tremendous increase in openly available data has created new roles and opportunities in data science. For example, data journalists look for interesting stories in data much like how traditional beat reporters hunt for news stories. The data lifecycle for the data journalist begins with the search for existing data that might have an interesting story, rather than beginning with a research question and looking for how to collect new or use existing data to address the question. "
"# Big Data and New Opportunities\n",
"\n",
"The tremendous increase in openly available data has created new roles and opportunities in data science. For example, data journalists look for interesting stories in data much like how traditional beat reporters hunt for news stories. The data lifecycle for the data journalist begins with the search for existing data that might have an interesting story, rather than beginning with a research question and looking for how to collect new or use existing data to address the question.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Citizen science projects are another example. They engage many people (and instruments) in data collection. Collectively, these data are made available to researchers who organize the project and often they are made available in repositories for the general public to further investigate. "
"Citizen science projects are another example. They engage many people (and instruments) in data collection. Collectively, these data are made available to researchers who organize the project and often they are made available in repositories for the general public to further investigate.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The availability of administrative and organizational data creates other opportunities. Researchers can link data collected from scientific studies with, say, medical data that have been collected for healthcare purposes; these administrative data have been collected for reasons that don't directly stem from the question of interest, but they can be useful in other settings. Such linkages can help data scientists expand the possibilities of their analyses and cross-check the quality of their data. In addition, found data can include digital traces, such as your web-browsing activity, posts on social media, and your online network of friends and acquaintances, and they can be quite complex. "
"The availability of administrative and organizational data creates other opportunities. Researchers can link data collected from scientific studies with, say, medical data that have been collected for healthcare purposes; these administrative data have been collected for reasons that don't directly stem from the question of interest, but they can be useful in other settings. Such linkages can help data scientists expand the possibilities of their analyses and cross-check the quality of their data. In addition, found data can include digital traces, such as your web-browsing activity, posts on social media, and your online network of friends and acquaintances, and they can be quite complex.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"When we have large amounts of administrative data or expansive digital traces, it can be tempting to treat them as more definitive than data collected from traditional smaller research studies. We might even consider these large datasets as a replacement for scientific studies and essentially a census. This over-reach is referred to as the [\"big data hubris\"](https://doi.org/10.1126/science.1248506). Data with a large scope does not mean that we can ignore foundational issues of how representative the data are, nor can we ignore issues with measurement, dependency, and reliability. (And it can be easy to discover meaningless or nonsensical relationships just by coincidence.) One well-known example is the Google Flu Trends tracking system. "
"When we have large amounts of administrative data or expansive digital traces, it can be tempting to treat them as more definitive than data collected from traditional smaller research studies. We might even consider these large datasets as a replacement for scientific studies and essentially a census. This over-reach is referred to as the [\"big data hubris\"](https://doi.org/10.1126/science.1248506). Data with a large scope does not mean that we can ignore foundational issues of how representative the data are, nor can we ignore issues with measurement, dependency, and reliability. (And it can be easy to discover meaningless or nonsensical relationships just by coincidence.) One well-known example is the Google Flu Trends tracking system.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: Google Flu Trends\n",
"\n",
"[Digital epidemiology](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5754279/), a new subfield of epidemiology, leverages data generated outside the public health system to study patterns of disease and health dynamics in populations[^nih].\n",
"[Digital epidemiology](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5754279/), a new subfield of epidemiology, leverages data generated outside the public health system to study patterns of disease and health dynamics in populations.\n",
"The Google Flu Trends (GFT) tracking system was one of the earliest examples of digital epidemiology.\n",
"In 2007, researchers found that counting the searches people made for flu-related\n",
"terms could accurately estimate the number of flu cases.\n",
"This apparent success made headlines, and many researchers became excited about the possibilities of big data.\n",
"However, GFT did not live up to expectations and was abandoned in 2015.\n",
"\n",
"What went wrong? After all, GFT used millions of digital traces from online queries for terms related to influenza to predict flu activity. Despite initial success, in the 2011–2012 flu season, Google's data scientists found that GFT was not a substitute for the more traditional surveillance reports of three-week old counts collected by the Centers for Disease Control (CDC) from laboratories across the United States. In comparison, GFT overestimated the CDC numbers for 100 out of 108 weeks. Week after week, GFT came in too high for the cases of influenza, even though it was based on big data: "
"What went wrong? After all, GFT used millions of digital traces from online queries for terms related to influenza to predict flu activity. Despite initial success, in the 2011–2012 flu season, Google's data scientists found that GFT was not a substitute for the more traditional surveillance reports of three-week old counts collected by the Centers for Disease Control (CDC) from laboratories across the United States. In comparison, GFT overestimated the CDC numbers for 100 out of 108 weeks. Week after week, GFT came in too high for the cases of influenza, even though it was based on big data:\n"
]
},
{
Expand Down Expand Up @@ -2830,42 +2836,47 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"From weeks 412 to 519 in this plot, GFT (solid line) over estimated the actual CDC reports (dashed line) 100 times. Also plotted here are predictions from a model based on 3-week old CDC data and seasonal trends (dotted line), which follows the actuals more closely than GFT. "
"From weeks 412 to 519 in this plot, GFT (solid line) over estimated the actual CDC reports (dashed line) 100 times. Also plotted here are predictions from a model based on 3-week old CDC data and seasonal trends (dotted line), which follows the actuals more closely than GFT.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Data scientists found that a simple model built from past CDC reports that used 3-week-old CDC data and seasonal trends did a better job of predicting flu prevalence than GFT. The GFT overlooked considerable information that can be extracted by basic statistical methods. This does not mean that big data captured from online activity is useless. In fact, [researchers](https://www.wired.com/2015/10/can-learn-epic-failure-google-flu-trends/#:~:text=The%20paper%20demonstrated%20that%20search,into%20potentially%20life%2Dsaving%20insights.) have shown that the combination of GFT data with CDC data can substantially improve on both GFT predictions and the CDC-based model. It is often the case that combining different approaches leads to improvements over individual methods."
"Data scientists found that a simple model built from past CDC reports that used 3-week-old CDC data and seasonal trends did a better job of predicting flu prevalence than GFT. The GFT overlooked considerable information that can be extracted by basic statistical methods. This does not mean that big data captured from online activity is useless. In fact, [researchers have shown](https://www.wired.com/2015/10/can-learn-epic-failure-google-flu-trends/#:~:text=The%20paper%20demonstrated%20that%20search,into%20potentially%20life%2Dsaving%20insights.) that the combination of GFT data with CDC data can substantially improve on both GFT predictions and the CDC-based model. It is often the case that combining different approaches leads to improvements over individual methods.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The GFT example shows us that even when we have tremendous amounts of information, the connections between the data and the question being asked are paramount. Understanding this framework can help us avoid answering the wrong question, applying inappropriate methods to the data, and overstating our findings. "
"The GFT example shows us that even when we have tremendous amounts of information, the connections between the data and the question being asked are paramount. Understanding this framework can help us avoid answering the wrong question, applying inappropriate methods to the data, and overstating our findings.\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
":::{note}\n",
"\n",
"In the age of big data, we are tempted to collect more and more data to answer a question precisely. After all, a census gives us perfect information, so shouldn't big data be nearly perfect? Unfortunately, this is often not the case, especially with administrative data and digital traces. The inaccessibility of a small fraction of the people you want to study (see the 2016 election upset in {numref}`Chapter %s <ch:theory_datadesign>`) or the measurement process itself (as in this GFT example) can lead to poor predictions. It is important to consider the scope of the data as it relates to the question under investigation. \n",
"In the age of big data, we are tempted to collect more and more data to answer a question precisely. After all, a census gives us perfect information, so shouldn't big data be nearly perfect? Unfortunately, this is often not the case, especially with administrative data and digital traces. The inaccessibility of a small fraction of the people you want to study (see the 2016 election upset in {numref}`Chapter %s <ch:theory_datadesign>`) or the measurement process itself (as in this GFT example) can lead to poor predictions. It is important to consider the scope of the data as it relates to the question under investigation.\n",
"\n",
":::"
":::\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"A key factor to keep in mind is the scope of the data. Scope includes considering the population we want to study, how to access information about that population, and what we are actually measuring. Thinking through these points can help us see potential gaps in our approach. This is the topic of the next section."
"A key factor to keep in mind is the scope of the data. Scope includes considering the population we want to study, how to access information about that population, and what we are actually measuring. Thinking through these points can help us see potential gaps in our approach. We investigate this in the next section.\n"
]
}
],
Expand Down

0 comments on commit 90ba6f9

Please sign in to comment.