This command is used to view the Original DataSet
View(default_of_credit_card_clients)
The orginal dataset is being duplicated into another document before further analysis.
credit_clients2=default_of_credit_card_clients
The Structure of the duplicated Dataset is Viewed using this function
str(credit_clients2)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 30000 obs. of 25 variables:
$ ID : num 1 2 3 4 5 6 7 8 9 10 ...
$ LIMIT_BAL: num 20000 120000 90000 50000 50000 50000 500000 100000 140000 20000 ...
$ SEX : num 2 2 2 2 1 1 1 2 2 1 ...
$ EDUCATION: num 2 2 2 2 2 1 1 2 3 3 ...
$ MARRIAGE : num 1 2 2 1 1 2 2 2 1 2 ...
$ AGE : num 24 26 34 37 57 37 29 23 28 35 ...
$ PAY_0 : num 2 -1 0 0 -1 0 0 0 0 -2 ...
$ PAY_2 : num 2 2 0 0 0 0 0 -1 0 -2 ...
$ PAY_3 : num -1 0 0 0 -1 0 0 -1 2 -2 ...
$ PAY_4 : num -1 0 0 0 0 0 0 0 0 -2 ...
$ PAY_5 : num -2 0 0 0 0 0 0 0 0 -1 ...
$ PAY_6 : num -2 2 0 0 0 0 0 -1 0 -1 ...
$ BILL_AMT1: num 3913 2682 29239 46990 8617 ...
$ BILL_AMT2: num 3102 1725 14027 48233 5670 ...
$ BILL_AMT3: num 689 2682 13559 49291 35835 ...
$ BILL_AMT4: num 0 3272 14331 28314 20940 ...
$ BILL_AMT5: num 0 3455 14948 28959 19146 ...
$ BILL_AMT6: num 0 3261 15549 29547 19131 ...
$ PAY_AMT1 : num 0 0 1518 2000 2000 ...
$ PAY_AMT2 : num 689 1000 1500 2019 36681 ...
$ PAY_AMT3 : num 0 1000 1000 1200 10000 657 38000 0 432 0 ...
$ PAY_AMT4 : num 0 1000 1000 1100 9000 ...
$ PAY_AMT5 : num 0 0 1000 1069 689 ...
$ PAY_AMT6 : num 0 2000 5000 1000 679 ...
$ dpnm : num 1 1 0 0 0 0 0 0 0 0 ...
The Summary of the Dataset is derived using this function
summary(credit_clients2)
ID LIMIT_BAL SEX EDUCATION MARRIAGE
Min. : 1 Min. : 10000 Min. :1.000 Min. :0.000 Min. :0.000
1st Qu.: 7501 1st Qu.: 50000 1st Qu.:1.000 1st Qu.:1.000 1st Qu.:1.000
Median :15000 Median : 140000 Median :2.000 Median :2.000 Median :2.000
Mean :15000 Mean : 167484 Mean :1.604 Mean :1.853 Mean :1.552
3rd Qu.:22500 3rd Qu.: 240000 3rd Qu.:2.000 3rd Qu.:2.000 3rd Qu.:2.000
Max. :30000 Max. :1000000 Max. :2.000 Max. :6.000 Max. :3.000
AGE PAY_0 PAY_2 PAY_3 PAY_4
Min. :21.00 Min. :-2.0000 Min. :-2.0000 Min. :-2.0000 Min. :-2.0000
1st Qu.:28.00 1st Qu.:-1.0000 1st Qu.:-1.0000 1st Qu.:-1.0000 1st Qu.:-1.0000
Median :34.00 Median : 0.0000 Median : 0.0000 Median : 0.0000 Median : 0.0000
Mean :35.49 Mean :-0.0167 Mean :-0.1338 Mean :-0.1662 Mean :-0.2207
3rd Qu.:41.00 3rd Qu.: 0.0000 3rd Qu.: 0.0000 3rd Qu.: 0.0000 3rd Qu.: 0.0000
Max. :79.00 Max. : 8.0000 Max. : 8.0000 Max. : 8.0000 Max. : 8.0000
PAY_5 PAY_6 BILL_AMT1 BILL_AMT2 BILL_AMT3
Min. :-2.0000 Min. :-2.0000 Min. :-165580 Min. :-69777 Min. :-157264
1st Qu.:-1.0000 1st Qu.:-1.0000 1st Qu.: 3559 1st Qu.: 2985 1st Qu.: 2666
Median : 0.0000 Median : 0.0000 Median : 22382 Median : 21200 Median : 20088
Mean :-0.2662 Mean :-0.2911 Mean : 51223 Mean : 49179 Mean : 47013
3rd Qu.: 0.0000 3rd Qu.: 0.0000 3rd Qu.: 67091 3rd Qu.: 64006 3rd Qu.: 60165
Max. : 8.0000 Max. : 8.0000 Max. : 964511 Max. :983931 Max. :1664089
BILL_AMT4 BILL_AMT5 BILL_AMT6 PAY_AMT1 PAY_AMT2
Min. :-170000 Min. :-81334 Min. :-339603 Min. : 0 Min. : 0
1st Qu.: 2327 1st Qu.: 1763 1st Qu.: 1256 1st Qu.: 1000 1st Qu.: 833
Median : 19052 Median : 18104 Median : 17071 Median : 2100 Median : 2009
Mean : 43263 Mean : 40311 Mean : 38872 Mean : 5664 Mean : 5921
3rd Qu.: 54506 3rd Qu.: 50190 3rd Qu.: 49198 3rd Qu.: 5006 3rd Qu.: 5000
Max. : 891586 Max. :927171 Max. : 961664 Max. :873552 Max. :1684259
PAY_AMT3 PAY_AMT4 PAY_AMT5 PAY_AMT6 dpnm
Min. : 0 Min. : 0 Min. : 0.0 Min. : 0.0 Min. :0.0000
1st Qu.: 390 1st Qu.: 296 1st Qu.: 252.5 1st Qu.: 117.8 1st Qu.:0.0000
Median : 1800 Median : 1500 Median : 1500.0 Median : 1500.0 Median :0.0000
Mean : 5226 Mean : 4826 Mean : 4799.4 Mean : 5215.5 Mean :0.2212
3rd Qu.: 4505 3rd Qu.: 4013 3rd Qu.: 4031.5 3rd Qu.: 4000.0 3rd Qu.:0.0000
Max. :896040 Max. :621000 Max. :426529.0 Max. :528666.0 Max. :1.0000
Using caTools Library, we factorize the dependent variable(dpnm) and education,SampleSplit(sample_cc)with a Ratio(0.8),Train(train_cc)and Test(test_cc) the Dataset.
library(caTools)
credit_clients2$dpnm=factor(credit_clients2$dpnm,levels = c(0,1))
credit_clients2$EDUCATION=factor(credit_clients2$EDUCATION,levels = c(1,2,3,4,5,6))
sample_cc=sample.split(credit_clients2,SplitRatio = 0.8)
sample_cc
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE
[15] TRUE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE FALSE
train_cc=subset(credit_clients2,sample_cc=="TRUE")
Length of logical index must be 1 or 30000, not 25
train_cc
test_cc=subset(credit_clients2,sample_cc=="FALSE")
Length of logical index must be 1 or 30000, not 25
test_cc
Post the Train and Test Process of the dataset,we use (rpart) and (rpart.plot) library to derive the decision tree for the test data that is assigned. We use rpart.control function to control the Decision Tree limits. We use Printcp,Plotcp function to rectify if there were any overfit in the derived decision tree.
library(rpart)
library(rpart.plot)
my_cc_model1=rpart.control(minsplit = 6,minbucket = round(5/3),maxdepth = 6,cp = 0)
my_cc_model=rpart(dpnm~.,data = test_cc,method = "class",
control =my_cc_model1)
my_cc_model
n= 6000
node), split, n, loss, yval, (yprob)
* denotes terminal node
1) root 6000 1337 0 (0.77716667 0.22283333)
2) PAY_0< 1.5 5356 884 0 (0.83495146 0.16504854)
4) PAY_2< 1.5 4942 715 0 (0.85532173 0.14467827)
8) PAY_AMT2>=1500.5 3112 328 0 (0.89460154 0.10539846)
16) PAY_5< 1 2988 295 0 (0.90127175 0.09872825)
32) BILL_AMT3< 477175.5 2983 291 0 (0.90244720 0.09755280) *
33) BILL_AMT3>=477175.5 5 1 1 (0.20000000 0.80000000) *
17) PAY_5>=1 124 33 0 (0.73387097 0.26612903)
34) PAY_AMT3>=3.5 101 21 0 (0.79207921 0.20792079) *
35) PAY_AMT3< 3.5 23 11 1 (0.47826087 0.52173913)
70) BILL_AMT1>=4100.5 17 6 0 (0.64705882 0.35294118) *
71) BILL_AMT1< 4100.5 6 0 1 (0.00000000 1.00000000) *
9) PAY_AMT2< 1500.5 1830 387 0 (0.78852459 0.21147541)
18) PAY_AMT4>=0.5 1091 189 0 (0.82676444 0.17323556)
36) BILL_AMT3< 342.5 282 27 0 (0.90425532 0.09574468)
72) BILL_AMT1< 337307.5 280 25 0 (0.91071429 0.08928571) *
73) BILL_AMT1>=337307.5 2 0 1 (0.00000000 1.00000000) *
37) BILL_AMT3>=342.5 809 162 0 (0.79975278 0.20024722) *
19) PAY_AMT4< 0.5 739 198 0 (0.73207037 0.26792963)
38) BILL_AMT1>=2252 294 54 0 (0.81632653 0.18367347)
76) BILL_AMT5< 40756.5 290 51 0 (0.82413793 0.17586207) *
77) BILL_AMT5>=40756.5 4 1 1 (0.25000000 0.75000000) *
39) BILL_AMT1< 2252 445 144 0 (0.67640449 0.32359551) *
5) PAY_2>=1.5 414 169 0 (0.59178744 0.40821256)
10) PAY_5< 1 298 105 0 (0.64765101 0.35234899)
20) PAY_AMT6>=1581.5 91 19 0 (0.79120879 0.20879121)
40) ID>=327 89 17 0 (0.80898876 0.19101124)
80) ID< 27914.5 82 13 0 (0.84146341 0.15853659) *
81) ID>=27914.5 7 3 1 (0.42857143 0.57142857) *
41) ID< 327 2 0 1 (0.00000000 1.00000000) *
21) PAY_AMT6< 1581.5 207 86 0 (0.58454106 0.41545894)
42) PAY_6< -0.5 57 15 0 (0.73684211 0.26315789) *
43) PAY_6>=-0.5 150 71 0 (0.52666667 0.47333333)
86) BILL_AMT1>=18865 80 29 0 (0.63750000 0.36250000) *
87) BILL_AMT1< 18865 70 28 1 (0.40000000 0.60000000) *
11) PAY_5>=1 116 52 1 (0.44827586 0.55172414)
22) PAY_5< 2.5 108 52 1 (0.48148148 0.51851852)
44) PAY_AMT5< 2064.5 81 36 0 (0.55555556 0.44444444)
88) AGE< 54.5 76 31 0 (0.59210526 0.40789474) *
89) AGE>=54.5 5 0 1 (0.00000000 1.00000000) *
45) PAY_AMT5>=2064.5 27 7 1 (0.25925926 0.74074074)
90) PAY_AMT3>=5700 9 3 0 (0.66666667 0.33333333) *
91) PAY_AMT3< 5700 18 1 1 (0.05555556 0.94444444) *
23) PAY_5>=2.5 8 0 1 (0.00000000 1.00000000) *
3) PAY_0>=1.5 644 191 1 (0.29658385 0.70341615)
6) PAY_3< -0.5 40 18 0 (0.55000000 0.45000000)
12) PAY_AMT3>=1346.5 11 1 0 (0.90909091 0.09090909) *
13) PAY_AMT3< 1346.5 29 12 1 (0.41379310 0.58620690)
26) BILL_AMT1< 1083 12 4 0 (0.66666667 0.33333333)
52) PAY_AMT5< 519 6 0 0 (1.00000000 0.00000000) *
53) PAY_AMT5>=519 6 2 1 (0.33333333 0.66666667)
106) BILL_AMT6>=911 2 0 0 (1.00000000 0.00000000) *
107) BILL_AMT6< 911 4 0 1 (0.00000000 1.00000000) *
27) BILL_AMT1>=1083 17 4 1 (0.23529412 0.76470588)
54) BILL_AMT1>=75450 3 1 0 (0.66666667 0.33333333) *
55) BILL_AMT1< 75450 14 2 1 (0.14285714 0.85714286) *
7) PAY_3>=-0.5 604 169 1 (0.27980132 0.72019868)
14) BILL_AMT1>=18236 460 143 1 (0.31086957 0.68913043)
28) BILL_AMT5< 30470.5 168 70 1 (0.41666667 0.58333333)
56) PAY_AMT1>=6028 5 0 0 (1.00000000 0.00000000) *
57) PAY_AMT1< 6028 163 65 1 (0.39877301 0.60122699)
114) AGE>=60.5 4 0 0 (1.00000000 0.00000000) *
115) AGE< 60.5 159 61 1 (0.38364780 0.61635220) *
29) BILL_AMT5>=30470.5 292 73 1 (0.25000000 0.75000000)
58) PAY_AMT2>=15030.5 7 2 0 (0.71428571 0.28571429) *
59) PAY_AMT2< 15030.5 285 68 1 (0.23859649 0.76140351) *
15) BILL_AMT1< 18236 144 26 1 (0.18055556 0.81944444)
30) AGE< 41.5 100 24 1 (0.24000000 0.76000000)
60) PAY_AMT4>=2500 9 4 0 (0.55555556 0.44444444)
120) BILL_AMT5< 18383.5 6 1 0 (0.83333333 0.16666667) *
121) BILL_AMT5>=18383.5 3 0 1 (0.00000000 1.00000000) *
61) PAY_AMT4< 2500 91 19 1 (0.20879121 0.79120879) *
31) AGE>=41.5 44 2 1 (0.04545455 0.95454545)
62) PAY_3< 1 10 2 1 (0.20000000 0.80000000)
124) BILL_AMT4< 8682.5 2 0 0 (1.00000000 0.00000000) *
125) BILL_AMT4>=8682.5 8 0 1 (0.00000000 1.00000000) *
63) PAY_3>=1 34 0 1 (0.00000000 1.00000000) *
rpart.plot(my_cc_model)
printcp(my_cc_model)
Classification tree:
rpart(formula = dpnm ~ ., data = test_cc, method = "class", control = my_cc_model1)
Variables actually used in tree construction:
[1] AGE BILL_AMT1 BILL_AMT3 BILL_AMT4 BILL_AMT5 BILL_AMT6 ID PAY_0
[9] PAY_2 PAY_3 PAY_5 PAY_6 PAY_AMT1 PAY_AMT2 PAY_AMT3 PAY_AMT4
[17] PAY_AMT5 PAY_AMT6
Root node error: 1337/6000 = 0.22283
n= 6000
CP nsplit rel error xerror xstd
1 0.19596111 0 1.00000 1.00000 0.024110
2 0.00448766 1 0.80404 0.80404 0.022218
3 0.00349040 3 0.79506 0.81825 0.022370
4 0.00336574 6 0.78459 0.81750 0.022362
5 0.00299177 11 0.76739 0.81301 0.022314
6 0.00224383 12 0.76440 0.81376 0.022322
7 0.00149589 13 0.76215 0.83022 0.022496
8 0.00134630 21 0.74869 0.83096 0.022504
9 0.00099726 26 0.74196 0.83096 0.022504
10 0.00074794 29 0.73897 0.83396 0.022535
11 0.00059835 33 0.73598 0.83844 0.022582
12 0.00000000 38 0.73298 0.83994 0.022597
plotcp(my_cc_model)
After deriving the Decision Tree,We Predict The Values of Test data. Then,we use table function to derive the Actual Value of the Dependent Variable(dpnm) from the dataset and the Predicted value of the using the test dataset.
pred=predict(my_cc_model,test_cc,type = "class")
pred
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
1 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990
0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0
991 992 993 994 995 996 997 998 999 1000
0 0 0 0 1 0 0 0 0 0
[ reached getOption("max.print") -- omitted 5000 entries ]
Levels: 0 1
t1=table(actualvalue=test_cc$dpnm,predictedvalue=pred)
Finally,We conclude by checking the accuracy of the Predicted Value with the Actual Value. Here,the Accuracy of the Predicted value =0.8388 (i.e) 83.88%
accu_test=sum(diag(t1))/sum(t1)
accu_test
[1] 0.8366667