Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views2 pages

Credit Risk Analysis with LDA

The document loads credit card data, performs exploratory data analysis including scatter plots and histograms, runs linear discriminant analysis (LDA) to classify customers as high or low risk based on attributes like age, income, and years married, and calculates the accuracy of the LDA model on the credit card data.

Uploaded by

Sanyam Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Credit Risk Analysis with LDA

The document loads credit card data, performs exploratory data analysis including scatter plots and histograms, runs linear discriminant analysis (LDA) to classify customers as high or low risk based on attributes like age, income, and years married, and calculates the accuracy of the LDA model on the credit card data.

Uploaded by

Sanyam Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Creditcard =read.csv(file.

choose(),header=T)

str(Creditcard)

#Scatter Plot

library(psych)

pairs.panels(Creditcard[2:4],

gap=0,

bg=c("red","green")[Creditcard$Riskcustomer],pch=21)

#Discriminant Analysis

library(MASS)

linear=lda(Riskcustomer~., Creditcard)

linear

attributes(linear)

linear$prior

linear$means

linear$counts

linear$scaling

linear$lev

linear$svd

linear$N

p=predict(linear, Creditcard)

#Histogram

ldahist(data=p$x[,1],g=Creditcard$Riskcustomer)

#Confusion matrix and accuracy

linear1=lda(Riskcustomer ~ Age + Income+ Yearsmarried, data=Creditcard)

linearp=predict(linear1, newdata = Creditcard[,c(2,3,4)])$class

linearp
table(linearp, Creditcard[,1])

tab=table(linearp, Creditcard[,1])

sum(diag(tab))/sum(tab)

You might also like