bank <- read.csv("/Users/tbs/Downloads/bank.csv")
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
The data is related with direct marketing campaigns (phone calls) of a Portuguese banking institution. The classification goal is to predict if the client will subscribe a term deposit (variable y).
Bank Marketing Data Set Information: The data is related with direct marketing campaigns of a Portuguese banking institution. The marketing campaigns were based on phone calls. Often, more than one contact to the same client was required, in order to access if the product (bank term deposit) would be (‘yes’) or not (‘no’) subscribed.
This dataset is for ABC Multistate bank with following columns:
Attribute Information: Bank client data: Age (numeric) Job : type of job (categorical: ‘admin.’, ‘blue-collar’, ‘entrepreneur’, ‘housemaid’, ‘management’, ‘retired’, ‘self-employed’, ‘services’, ‘student’, ‘technician’, ‘unemployed’, ‘unknown’) Marital : marital status (categorical: ‘divorced’, ‘married’, ‘single’, ‘unknown’ ; note: ‘divorced’ means divorced or widowed) Education (categorical: ‘basic.4y’, ‘basic.6y’, ‘basic.9y’, ‘high.school’, ‘illiterate’, ‘professional.course’, ‘university.degree’, ‘unknown’) Default: has credit in default? (categorical: ‘no’, ‘yes’, ‘unknown’) Housing: has housing loan? (categorical: ‘no’, ‘yes’, ‘unknown’) Loan: has personal loan? (categorical: ‘no’, ‘yes’, ‘unknown’)
Related with the last contact of the current campaign: Contact: contact communication type (categorical: ‘cellular’,‘telephone’) Month: last contact month of year (categorical: ‘jan’, ‘feb’, ‘mar’, …, ‘nov’, ‘dec’) Day_of_week: last contact day of the week (categorical: ‘mon’,‘tue’,‘wed’,‘thu’,‘fri’) Duration: last contact duration, in seconds (numeric). Important note: this attribute highly affects the output target (e.g., if duration=0 then y=‘no’). Yet, the duration is not known before a call is performed. Also, after the end of the call y is obviously known. Thus, this input should only be included for benchmark purposes and should be discarded if the intention is to have a realistic predictive model.
summary(bank)
## age job marital education
## Min. :18.00 Length:11162 Length:11162 Length:11162
## 1st Qu.:32.00 Class :character Class :character Class :character
## Median :39.00 Mode :character Mode :character Mode :character
## Mean :41.23
## 3rd Qu.:49.00
## Max. :95.00
## default balance housing loan
## Length:11162 Min. :-6847 Length:11162 Length:11162
## Class :character 1st Qu.: 122 Class :character Class :character
## Mode :character Median : 550 Mode :character Mode :character
## Mean : 1529
## 3rd Qu.: 1708
## Max. :81204
## contact day month duration
## Length:11162 Min. : 1.00 Length:11162 Min. : 2
## Class :character 1st Qu.: 8.00 Class :character 1st Qu.: 138
## Mode :character Median :15.00 Mode :character Median : 255
## Mean :15.66 Mean : 372
## 3rd Qu.:22.00 3rd Qu.: 496
## Max. :31.00 Max. :3881
## campaign pdays previous poutcome
## Min. : 1.000 Min. : -1.00 Min. : 0.0000 Length:11162
## 1st Qu.: 1.000 1st Qu.: -1.00 1st Qu.: 0.0000 Class :character
## Median : 2.000 Median : -1.00 Median : 0.0000 Mode :character
## Mean : 2.508 Mean : 51.33 Mean : 0.8326
## 3rd Qu.: 3.000 3rd Qu.: 20.75 3rd Qu.: 1.0000
## Max. :63.000 Max. :854.00 Max. :58.0000
## deposit
## Length:11162
## Class :character
## Mode :character
##
##
##
# standard deviation of duration
std_dev_tp <- sd(bank$age, na.rm = TRUE)
print(std_dev_tp)
## [1] 11.91337
#variance of balance
var_tp <- var(bank$balance, na.rm= TRUE)
print(var_tp)
## [1] 10403291
#sum of total balance
Assessed_sum <- sum(bank$balance)
print(Assessed_sum)
## [1] 17061547
{r visual summary}
library(ggplot2)
# Pie chart for Job
pie(table(bank$`job`), main="Pie chart for Job")
# Scattered plot for age vs balance
library(ggplot2)
plot(bank$age,bank$balance, main = "Scatter plot for age vs balance", xlab="age", ylab="balance")
# Histogram for duration
hist(bank$'duration', breaks = 20, col = "orange", main = "Histogram for duration", xlab = "duration")
# bar plot for marital vs job
barplot(table(bank$marital, bank$job), col= "blue",main="Bar Plot for marital vs job", xlab="marital", ylab="job")
# line plot
plot(bank$campaign, bank$day, type="l", main="Line Plot", xlab="campaign", ylab="day")
boxplot(bank$previous, bank$balance, main="Box Plot for previous vs balance")
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.