Data Science Desktop Survival Guide
by Graham Williams
20180723 Now that we have a basic idea of the size and shape and contents of the dataset and have performed some basic data type identification and conversion we are in a position to identify the roles played by the variables within the dataset. First we will record the list of available variables so that we might reference them below.
# Note the available variables.
vars <- names(ds) %T>% print()
By this stage of the project we will usually have identified a business problem that is the focus of attention. In our case we will assume it is to build a predictive analytics model to predict the chance of it raining tomorrow given the observation of today's weather. In this case the variable rain_tomorrow is the target variable. Given today's observations of the weather this is what we want to predict. The dataset we have is then a training dataset of historic observations. The task is to identify any patterns among the other observed variables that suggest that it rains the following day.
# Note the target variable.
target <- "rain_tomorrow"
# Place the target variable at the beginning of the vars.
vars <- c(target, vars) %>% unique() %T>% print()
We have taken the opportunity here to move the target variable to be the first in the vector of variables recorded in vars. This is common practice where the first variable in a dataset is the target (dependent variable) and the remainder are the variables (the independent variables) that will be used to build a model to predict that target.