Python Learning Week 8 (Solution)

Task 1

Write a program to implement KNN classifier and classify given vector. (for k = 3)

Age Loan Class (Defaulter)
25 40000 N
35 60000 N
45 80000 N
20 20000 N
35 120000 N
52 18000 N
23 95000 Y
40 62000 Y
60 100000 Y
48 220000 Y
33 150000 Y
48 142000 ?

CODE:

139QcAJQAAAABJRU5ErkJggg== - Python Learning Week 8 (Solution)

 

QAAAABJRU5ErkJggg== - Python Learning Week 8 (Solution)

 

A+E9TTjRA7+HwAAAABJRU5ErkJggg== - Python Learning Week 8 (Solution)

wERmeYAFAN16gAAAABJRU5ErkJggg== - Python Learning Week 8 (Solution)

 

 

 

Task 2

Modify Task 1  and perform it for all odd values of k from 1 to 10.

  • Find accuracy for each value of k and display.
  • Find the best k which gives highest value of accuracy
  • Also compute confusion matrix for the best value of k.

CODE:

QoAHkCXAANNhlPDAZMBkwGTAZMBm4cxngjccAh6KioocbNDC60tJS4f882GU8MBkwGTAZMBkwGbg7GcBFUZXPA21pqMoArYxxwDhgHDAOGAeMAzXDAQMNNcNHa8U4YBwwDhgHjAMPPQcMNDz0j9gGaBwwDhgHjAPGgZrhgIGGmuGjtWIcMA4YB4wDxoGHngMGGh76R2wDNA4YB4wDxgHjQM1w4P8Dv3J2+rk2s5sAAAAASUVORK5CYII= - Python Learning Week 8 (Solution)

 

IWLkLAAAAAElFTkSuQmCC - Python Learning Week 8 (Solution)

onVphIPvS2c6FI6VdxgOTAZMBkwGTAZOBoskAOhRdys6ukvoLekCSmZmpWw1hol3GA5MBkwGTAZMBk4HiyQC7vdCpJfUX9IAExuXk5CgTMzIyxC7jgcmAyYDJgMmAyUDRZSA7O7uksIjmWyYASYly0DI3DhgHjAPGAeOAceCeOWCA5J5ZaBkYB4wDxgHjgHHAOHCvHDBAcq8ctPTGAeOAccA4YBwwDtwzBwyQ3DMLLQPjgHHAOGAcMA4YB+6VAwZI7pWDlt44YBwwDhgHjAPGgXvmwP8HnmEqMzGFPuAAAAAASUVORK5CYII= - Python Learning Week 8 (Solution)