Question

In: Computer Science

1. Use Universal Bank dataset. Note that Personal.Loan is the outcome variable of interest. a. Perform...

1. Use Universal Bank dataset. Note that Personal.Loan is the outcome variable of interest. a. Perform a k-NN classification with k=3 for a new data (You are welcome to choose your own values for the new data. Please clearly state it in your report).

b. Identify the best k. Why do you think this is the best? (Hint: Explain what happens if k increases and if k decreases).

c. Calculate accuracy, sensitivity, and specificity for your validation data using the best k (from part b) without calling or using the confusion matrix (that is, compute them directly from the validation data) and verify your computation by directly calling the confusion matrix using R (This is to just make you better in using R).

d. Partition your dataset into 3. Compare the accuracy metrics from part c for both validation data and test data. Summarize your results.

Solutions

Expert Solution

#  !!!!!  Don't forget to change the path in read.csv !!!!!
data <- read.csv("c:/Users/Acer/Downloads/UniversalBank.csv")
n <- nrow(data)
print(str(data))
print(summary(data))
attach(data)
n_train <- floor(0.8 * n)
n_valid <- floor(0.1 * n)
set.seed(123)

train_indices <- sample(1:n, n_train)
train_temp <- data[train_indices,]
test <- data[-train_indices,]

valid_indices <- sample(1:n_train, n_valid)
valid <- train_temp[valid_indices,]
train <- train_temp[-valid_indices,]


install.packages("DMwR")
library(DMwR)

install.packages("e1071")
library(e1071)

i = 2
while (i < 10) {
pred1 <- kNN(Personal.Loan~., train, test,k=i)
pred2 <- kNN(Personal.Loan~., train, valid,k=i)
print("Number of Nearest Neighbors : ")
print(i)

print("Confusion Matrix for Test: ")
print(confusionMatrix(factor(test$Personal.Loan), factor(pred1)))
print("Confusion Matrix for Valid: ")
print(confusionMatrix(factor(valid$Personal.Loan), factor(pred2)))
print("-------------------------------------------------")
i = i + 1
}


Related Solutions

Use Titanic dataset and perform EDA on various columns. Without using any modeling algorithms, and only...
Use Titanic dataset and perform EDA on various columns. Without using any modeling algorithms, and only using basic methods such as frequency distribution, describe the most important predictors of survival of Titanic passengers, e.g. were males or females more likely to survive, were young and rich females more likely to survive than old poor males etc? Submit the  response in a fully "knit" R Markdown file.
(18 pts) Use the “Car Filter.sav” (SPSS) dataset (located below) to perform a Two-Way ANOVA. This...
(18 pts) Use the “Car Filter.sav” (SPSS) dataset (located below) to perform a Two-Way ANOVA. This dataset contains noise level readings taken from inside different sized cars equipped with different sized filters. Write your findings using the format presented in the class slides. (2 pts) What is the mean and standard deviation of each filter’s noise level? (2 pts) Based on the means and standard deviations calculated above for each filter, do you believe the mean noise levels are statistically...
Part 1. Consider the dataset below. You will perform a series of regressions and data transformations....
Part 1. Consider the dataset below. You will perform a series of regressions and data transformations. Be sure to keep a record of all your computer results. First, please perform a simple linear regression. Predict Y if X = 40. To avoid rounding errors in ALL your calculations, please perform your calculations on your spreadsheet referencing data from your regression output. X Y 54 6 42 16 28 33 38 18 25 41 70 3 48 10 41 14 20...
>Paid 25,000 of principle and 1250 of interest expense on the note payable to first bank...
>Paid 25,000 of principle and 1250 of interest expense on the note payable to first bank Paid 10,000 on the mortgage principle and 800 of interest expense to commerece bank How would i Jornalize this in accounting can somone help me and explain to me thanks
National Bank loaned the Lyon Company $10 million, at an interest rate of 8%. The note...
National Bank loaned the Lyon Company $10 million, at an interest rate of 8%. The note was signed January 1, 2008, and was due December 31, 2022. Annual interest was last paid on December 31, 2016. At January 1, 2018, National believes it will not collect accrued interest, that it will only receive $500,000 of interest each year, and that it will only receive $8 million of principal at the end of the life of the note. Calculate the amount...
On January 1, 2017, Headland Company issued a $1,264,500, 5-year, zero-interest-bearing note to Sage Bank. The...
On January 1, 2017, Headland Company issued a $1,264,500, 5-year, zero-interest-bearing note to Sage Bank. The note was issued to yield 8% annual interest. Unfortunately, during 2018 Headland fell into financial trouble due to increased competition. After reviewing all available evidence on December 31, 2018, Sage Bank decided that the loan was impaired. Headland will probably pay back only $843,000 of the principal at maturity. 1. Prepare journal entries for both Headland Company and Sage Bank to record the issuance...
Quick Print Press borrowed $20,000 from the Provincial Bank on May 25 at 7.5% and secured the loan by signing a promissory note subject to a variable rate of interest
Quick Print Press borrowed $20,000 from the Provincial Bank on May 25 at 7.5% and secured the loan by signing a promissory note subject to a variable rate of interest. Quick Print made partial payments of $5000 on July 10 and $8000 on September 15. The rate of interest was increased to 8% effective August 1 and to 8.5% effective October 1. What payment must Quick Print make on October 31 if, under the terms of the loan agreement, any...
When the Prestons took out a variable mortgage with the First Bank of Marietta, their interest...
When the Prestons took out a variable mortgage with the First Bank of Marietta, their interest rate was 9 percent. The agreement allowed First Bank to raise or lower the interest rate at any time, provided that the Prestons received 30 days’ notice. When the bank raised the interest rate to 11 percent, the Prestons refused to pay, arguing that the agreement was unenforceable, because it set no limit on what interest rate they might be forced to pay. Were...
Conducting a Bank Reconciliation Note: Part 1 is the bank reconciliation itself and Part 2 is...
Conducting a Bank Reconciliation Note: Part 1 is the bank reconciliation itself and Part 2 is for the adjusting entries. Instructions: Using the information below, complete the bank reconciliation for both the "book" and the "bank" sides and create all necessary adjusting journal entries. Details: Cash balance per company's records as of July 31st was $66,955. Bank statement balance as of July 31st was $15,875. A deposit in the amount of $52,000 was deposited into the night depository of the...
On December 31, 2020, Pina Company signed a $1,056,300 note to Grouper Bank. The market interest...
On December 31, 2020, Pina Company signed a $1,056,300 note to Grouper Bank. The market interest rate at that time was 11%. The stated interest rate on the note was 9%, payable annually. The note matures in 5 years. Unfortunately, because of lower sales, Pina’s financial situation worsened. On December 31, 2022, Grouper Bank determined that it was probable that the company would pay back only $633,780 of the principal at maturity. However, it was considered likely that interest would...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT