Project 1

Updated by NDG 9/18/24

Description

You have been hired as a consultant by Disney to create a location for a new amusement park. Your job is to analyze weather data from different locations to pick out the best option.

Part 1: Normal data cleanup (5 points)

Begin by looking at the climate normal data. Normal data is the predicted weather for a specific date and location. It is not tied to an individual year.

Load your climate normal datafiles. You will need to do some clean-up. Be sure to look at the data carefully. Below are a list of suggested dplyr activities.

Suggested tasks:

Part 2: Summary table (5 points)

Now that you have the data, create some basic summary data. Show a table with the average temperature by month and location. Have the stations as rows, and the month as columns.

Hint: you may need to use dplyr pivot. First group, then summarise, then pivot. You should end up with a table showing the name for each row, and then each month as a column. You may want to use dplyr and lubridate to create a month column.

## `summarise()` has grouped output by 'name'. You can override using the
## `.groups` argument.
## # A tibble: 4 × 13
## # Groups:   name [4]
##   name     jan   feb   mar   apr   may   jun   jul   aug   sep   oct   nov   dec
##   <chr>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 AUSTI…  61.2  64.9  72.8  78.8  85.4  92.0  94.3  95.9  89.3  81.5  70.8  62.2
## 2 BINGH…  27.7  29.0  39    52.4  64.2  72.0  77.0  74.4  68.0  56.0  43.2  32.5
## 3 JUNEA…  31.9  33.4  37.3  46.4  55.9  60.2  62.0  60.5  54.9  45.7  35.5  31.9
## 4 PITTS…  34.0  35.7  47.5  60.0  69.8  77.5  80.8  79.4  73.8  61.5  49.0  38.9

Part 3: Best location for amusement park (5 points)

We want to find the best location for an amusement park that isn’t too hot, or too cold.

Define an appropriate temperature range where it is comfortable to be outside. Then, create a graph showing how different locations meet your temperature requirement.

Hint: use mutate to create a new field using ifelse (and some temperature range). Set this value to either 1 (for good) or 0 (for bad). Then look at how much of your dataset falls into this ‘good’ range for each station.

Write a brief 2-3 sentence explanation of your findings.

Using the model to predict how frequently the maximum temperature is within the comfortable range of 50-85 degrees, it can be concluded that the best location for Disney’s new park is Pittsburgh, PA. The predictive model shows that Pittsburgh has the most days out of the year within the comfortable range, numbering 234, as shown in the column chart. Additionally, the line chart shows that the temperature in Pittsburgh typically stays within the comfortable range from late March until mid November.

Part 4: Prediction (5 points)

Now, you need to figure out how much the average daily weather for your best site varies from the climate normals for 2023.

Load up the GHCN_daily dataset. You’ll want to filter it down to your chosen site, and then turn the date_as_text column into a proper date. Then, join it to your climate normals (again, filtered to your chosen site) using the date.

Note that tmax is stored as Celsius. You’ll need to convert it.

Create two predictions.

First, compare the actual tmax versus predicted tmax. What is the error? Graph your results and give a 2-3 sentence explanation.

Second, compare the number of days that are predicted to be nice, versus the actual number of days that were nice. Use the same definition as the prior question.

What is the accuracy, precision, and recall of the climate normal data? Give a 2-3 sentence explanation of your results.

According to the model, there was an average difference of about 8.24 degrees between the predicted temperature and the actual temperature. The graph shows a clear positive coorelation between predicted temperature and actual temperature, which was to be expected. Additionally, the points within the two green rectangles represent days in which the model correctly predicted whether or not the temperature would be within the comfortable range.

## Rows: 88644 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): station, date_as_text
## dbl (1): tmax_actual_in_c
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## # A tibble: 4 × 2
##   accuracy count
##   <chr>    <int>
## 1 FN          62
## 2 FP          31
## 3 TN          69
## 4 TP         201
## [1] "Accuracy: 0.724517906336088"
## [1] "Precision: 0.866379310344828"
## [1] "Recall: 0.76425855513308"

The model was about 72.5% accuracte, meaning 72.5% of it’s total predictions were correct. The model was about 86.6% precise, meaning it was correct 86.6% of the time that it predicted a comfortable day. The model had a recall rate of about 76.4%, meaning it correctly predicted 76.4% of the comfortable days. Overall, these numbers are solid, but not great.