creditn.csv
Income,Limit,Rating,Cards,Age,Education,Gender,Student,Married,Balance
14.891,3606,283,2,34,11,Male,No,Yes,333
106.025,6645,483,3,82,15,Female,Yes,Yes,903
104.593,7075,514,4,71,11,Male,No,No,580
148.924,9504,681,3,36,11,Female,No,No,964
55.882,4897,357,2,68,16,Male,No,Yes,331
80.18,8047,569,4,77,10,Male,No,No,1151
20.996,3388,259,2,37,12,Female,No,No,203
71.408,7114,512,2,87,9,Male,No,No,872
15.125,3300,266,5,66,13,Female,No,No,279
71.061,6819,491,3,41,19,Female,Yes,Yes,1350
63.095,8117,589,4,30,14,Male,No,Yes,1407
15.045,1311,138,3,64,16,Male,No,No,0
80.616,5308,394,1,57,7,Female,No,Yes,204
43.682,6922,511,1,49,9,Male,No,Yes,1081
19.144,3291,269,2,75,13,Female,No,No,148
20.089,2525,200,3,57,15,Female,No,Yes,0
53.598,3714,286,3,73,17,Female,No,Yes,0
36.496,4378,339,3,69,15,Female,No,Yes,368
49.57,6384,448,1,28,9,Female,No,Yes,891
42.079,6626,479,2,44,9,Male,No,No,1048
17.7,2860,235,4,63,16,Female,No,No,89
37.348,6378,458,1,72,17,Female,No,No,968
20.103,2631,213,3,61,10,Male,No,Yes,0
64.027,5179,398,5,48,8,Male,No,Yes,411
10.742,1757,156,3,57,15,Female,No,No,0
14.09,4323,326,5,25,16,Female,No,Yes,671
42.471,3625,289,6,44,12,Female,Yes,No,654
32.793,4534,333,2,44,16,Male,No,No,467
186.634,13414,949,2,41,14,Female,No,Yes,1809
26.813,5611,411,4,55,16,Female,No,No,915
34.142,5666,413,4,47,5,Female,No,Yes,863
28.941,2733,210,5,43,16,Male,No,Yes,0
134.181,7838,563,2,48,13,Female,No,No,526
31.367,1829,162,4,30,10,Male,No,Yes,0
20.15,2646,199,2,25,14,Female,No,Yes,0
23.35,2558,220,3,49,12,Female,Yes,No,419
62.413,6457,455,2,71,11,Female,No,Yes,762
30.007,6481,462,2,69,9,Female,No,Yes,1093
11.795,3899,300,4,25,10,Female,No,No,531
13.647,3461,264,4,47,14,Male,No,Yes,344
34.95,3327,253,3,54,14,Female,No,No,50
113.659,7659,538,2,66,15,Male,Yes,Yes,1155
44.158,4763,351,2,66,13,Female,No,Yes,385
36.929,6257,445,1,24,14,Female,No,Yes,976
31.861,6375,469,3,25,16,Female,No,Yes,1120
77.38,7569,564,3,50,12,Female,No,Yes,997
19.531,5043,376,2,64,16,Female,Yes,Yes,1241
44.646,4431,320,2,49,15,Male,Yes,Yes,797
44.522,2252,205,6,72,15,Male,No,Yes,0
43.479,4569,354,4,49,13,Male,Yes,Yes,902
36.362,5183,376,3,49,15,Male,No,Yes,654
39.705,3969,301,2,27,20,Male,No,Yes,211
44.205,5441,394,1,32,12,Male,No,Yes,607
16.304,5466,413,4,66,10,Male,No,Yes,957
15.333,1499,138,2,47,9,Female,No,Yes,0
32.916,1786,154,2,60,8,Female,No,Yes,0
57.1,4742,372,7,79,18,Female,No,Yes,379
76.273,4779,367,4,65,14,Female,No,Yes,133
10.354,3480,281,2,70,17,Male,No,Yes,333
51.872,5294,390,4,81,17,Female,No,No,531
35.51,5198,364,2,35,20,Female,No,No,631
21.238,3089,254,3,59,10,Female,No,No,108
30.682,1671,160,2,77,7,Female,No,No,0
14.132,2998,251,4,75,17,Male,No,No,133
32.164,2937,223,2,79,15,Female,No,Yes,0
12,4160,320,4,28,14,Female,No,Yes,602
113.829,9704,694,4,38,13,Female,No,Yes,1388
11.187,5099,380,4,69,16,Female,No,No,889
27.847,5619,418,2,78,15,Female,No,Yes,822
49.502,6819,505,4,55,14,Male,No,Yes,1084
24.889,3954,318,4,75,12,Male,No,Yes,357
58.781,7402,538,2,81,12,Female,No,Yes,1103
22.939,4923,355,1,47,18,Female,No,Yes,663
23.989,4523,338,4,31,15,Male,No,No,601
16.103,5390,418,4,45,10,Female,No,Yes,945
33.017,3180,224,2,28,16,Male,No,Yes,29
30.622,3293,251,1,68,16,Male,Yes,No,532
20.936,3254,253,1,30,15,Female,No,No,145
110.968,6662,468,3,45,11,Female,No,Yes,391
15.354,2101,171,2,65,14,Male,No,No,0
27.369,3449,288,3,40,9,Female,No,Yes,162
53.48,4263,317,1,83,15,Male,No,No,99
23.672,4433,344,3,63,11,Male,No,No,503
19.225,1433,122,3,38,14,Female,No,No,0
43.54,2906,232,4,69,11,Male,No,No,0
152.298,12066,828,4,41,12,Female,No,Yes,1779
55.367,6340,448,1,33,15,Male,No,Yes,815
11.741,2271,182,4,59,12,Female,No,No,0
15.56,4307,352,4,57,8,Male,No,Yes,579
59.53,7518,543,3,52,9,Female,No,No,1176
20.191,5767,431,4,42,16,Male,No,Yes,1023
48.498,6040,456,3,47,16,Male,No,Yes,812
30.733,2832,249,4,51,13,Male,No,No,0
16.479,5435,388,2,26,16,Male,No,No,937
38.009,3075,245,3,45,15,Female,No,No,0
14.084,855,120,5,46,17,Female,No,Yes,0
14.312,5382,367,1,59,17,Male,Yes,No,1380
26.067,3388,266,4,74,17,Female,No,Yes,155
36.295,2963,241,2,68,14,Female,Yes,No,375
83.851,8494,607,5,47,18,Male,No,No,1311
21.153,3736,256,1,41,11,Male,No,No,298
17.976,2433,190,3,70,16,Female,Yes,No,431
68.713,7582,531,2,56,16,Male,Yes,No,1587
146.183,9540,682,6,66,15,Male,No,No,1050
15.846,4768,365,4,53,12,Female,No,No,745
12.031,3182,259,2,58,18,Female,No,Yes,210
16.819,1337,115,2,74,15,Male,No,Yes,0
39.11,3189,263,3,72,12,Male,No,No,0
107.986,6033,449,4,64,14,Male,No,Yes,227
13.561,3261,279,5,37,19,Male,No,Yes,297
34.537,3271,250,3,57,17,Female,No,Yes,47
28.575,2959,231,2,60,11,Female,No,No,0
46.007,6637,491,4,42,14,Male,No,Yes,1046
69.251,6386,474,4,30,12,Female,No,Yes,768
16.482,3326,268,4,41,15,Male,No,No,271
40.442,4828,369,5,81,8,Female,No,No,510
35.177,2117,186,3,62,16,Female,No,No,0
91.362,9113,626,1,47,17,Male,No,Yes,1341
27.039,2161,173,3,40,17,Female,No,No,0
23.012,1410,137,3,81,16,Male,No,No,0
27.241,1402,128,2,67,15,Female,No,Yes,0
148.08,8157,599,2,83,13,Male,No,Yes,454
62.602,7056,481,1,84,11,Female,No,No,904
11.808,1300,117,3,77,14,Female,No,No,0
29.564,2529,192,1,30,12,Female,No,Yes,0
27.578,2531,195,1,34,15,Female,No,Yes,0
26.427,5533,433,5,50,15,Female,Yes,Yes,1404
57.202,3411,259,3,72,11,Female,No,No,0
123.299,8376,610,2,89,17,Male,Yes,No,1259
18.145,3461,279,3,56,15,Male,No,Yes,255
23.793,3821,281,4,56,12,Female,Yes,Yes,868
10.726,1568,162,5,46,19,Male,No,Yes,0
23.283,5443,407,4,49,13,Male,No,Yes,912
21.455,5829,427,4,80,12,Female,No,Yes,1018
34.664,5835,452,3,77,15,Female,No,Yes,835
44.473,3500,257,3,81,16,Female,No,No,8
54.663,4116,314,2,70,8,Female,No,No,75
36.355,3613,278,4,35,9,Male,No,Yes,187
21.374,2073,175,2,74,11,Female,No,Yes,0
107.841,10384,728,3,87,7,Male,No,No,1597
39.831,6045,459,3,32,12,Female,Yes,Yes,1425
91.876,6754,483,2,33,10,Male,No,Yes,605
103.893,7416,549,3,84,17,Male,No,No,669
19.636,4896,387,3,64,10,Female,No,No,710
17.392,2748,228,3,32,14,Male,No,Yes,68
19.529,4673,341,2,51,14,Male,No,No,642
17.055,5110,371,3,55,15,Female,No,Yes,805
23.857,1501,150,3,56,16,Male,No,Yes,0
15.184,2420,192,2,69,11,Female,No,Yes,0
13.444,886,121,5,44,10,Male,No,Yes,0
63.931,5728,435,3,28,14,Female,No,Yes,581
35.864,4831,353,3,66,13,Female,No,Yes,534
41.419,2120,184,4,24,11,Female,Yes,No,156
92.112,4612,344,3,32,17,Male,No,No,0
55.056,3155,235,2,31,16,Male,No,Yes,0
19.537,1362,143,4,34,9,Female,No,Yes,0
31.811,4284,338,5,75,13,Female,No,Yes,429
56.256,5521,406,2,72,16,Female,Yes,Yes,1020
42.357,5550,406,2,83,12,Female,No,Yes,653
53.319,3000,235,3,53,13,Male,No,No,0
12.238,4865,381,5,67,11,Female,No,No,836
31.353,1705,160,3,81,14,Male,No,Yes,0
63.809,7530,515,1,56,12,Male,No,Yes,1086
13.676,2330,203,5,80,16,Female,No,No,0
76.782,5977,429,4,44,12,Male,No,Yes,548
25.383,4527,367,4,46,11,Male,No,Yes,570
35.691,2880,214,2,35,15,Male,No,No,0
29.403,2327,178,1,37,14,Female,No,Yes,0
27.47,2820,219,1,32,11,Female,No,Yes,0
27.33,6179,459,4,36,12,Female,No,Yes,1099
34.772,2021,167,3,57,9,Male,No,No,0
36.934,4270,299,1,63,9,Female,No,Yes,283
76.348,4697,344,4,60,18,Male,No,No,108
14.887,4745,339,3,58,12,Male,No,Yes,724
121.834,10673,750,3,54,16,Male,No,No,1573
30.132,2168,206,3,52,17,Male,No,No,0
24.05,2607,221,4,32,18,Male,No,Yes,0
22.379,3965,292,2,34,14,Female,No,Yes,384
28.316,4391,316,2,29,10,Female,No,No,453
58.026,7499,560,5,67,11,Female,No,No,1237
10.635,3584,294,5,69,16,Male,No,Yes,423
46.102,5180,382,3,81,12,Male,No,Yes,516
58.929,6420,459,2,66,9,Female,No,Yes,789
80.861,4090,335,3,29,15,Female,No,Yes,0
158.889,11589,805,1,62,17,Female,No,Yes,1448
30.42,4442,316,1,30,14,Female,No,No,450
36.472,3806,309,2,52,13,Male,No,No,188
23.365,2179,167,2,75,15,Male,No,No,0
83.869,7667,554,2,83,11,Male,No,No,930
58.351,4411,326,2,85,16,Female,No,Yes,126
55.187,5352,385,4,50,17,Female,No,Yes,538
124.29,9560,701,3,52,17,Female,Yes,No,1687
28.508,3933,287,4,56,14,Male,No,Yes,336
130.209,10088,730,7,39,19,Female,No,Yes,1426
30.406,2120,181,2,79,14,Male,No,Yes,0
23.883,5384,398,2,73,16,Female,No,Yes,802
93.039,7398,517,1,67,12,Male,No,Yes,749
50.699,3977,304,2,84,17,Female,No,No,69
27.349,2000,169,4,51,16,Female,No,Yes,0
10.403,4159,310,3,43,7,Male,No,Yes,571
23.949,5343,383,2,40,18,Male,No,Yes,829
73.914,7333,529,6,67,15,Female,No,Yes,1048
21.038,1448,145,2,58,13,Female,No,Yes,0
68.206,6784,499,5,40,16,Female,Yes,No,1411
57.337,5310,392,2,45,7,Female,No,No,456
10.793,3878,321,8,29,13,Male,No,No,638
23.45,2450,180,2,78,13,Male,No,No,0
10.842,4391,358,5,37,10,Female,Yes,Yes,1216
51.345,4327,320,3,46,15,Male,No,No,230
151.947,9156,642,2,91,11,Female,No,Yes,732
24.543,3206,243,2,62,12,Female,No,Yes,95
29.567,5309,397,3,25,15,Male,No,No,799
39.145,4351,323,2,66,13,Male,No,Yes,308
39.422,5245,383,2,44,19,Male,No,No,637
34.909,5289,410,2,62,16,Female,No,Yes,681
41.025,4229,337,3,79,19,Female,No,Yes,246
15.476,2762,215,3,60,18,Male,No,No,52
12.456,5395,392,3,65,14,Male,No,Yes,955
10.627,1647,149,2,71,10,Female,Yes,Yes,195
38.954,5222,370,4,76,13,Female,No,No,653
44.847,5765,437,3,53,13,Female,Yes,No,1246
98.515,8760,633,5,78,11,Female,No,No,1230
33.437,6207,451,4,44,9,Male,Yes,No,1549
27.512,4613,344,5,72,17,Male,No,Yes,573
121.709,7818,584,4,50,6,Male,No,Yes,701
15.079,5673,411,4,28,15,Female,No,Yes,1075
59.879,6906,527,6,78,15,Female,No,No,1032
66.989,5614,430,3,47,14,Female,No,Yes,482
69.165,4668,341,2,34,11,Female,No,No,156
69.943,7555,547,3,76,9,Male,No,Yes,1058
33.214,5137,387,3,59,9,Male,No,No,661
25.124,4776,378,4,29,12,Male,No,Yes,657
15.741,4788,360,1,39,14,Male,No,Yes,689
11.603,2278,187,3,71,11,Male,No,Yes,0
69.656,8244,579,3,41,14,Male,No,Yes,1329
10.503,2923,232,3,25,18,Female,No,Yes,191
42.529,4986,369,2,37,11,Male,No,Yes,489
60.579,5149,388,5,38,15,Male,No,Yes,443
26.532,2910,236,6,58,19,Female,No,Yes,52
27.952,3557,263,1,35,13,Female,No,Yes,163
29.705,3351,262,5,71,14,Female,No,Yes,148
15.602,906,103,2,36,11,Male,No,Yes,0
20.918,1233,128,3,47,18,Female,Yes,Yes,16
58.165,6617,460,1,56,12,Female,No,Yes,856
22.561,1787,147,4,66,15,Female,No,No,0
34.509,2001,189,5,80,18,Female,No,Yes,0
19.588,3211,265,4,59,14,Female,No,No,199
36.364,2220,188,3,50,19,Male,No,No,0
15.717,905,93,1,38,16,Male,Yes,Yes,0
22.574,1551,134,3,43,13,Female,Yes,Yes,98
10.363,2430,191,2,47,18,Female,No,Yes,0
28.474,3202,267,5,66,12,Male,No,Yes,132
72.945,8603,621,3,64,8,Female,No,No,1355
85.425,5182,402,6,60,12,Male,No,Yes,218
36.508,6386,469,4,79,6,Female,No,Yes,1048
58.063,4221,304,3,50,8,Male,No,No,118
25.936,1774,135,2,71,14,Female,No,No,0
15.629,2493,186,1,60,14,Male,No,Yes,0
41.4,2561,215,2,36,14,Male,No,Yes,0
33.657,6196,450,6,55,9,Female,No,No,1092
67.937,5184,383,4,63,12,Male,No,Yes,345
180.379,9310,665,3,67,8,Female,Yes,Yes,1050
10.588,4049,296,1,66,13,Female,No,Yes,465
29.725,3536,270,2,52,15,Female,No,No,133
27.999,5107,380,1,55,10,Male,No,Yes,651
40.885,5013,379,3,46,13,Female,No,Yes,549
88.83,4952,360,4,86,16,Female,No,Yes,15
29.638,5833,433,3,29,15,Female,No,Yes,942
25.988,1349,142,4,82,12,Male,No,No,0
39.055,5565,410,4,48,18,Female,No,Yes,772
15.866,3085,217,1,39,13,Male,No,No,136
44.978,4866,347,1,30,10,Female,No,No,436
30.413,3690,299,2,25,15,Female,Yes,No,728
16.751,4706,353,6,48,14,Male,Yes,No,1255
30.55,5869,439,5,81,9,Female,No,No,967
163.329,8732,636,3,50,14,Male,No,Yes,529
23.106,3476,257,2,50,15,Female,No,No,209
41.532,5000,353,2,50,12,Male,No,Yes,531
128.04,6982,518,2,78,11,Female,No,Yes,250
54.319,3063,248,3,59,8,Female,Yes,No,269
53.401,5319,377,3,35,12,Female,No,No,541
36.142,1852,183,3,33,13,Female,No,No,0
63.534,8100,581,2,50,17,Female,No,Yes,1298
49.927,6396,485,3,75,17,Female,No,Yes,890
14.711,2047,167,2,67,6,Male,No,Yes,0
18.967,1626,156,2,41,11,Female,No,Yes,0
18.036,1552,142,2,48,15,Female,No,No,0
60.449,3098,272,4,69,8,Male,No,Yes,0
16.711,5274,387,3,42,16,Female,No,Yes,863
10.852,3907,296,2,30,9,Male,No,No,485
26.37,3235,268,5,78,11,Male,No,Yes,159
24.088,3665,287,4,56,13,Female,No,Yes,309
51.532,5096,380,2,31,15,Male,No,Yes,481
140.672,11200,817,7,46,9,Male,No,Yes,1677
42.915,2532,205,4,42,13,Male,No,Yes,0
27.272,1389,149,5,67,10,Female,No,Yes,0
65.896,5140,370,1,49,17,Female,No,Yes,293
55.054,4381,321,3,74,17,Male,No,Yes,188
20.791,2672,204,1,70,18,Female,No,No,0
24.919,5051,372,3,76,11,Female,No,Yes,711
21.786,4632,355,1,50,17,Male,No,Yes,580
31.335,3526,289,3,38,7,Female,No,No,172
59.855,4964,365,1,46,13,Female,No,Yes,295
44.061,4970,352,1,79,11,Male,No,Yes,414
82.706,7506,536,2,64,13,Female,No,Yes,905
24.46,1924,165,2,50,14,Female,No,Yes,0
45.12,3762,287,3,80,8,Male,No,Yes,70
75.406,3874,298,3,41,14,Female,No,Yes,0
14.956,4640,332,2,33,6,Male,No,No,681
75.257,7010,494,3,34,18,Female,No,Yes,885
33.694,4891,369,1,52,16,Male,Yes,No,1036
23.375,5429,396,3,57,15,Female,No,Yes,844
27.825,5227,386,6,63,11,Male,No,Yes,823
92.386,7685,534,2,75,18,Female,No,Yes,843
115.52,9272,656,2,69,14,Male,No,No,1140
14.479,3907,296,3,43,16,Male,No,Yes,463
52.179,7306,522,2,57,14,Male,No,No,1142
68.462,4712,340,2,71,16,Male,No,Yes,136
18.951,1485,129,3,82,13,Female,No,No,0
27.59,2586,229,5,54,16,Male,No,Yes,0
16.279,1160,126,3,78,13,Male,Yes,Yes,5
25.078,3096,236,2,27,15,Female,No,Yes,81
27.229,3484,282,6,51,11,Male,No,No,265
182.728,13913,982,4,98,17,Male,No,Yes,1999
31.029,2863,223,2,66,17,Male,Yes,Yes,415
17.765,5072,364,1,66,12,Female,No,Yes,732
125.48,10230,721,3,82,16,Male,No,Yes,1361
49.166,6662,508,3,68,14,Female,No,No,984
41.192,3673,297,3,54,16,Female,No,Yes,121
94.193,7576,527,2,44,16,Female,No,Yes,846
20.405,4543,329,2,72,17,Male,Yes,No,1054
12.581,3976,291,2,48,16,Male,No,Yes,474
62.328,5228,377,3,83,15,Male,No,No,380
21.011,3402,261,2,68,17,Male,No,Yes,182
24.23,4756,351,2,64,15,Female,No,Yes,594
24.314,3409,270,2,23,7,Female,No,Yes,194
32.856,5884,438,4,68,13,Male,No,No,926
12.414,855,119,3,32,12,Male,No,Yes,0
41.365,5303,377,1,45,14,Male,No,No,606
149.316,10278,707,1,80,16,Male,No,No,1107
27.794,3807,301,4,35,8,Female,No,Yes,320
13.234,3922,299,2,77,17,Female,No,Yes,426
14.595,2955,260,5,37,9,Male,No,Yes,204
10.735,3746,280,2,44,17,Female,No,Yes,410
48.218,5199,401,7,39,10,Male,No,Yes,633
30.012,1511,137,2,33,17,Male,No,Yes,0
21.551,5380,420,5,51,18,Male,No,Yes,907
160.231,10748,754,2,69,17,Male,No,No,1192
13.433,1134,112,3,70,14,Male,No,Yes,0
48.577,5145,389,3,71,13,Female,No,Yes,503
30.002,1561,155,4,70,13,Female,No,Yes,0
61.62,5140,374,1,71,9,Male,No,Yes,302
104.483,7140,507,2,41,14,Male,No,Yes,583
41.868,4716,342,2,47,18,Male,No,No,425
12.068,3873,292,1,44,18,Female,No,Yes,413
180.682,11966,832,2,58,8,Female,No,Yes,1405
34.48,6090,442,3,36,14,Male,No,No,962
39.609,2539,188,1,40,14,Male,No,Yes,0
30.111,4336,339,1,81,18,Male,No,Yes,347
12.335,4471,344,3,79,12,Male,No,Yes,611
53.566,5891,434,4,82,10,Female,No,No,712
53.217,4943,362,2,46,16,Female,No,Yes,382
26.162,5101,382,3,62,19,Female,No,No,710
64.173,6127,433,1,80,10,Male,No,Yes,578
128.669,9824,685,3,67,16,Male,No,Yes,1243
113.772,6442,489,4,69,15,Male,Yes,Yes,790
61.069,7871,564,3,56,14,Male,No,Yes,1264
23.793,3615,263,2,70,14,Male,No,No,216
89,5759,440,3,37,6,Female,No,No,345
71.682,8028,599,3,57,16,Male,No,Yes,1208
35.61,6135,466,4,40,12,Male,No,No,992
39.116,2150,173,4,75,15,Male,No,No,0
19.782,3782,293,2,46,16,Female,Yes,No,840
55.412,5354,383,2,37,16,Female,Yes,Yes,1003
29.4,4840,368,3,76,18,Female,No,Yes,588
20.974,5673,413,5,44,16,Female,No,Yes,1000
87.625,7167,515,2,46,10,Female,No,No,767
28.144,1567,142,3,51,10,Male,No,Yes,0
19.349,4941,366,1,33,19,Male,No,Yes,717
53.308,2860,214,1,84,10,Male,No,Yes,0
115.123,7760,538,3,83,14,Female,No,No,661
101.788,8029,574,2,84,11,Male,No,Yes,849
24.824,5495,409,1,33,9,Male,Yes,No,1352
14.292,3274,282,9,64,9,Male,No,Yes,382
20.088,1870,180,3,76,16,Male,No,No,0
26.4,5640,398,3,58,15,Female,No,No,905
19.253,3683,287,4,57,10,Male,No,No,371
16.529,1357,126,3,62,9,Male,No,No,0
37.878,6827,482,2,80,13,Female,No,No,1129
83.948,7100,503,2,44,18,Male,No,No,806
135.118,10578,747,3,81,15,Female,No,Yes,1393
73.327,6555,472,2,43,15,Female,No,No,721
25.974,2308,196,2,24,10,Male,No,No,0
17.316,1335,138,2,65,13,Male,No,No,0
49.794,5758,410,4,40,8,Male,No,No,734
12.096,4100,307,3,32,13,Male,No,Yes,560
13.364,3838,296,5,65,17,Male,No,No,480
57.872,4171,321,5,67,12,Female,No,Yes,138
37.728,2525,192,1,44,13,Male,No,Yes,0
18.701,5524,415,5,64,7,Female,No,No,966
RR.ipynb
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {
"colab": {
"name": "CAP5625_Assignment1.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3.9.4 64-bit"
},
"language_info": {
"name": "python",
"version": "3.9.4",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"interpreter": {
"hash": "81118431cc388d258ed977b65143603a98f8ad6ed776c173758a3af876bc6de9"
}
},
"cells": [
{
"cell_type": "code",
"execution_count": 102,
"source": [
"import numpy as np\r\n",
"import matplotlib.pyplot as plt\r\n",
"import os\r\n",
"import pandas as pd"
],
"outputs": [],
"metadata": {
"id": "ZfXIWZ57NkON"
}
},
{
"cell_type": "code",
"execution_count": 103,
"source": [
"class RRegression:\r\n",
" def __init__(self, preds, responses, lambdas, iters = 2000, nfolds = 4, alpha = 1e-4, ):\r\n",
"\r\n",
" self.x, self.y = self._shuffle_data(preds, responses)\r\n",
" self.lambdas = lambdas \r\n",
" self.nfolds = nfolds\r\n",
" self.alpha = alpha \r\n",
" self.iters = iters\r\n",
" self.initialize()\r\n",
"\r\n",
"\r\n",
" def initialize(self):\r\n",
" \r\n",
"\r\n",
" # get number of samples and number of features\r\n",
" self.n_samples = self.x.shape[0]\r\n",
" self.n_preds = self.x.shape[1]\r\n",
" \r\n",
" # matrix to store the cross validation results \r\n",
" self.cv_vals = np.zeros([self.nfolds, len(self.lambdas)])\r\n",
"\r\n",
" # determine the number of validation samples and their inds based on nfolds \r\n",
" self.nval = self.n_samples // self.nfolds \r\n",
" self.ivals = list(range(0, self.n_samples, self.nval))\r\n",
"\r\n",
" # create a tensor to store the Betas \r\n",
" self.B_trained = np.zeros([self.nfolds, len(self.lambdas), self.n_preds])\r\n",
"\r\n",
" def _standardize(self, x, mean_vec, std_vec):\r\n",
"\r\n",
" return (x - mean_vec) / std_vec \r\n",
"\r\n",
" def _center_responses(self, y, mean):\r\n",
"\r\n",
"\r\n",
" return y - mean\r\n",
"\r\n",
" def _shuffle_data(self, preds, responses):\r\n",
"\r\n",
"\r\n",
" data = np.concatenate((preds, responses[:, None]), 1)\r\n",
" np.random.shuffle(data)\r\n",
" return data[:, :-1], data[:, -1]\r\n",
"\r\n",
" def initialize_B(self):\r\n",
" \r\n",
" return np.random.uniform(low = -1, high = 1, size = (self.n_preds, 1))\r\n",
"\r\n",
" def predict(self, x):\r\n",
"\r\n",
" assert(self.mean_vec is not None and self.std_vec is not None), \\\r\n",
" 'Train mode first'\r\n",
"\r\n",
" x = self._standardize(x, self.mean_vec, self.std_vec)\r\n",
" return np.matmul(x, self.B)\r\n",
"\r\n",
" def fold(self, ival):\r\n",
"\r\n",
" x_val = self.x[ival:ival + self.nval]\r\n",
" x_train = np.delete(self.x, np.arange(ival, ival + self.nval), axis = 0)\r\n",
" y_val = self.y[ival:ival + self.nval]\r\n",
" y_train = np.delete(self.y, np.arange(ival, ival + self.nval), axis = 0)\r\n",
" return x_train, x_val, y_train, y_val\r\n",
"\r\n",
" def update(self, x, y, B, lambda_):\r\n",
"\r\n",
"\r\n",
" return B - 2 * self.alpha * (lambda_ * B - np.matmul(x.transpose(), y - np.matmul(x, B)))\r\n",
"\r\n",
" def score(self, x, y, B):\r\n",
"\r\n",
"\r\n",
" y_hat = np.matmul(x, B)\r\n",
" mse = np.mean((y - y_hat) ** 2)\r\n",
" return mse\r\n",
"\r\n",
" def fit(self):\r\n",
"\r\n",
"\r\n",
" for i_lambda, lambda_ in enumerate(self.lambdas):\r\n",
" for i_fold, ival in zip(range(self.nfolds), self.ivals):\r\n",
" # get the folds\r\n",
" x_train, x_val, y_train, y_val = self.fold(ival)\r\n",
"\r\n",
" # standardize x and center y\r\n",
" mean_vec, std_vec = np.mean(x_train, 0), np.std(x_train, 0)\r\n",
" mean_response = np.mean(y_train)\r\n",
" x_train = self._standardize(x_train, mean_vec, std_vec)\r\n",
" x_val = self._standardize(x_val, mean_vec, std_vec)\r\n",
" y_train = self._center_responses(y_train, mean_response)[:, None]\r\n",
" y_val = self._center_responses(y_val, mean_response)[:, None]\r\n",
"\r\n",
" # initialize Beta for this lambda and fold\r\n",
" B = self.initialize_B()\r\n",
"\r\n",
" for iter in range(self.iters):\r\n",
" B = self.update(x_train, y_train, B, lambda_)\r\n",
"\r\n",
" # score this model and store the value \r\n",
" self.cv_vals[i_fold, i_lambda] = self.score(x_val, y_val, B)\r\n",
"\r\n",
" # store the coefficient vector\r\n",
" self.B_trained[i_fold, i_lambda] = B[:, 0]\r\n",
"\r\n",
" # find the best lambda and retrain model\r\n",
" self.best_lambda = self.lambdas[np.argmin(np.mean(self.cv_vals, 0))]\r\n",
" self.mean_vec, self.std_vec = np.mean(self.x, 0), np.std(self.x, 0)\r\n",
" x = self._standardize(self.x, self.mean_vec, self.std_vec)\r\n",
" y = self._center_responses(self.y, np.mean(self.y))[:, None]\r\n",
" self.B = self.initialize_B()\r\n",
" for iter in range(self.iters):\r\n",
" self.B = self.update(x, y, self.B, self.best_lambda)"
],
"outputs": [],
"metadata": {
"id": "nMdVQfNePLQJ"
}
},
{
"cell_type": "code",
"execution_count": 104,
"source": [
"# read in the data into a pandas dataframe\r\n",
"df = pd.read_csv('creditn.csv')\r\n",
"df"
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Income | \n",
"Limit | \n",
"Rating | \n",
"Cards | \n",
"Age | \n",
"Education | \n",
"Gender | \n",
"Student | \n",
"Married | \n",
"Balance | \n",
"
\n",
"\n",
"\n",
"\n",
"0 | \n",
"14.891 | \n",
"3606 | \n",
"283 | \n",
"2 | \n",
"34 | \n",
"11 | \n",
"Male | \n",
"No | \n",
"Yes | \n",
"333 | \n",
"
\n",
"\n",
"1 | \n",
"106.025 | \n",
"6645 | \n",
"483 | \n",
"3 | \n",
"82 | \n",
"15 | \n",
"Female | \n",
"Yes | \n",
"Yes | \n",
"903 | \n",
"
\n",
"\n",
"2 | \n",
"104.593 | \n",
"7075 | \n",
"514 | \n",
"4 | \n",
"71 | \n",
"11 | \n",
"Male | \n",
"No | \n",
"No | \n",
"580 | \n",
"
\n",
"\n",
"3 | \n",
"148.924 | \n",
"9504 | \n",
"681 | \n",
"3 | \n",
"36 | \n",
"11 | \n",
"Female | \n",
"No | \n",
"No | \n",
"964 | \n",
"
\n",
"\n",
"4 | \n",
"55.882 | \n",
"4897 | \n",
"357 | \n",
"2 | \n",
"68 | \n",
"16 | \n",
"Male | \n",
"No | \n",
"Yes | \n",
"331 | \n",
"
\n",
"\n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"... | \n",
"
\n",
"\n",
"395 | \n",
"12.096 | \n",
"4100 | \n",
"307 | \n",
"3 | \n",
"32 | \n",
"13 | \n",
"Male | \n",
"No | \n",
"Yes | \n",
"560 | \n",
"
\n",
"\n",
"396 | \n",
"13.364 | \n",
"3838 | \n",
"296 | \n",
"5 | \n",
"65 | \n",
"17 | \n",
"Male | \n",
"No | \n",
"No | \n",
"480 | \n",
"
\n",
"\n",
"397 | \n",
"57.872 | \n",
"4171 | \n",
"321 | \n",
"5 | \n",
"67 | \n",
"12 | \n",
"Female | \n",
"No | \n",
"Yes | \n",
"138 | \n",
"
\n",
"\n",
"398 | \n",
"37.728 | \n",
"2525 | \n",
"192 | \n",
"1 | \n",
"44 | \n",
"13 | \n",
"Male | \n",
"No | \n",
"Yes | \n",
"0 | \n",
"
\n",
"\n",
"399 | \n",
"18.701 | \n",
"5524 | \n",
"415 | \n",
"5 | \n",
"64 | \n",
"7 | \n",
"Female | \n",
"No | \n",
"No | \n",
"966 | \n",
"
\n",
"\n",
"
\n",
"
400 rows × 10 columns
\n",
"
"
],
"text/plain": [
" Income Limit Rating Cards Age Education Gender Student Married \\\n",
"0 14.891 3606 283 2 34 11 Male No Yes \n",
"1 106.025 6645 483 3 82 15 Female Yes Yes \n",
"2 104.593 7075 514 4 71 11 Male No No \n",
"3 148.924 9504 681 3 36 11 Female No No \n",
"4 55.882 4897 357 2 68 16 Male No Yes \n",
".. ... ... ... ... ... ... ... ... ... \n",
"395 12.096 4100 307 3 32 13 Male No Yes \n",
"396 13.364 3838 296 5 65 17 Male No No \n",
"397 57.872 4171 321 5 67 12 Female No Yes \n",
"398 37.728 2525 192 1 44 13 Male No Yes \n",
"399 18.701 5524 415 5 64 7 Female No No \n",
"\n",
" Balance \n",
"0 333 \n",
"1 903 \n",
"2 580 \n",
"3 964 \n",
"4 331 \n",
".. ... \n",
"395 560 \n",
"396 480 \n",
"397 138 \n",
"398 0 \n",
"399 966 \n",
"\n",
"[400 rows x 10 columns]"
]
},
"metadata": {},
"execution_count": 104
}
],
"metadata": {
"id": "2yKcu-xHOwnO",
"outputId": "6b6549d7-3105-4600-c9a1-1bb42d9f335c",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 419
}
}
},
{
"cell_type": "code",
"execution_count": 105,
"source": [
"# recode the gender, student, and married preds \r\n",
"df['Gender'].replace(to_replace = dict(Female = 0, Male = 1), inplace=True)\r\n",
"df['Student'].replace(to_replace = dict(No = 0, Yes = 1), inplace=True)\r\n",
"df['Married'].replace(to_replace = dict(No = 0, Yes = 1), inplace=True)\r\n",
"df"
],
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Income | \n",
"Limit | \n",
"Rating | \n",
"Cards | \n",
"Age | \n",
"Education | \n",
"Gender | \n",
"Student | \n",
"Married | \n",
"Balance | \n",
"
\n",
"\n",
"\n",
"\n",
"0 | \n",
"14.891 | \n",
"3606 | \n",
"283 | \n",
"2 | \n",
"34 | \n",
"11 | \n",
"1 | \n",
"0 | \n",
"1 | \n",
"333 | \n",
"
\n",
"\n",
"1 | \n",
"106.025 | \n",
"6645 | \n",
"483 | \n",
"3 | \n",
"82 | \n",
"15 | \n",
"0 | \n",
"1 | \n",
"1 | \n",
"903 | \n",
"
\n",
"\n",
"2 | \n",
"104.593 | \n",
"7075 | \n",
"514 | \n",
"4 | \n",
"71 | \n",
"11 | \n",
"1 | \n",
"0 | \n",
"0 | \n",
"580 | \n",
"
\n",
"\n",
"3 | \n",
"148.924 | \n",
"9504 | \n",
"681 | \n",
"3 | \n",
"36 | \n",
"11 | \n",
"0 | \n",
"0 | \n",
"0 | \n",
"964 | \n",
"
\n",
"\n",
"4 | \n",
"55.882 | \n",
"4897 | \n",
"357 | \n",
"2 | \n",
"68 | \n",
"16 | \n",
"1 | \n",
"0 | \n",
" ...SOLUTION.PDFAnswer To This Question Is Available To Download
Submit New Assignment
Please select references for your assignment
Please select no of pages for your assignment
Please select level for your assignment
x
I am Online - Talk to me!
Please fill out the form below to start chatting with the next available agent.
Mehmet Mert
3