- 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.
- Windows phone 7.5 application development with F#
- 電腦常見問題與故障排除
- INSTANT ForgedUI Starter
- R Deep Learning Essentials
- 筆記本電腦維修實踐教程
- 微型計算機系統(tǒng)原理及應(yīng)用:國產(chǎn)龍芯處理器的軟件和硬件集成(基礎(chǔ)篇)
- 龍芯自主可信計算及應(yīng)用
- 圖解計算機組裝與維護(hù)
- The Artificial Intelligence Infrastructure Workshop
- Mastering Machine Learning on AWS
- 觸摸屏應(yīng)用技術(shù)從入門到精通
- 單片機原理及應(yīng)用
- Blender for Video Production Quick Start Guide
- 施耐德M241/251可編程序控制器應(yīng)用技術(shù)
- Exceptional C++:47個C++工程難題、編程問題和解決方案(中文版)