Data Science Desktop Survival Guide by Graham Williams Desktop Survival Project Home Preface Data Science Introducing R R Constructs R Tasks R Strings R Read, Write, and Create Data Template Data Exploration Data Wrangling Data Visualisation Statistics ML Template ML Scenarios ML Activities ML Applications ML Algorithms Cluster Analysis Decision Trees Computer Vision Graph Data Privacy Literate Data Science Coding with Style Resources Bibliography Index

## Risk Variable

20180723 With some knowledge of the data we observe risk_mm captures the amount of rain recorded tomorrow. We refer to this as a risk variable, being a measure of the impact or risk of the target we are predicting (rain tomorrow). The risk is an output variable and should not be used as an input to the modelling—it is not an independent variable. In other circumstances it might actually be treated as the target variable.

 # Note the risk variable - measures the severity of the outcome. risk <- "risk_mm" For this risk variable note that we expect it to have a value of 0 for all observations when the target variable has the value No.

# Review the distribution of the risk variable for non-targets.

ds %>%
filter(rain_tomorrow == "No") %>%
select(risk_mm) %>%
summary()
 ```## risk_mm ## Min. :0.0000 ## 1st Qu.:0.0000 ## Median :0.0000 ## Mean :0.0726 ## 3rd Qu.:0.0000 ## Max. :1.0000 ```

Interestingly, even a little rain (defined as 1mm or less) is regarded as no rain. That is useful to keep in mind and is a discovery of the data that we might not have expected. As data scientists we should be expecting to find the unexpected.

A similar analysis for the target observations is more in line with expectations.

# Review the distribution of the risk variable for targets.

ds %>%
filter(rain_tomorrow == "Yes") %>%
select(risk_mm) %>%
summary()
 ```## risk_mm ## Min. : 1.10 ## 1st Qu.: 2.40 ## Median : 5.00 ## Mean : 10.17 ## 3rd Qu.: 11.40 ## Max. :474.00 ```