logo

Strategies for Maximizing Accuracy in Predicting Credit Rating

   

Added on  2023-01-23

3 Pages1135 Words84 Views
## Task- 2 ####
############################################## Question 1:
##############################################################
# Import file creditworthiness.csv
credit_data <- read.csv("/Path of your folder/creditworthiness.csv")
View(credit_data)
names(credit_data) # Column names / Varibale names
dim(credit_data) # There are 2500 observations and 46 variables
str(credit_data)
summary(credit_data) # Summary of the dataset
##list of rows with missing values
credit_data[!complete.cases(credit_data),]
##list of columns with missing values
credit_data[,!complete.cases(credit_data)]
## Discard missingvalues
credit_data <- na.omit(credit_data,na.action=TRUE)
# First check the complete set of components for outliers
boxplot(credit_data)
# outlier in savings.on.other.accounts
boxplot(credit_data[,c(8)])
## Phrase the function to replace outliers
library(data.table)
outlierReplace = function(credit_data, cols, rows, newValue = NA) {
if (any(rows)) {
set(credit_data, rows, cols, newValue)
}
}
# gender vs credit rating
counts <- table(credit_data$gender, credit_data$credit.rating)
barplot(counts, main="Credit Rating Distribution",
xlab="Categories", col=c("gray", "blue"), legend = rownames(counts),
beside=TRUE)
#Convert credit.rating variable as categorical variable
credit_data$credit.rating = as.factor(credit_data$credit.rating )
### k-means clustering
fit <- kmeans(credit_data,6)
fit
## checking withinss i.e. the intra cluster bond strength factor for each
cluster
fit$withinss
## checking betweenss i.e. the inter cluster distance between cluster
Strategies for Maximizing Accuracy in Predicting Credit Rating_1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
R Programming Analysis 2022
|7
|1725
|21

Estimation of Crimes in the USA in 1990-92 – A Comparative Analysis of Multiple Linear Regression with Poisson/Negative Binomial Regression Modelling
|31
|5388
|248