This worksheet includes three main tasks: data modeling (a key step to understand the data), basic steps to compute a simple signal-to-noise ratio, and data exploration to identify trends & patterns using Watson Analytics.
Remember to always set your working directory to the source file location. Go to ‘Session’, scroll down to ‘Set Working Directory’, and click ‘To Source File Location’. Read carefully the below and follow the instructions to complete the tasks and answer any questions. Submit your work to RPubs as detailed in previous notes.
For your assignment you may be using different data sets than what is included here. Always read carefully the instructions on Sakai. For clarity, tasks/questions to be completed/answered are highlighted in red color (visible in preview) and numbered according to their particular placement in the task section. Quite often you will need to add your own code chunk.
Execute all code chunks, preview, publish, and submit link on Sakai.
To begin the Lab, examine the content of the csv file ‘creditrisk.csv’ by opening the file in RStudio. You can view the file separetely in Excel or use File -> Import Dataset in RStudio for that purpose.
##### 1A) Create a simple star relational schema in ERDPlus standalone feature https://erdplus.com/#/standalone, take a screenshot of the image, and add it below. Consider using one fact table for loan, one dimension table for customer profile, and one dimension table for credit risk.
To add a picture, use the directions found in Lab00. Below are steps and an example to create a simple star relational schema in ERDPlus.
Finally export the diagram as an image.
Below is the completed diagram for the lab using the credit risk data table.
Next, read the csv file into R Studio. It can be useful to name your data to create a shortcut to it. Here we will label the data, ‘mydata’. To see the top head data in the console, one can ‘call’ it using the function ‘head’ and referring to it by its given shortcut name.
mydata = read.csv(file="data/creditrisk.csv")
head(mydata)
To capture, or extract, the checking and savings columns and perform some analytics on them, we must first be able to extract the columns from the data separately. Using the ‘$’ sign following the label for the data extracts a specific column. For convenience, we relabel the extracted data. Below, we have extracted the checking column.
#Extracting the Checking Column
checking = mydata$Checking
#Calling the Checking Column to display top head values
head(checking)
[1] 0 0 0 638 963 2827
##### 2A) Repeat here the above code chunk to extract instead the savings column. Be careful to use different variable naming.
Erazodata = read.csv(file="data/creditrisk.csv")
head(Erazodata)
Savings = Erazodata$Savings
head(Savings)
[1] 739 1230 389 347 4754 0
In order to calculate the mean, or the average by hand of the checking column, one can add each individual row entry and divide by the total number of rows. Thankfully, R has a built-in command for this. We have done an example using the checking column.
#Using the 'mean' function on checking to calculate the checking average and naming the average 'meanChecking'
meanChecking = mean(checking)
#Calling the average
meanChecking
[1] 1048.014
We similarly compute the standard deviation or spread of the checking column
#Computing the standard deviation of checking
spreadChecking = sd(checking)
Now, to compute the SNR, the signal to noise ratio, a formula is created because there is no built in function. SNR is the mean, or average, divided by the spread.
#Compute the snr of Checking and name it snr_Checking
snr_Checking = meanChecking/spreadChecking
#Call snr_Checking
snr_Checking
[1] 0.3330006
##### 2B) Repeat here the above code chunks calculations to derive instead the SNR for the savings column. Watch your variable namings to differentiate the checking calculations from the savings.
meanSavings = mean(Savings)
meanSavings
[1] 1812.562
spreadSavings = sd(Savings)
spreadSavings
[1] 3597.285
snr_Savings = meanSavings / spreadSavings
snr_Savings
[1] 0.5038695
##### 2C) Of the checking and savings data , which one has a higher SNR? What does it mean in terms of possible data quality?
Of the checking and savings data, savings has a higher SNR. This mean that in terms of possible data quality, savings has less noise and more signal than that of the checking data; meaning that the savings data has less clutter and is more “clean” than the checkings data. The overall effect is that the higher the SNR, the less room for contimination there is.
Login to Watson Analytics https://www.ibm.com/watson-analytics and upload the file creditrisk.csv to your account.
##### 3A) Consider the trend of ‘Months Employed over Age by Gender’. Include a screenshot of your plot. Refer to first lab session lab00 worksheet on how to include a picture. Write a small paragraph sharing your observations on the general data trends and data behavior.
Below is the trend graph of Months Employed over Age by Gender using IBM Watson Analytics.
In analyzing the trend that IBM Watson retreieved for us, one can see many observations. The most obvious observation is that, across the data plotted, males tend to work more at their respective ages than females. Also, the peak age range for months employeed for men is from ages 21 to 41. Whereas for females, the peak range for months employeed is roughly from 21 to 32. As both genders get to their mid 50s (54-55), months employeed picks up again until about age 60.