- Applied Supervised Learning with R
- Karthik Ramasubramanian Jojo Moolayil
- 241字
- 2021-06-11 13:22:32
Studying the Relationship between Two Numeric Variables
To understand how we can study the relationship between two numeric variables, we can leverage scatter plots. It is a 2-dimensional visualization of the data, where each variable is plotted on an axis along its length. Relationships between the variables are easily identified by studying the trend across the visualization. Let's take a look at an example in the following exercise.
Exercise 30: Studying the Relationship between Employee Variance Rate and Number of Employees
Let's study the relationship between employee variance rate and the number of employees. Ideally, the number of employees should increase as the variation rate increases.
Perform the following steps to complete the exercise:
- First, import the ggplot2 package using the following command:
library(ggplot2)
- Create a DataFrame object, df, and use the bank-additional-full.csv file using the following command:
df <- read.csv("/Chapter 2/Data/bank-additional/bank-additional-full.csv",sep=';')
- Now, plot the scatter plot using the following command:
ggplot(data=df,aes(x=emp.var.rate,y=nr.employed)) + geom_point(size=4) +
ggtitle("Scatterplot of Employment variation rate v/s Number of Employees")
The output is as follows:

Figure 2.15: Scatterplot of employment variation versus the number of employees
We use the same base function, ggplot, with a new wrapper for the scatterplot. The geom_point function in ggplot provides the necessary constructs for using a scatterplot.
We can see an overall increasing trend, that is, as employment variance rate increases, we see the number of employees also increases. The fewer number of dots are due to repetitive records in nr.employed.
- Intel FPGA/CPLD設計(高級篇)
- 現代辦公設備使用與維護
- 嵌入式系統中的模擬電路設計
- Mastering Adobe Photoshop Elements
- 筆記本電腦維修300問
- 面向對象分析與設計(第3版)(修訂版)
- SiFive 經典RISC-V FE310微控制器原理與實踐
- Hands-On Artificial Intelligence for Banking
- 數字媒體專業英語(第2版)
- 基于網絡化教學的項目化單片機應用技術
- USB應用分析精粹:從設備硬件、固件到主機端程序設計
- Corona SDK Mobile Game Development:Beginner's Guide
- FPGA進階開發與實踐
- 電腦軟硬件維修寶典
- 3D打印:Geomagic Design X5.1 逆向建模設計實用教程