-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblank_notes.Rmd
156 lines (91 loc) · 2.69 KB
/
blank_notes.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
title: "Stat 33A - Lecture Notes 7"
date: Oct 4, 2020
output: pdf_document
---
Exploratory Data Analysis
=========================
What does it mean to "explore" data?
* Look for patterns (examine variation in the data)
* Look for errors in the data
* Look for relationships between variables
* Look at data to get an overview (what data are present?)
* Check assumptions (model, conclusions, etc)
What are the techniques to "explore" data?
* Make plots
* Compute summary statistics
* Fit models (including hypothesis tests, machine learning)
The table below has _suggestions_ for choosing an appropriate plot
based on the data types.
You also need to think about what you're trying to convey.
First Feature | Second Feature | Plot
-------------- | ---------------- | ----
categorical | | bar, dot
categorical | categorical | bar, dot, mosaic
numerical | | box, density, histogram
numerical | categorical | box, density
numerical | numerical | line, scatter, smooth scatter
Again we'll use the dogs data:
```{r}
```
Example: How many dogs are there in each group (toy, sporting, etc)?
```{r}
```
Example: What's the distribution of datadog scores?
```{r}
```
Example: How are size and height related?
```{r}
```
Distribution Plots
==================
For numeric features, we typically use box, histogram, or density plots.
Example: How does height vary for different groups of dogs?
What can we do to display these?
* side-by-side box plots
* overlapping density plots
Let's start with a box plot:
```{r}
```
How can we display the groups in a density plot?
```{r}
```
Too many lines!
You can use a ridge plot instead to show many densities at once:
```{r}
# install.packages("ggridges")
```
Faceted Plots
=============
Side-by-side plots are called _faceted_ plots.
Can we make the group vs height dogs plot using faceted plots?
The `facet_wrap()` function lays out facets in rows (to use screen space
efficiently).
The syntax is:
```
facet_wrap(vars(FEATURE))
```
For example:
```{r}
```
The `facet_grid()` function lays out facets in a grid. The syntax is:
```
facet_grid(ROWS ~ COLUMNS)
```
Use `.` as a placeholder if you only want one feature.
For example:
```{r}
```
When should you use facets versus aesthetics?
Use facets when aesthetics would put too much information on the plot (too many
lines, too many points, etc).
Use aesthetics when there is less information to show; facets tend to use space
less efficiently than aesthetics.
Overall, think about the reader. There is no rule that always holds here.
EDA Strategy
============
See the lecture slides.
EDA Examples
============
```{r}
```