# Filter fraud and legit data
fraud_data <- filter(fraud_detection_data, Label == "fraud")
legit_data <- filter(fraud_detection_data, Label == "legit")

mean(fraud_data$Transaction_Amount)
## [1] 504.87
mean(legit_data$Transaction_Amount)
## [1] 250.42
fraud_detection_data$Label_numeric <- ifelse(fraud_detection_data$Label == "fraud", 1, 0)
cor(fraud_detection_data$Transaction_Amount,fraud_detection_data$Label_numeric )
## [1] 0.8834135
mean(fraud_data$Time_of_Day)
## [1] 5.47
mean(legit_data$Time_of_Day)
## [1] 16.98
cor(fraud_detection_data$Time_of_Day,fraud_detection_data$Label_numeric )
## [1] -0.6355552
mean(fraud_data$Distance_From_Home)
## [1] 100.89
mean(legit_data$Distance_From_Home)
## [1] 51.15
cor(fraud_detection_data$Distance_From_Home,fraud_detection_data$Label_numeric )
## [1] 0.8382772
# Create histogram for fraud transactions based on Transaction_Amount
hist(legit_data$Time_of_Day, 
     main = "Histogram of Legit Transactions", 
     xlab = "Time of Day")

# Create histogram for fraud transactions based on Transaction_Amount
hist(fraud_data$Time_of_Day, 
     main = "Histogram of Fraud Transactions", 
     xlab = "Time of Day")