You are on page 1of 43
ans, 1028 0m Creat Sear Project yn = Colaboratory > Import required libraries fngort nunpy 35 np ingort pandes 95 P@ warnings. terwarnings(Sgnore") = placend_cou(*erain cov") ones) e Xo Customer 30 Month Hane Age SS_OCcupation Anal Income Monthly poor © 602 CUS ondK0 January gh 20 “Oa: Selaat—s01te12 2 1 oxteos cUS.O«Ho Febuary 4ygABS° 23 on. Seletst atta — Meashes 0265 2 oan cUS.onaK0 waren AB .so0 “Ene Suotat——sent4.12 3 oxis05 cUS.ox40 pnt A893 “oa. tomate easton oan Aaron 9g "2h — ‘Wassnon 0265 . ~ check if we have duplicated rows oF. duplicates(). sum) 00080, 25) + ID, Customer 1D , Name, SSN —» they will not affect on credit score go we can crop them ef droa("10, "Custom 0 SON, "Type_of Loan’, axtsed, Saplacesteue) rdex(Usonth', “Age, “Occupation, “anneal Encone', “onthiy_Iokond sary’, Credit_utilization Ratio’, ‘Credit History_Age', ‘anourt_invested monthly", "Payment Behaviour’, ‘Monthly Balance’ , reattctcore' Te types cBject) ~ Alternative to info) et colus_info (64) colurns=(] Intps:olab research google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWiorniMode=ttue 9 811723, 1028 PM Creat Score Project pyn~ Colaboratory colunns.appene(coin) types. append éf[ cote] dtypes) untaue.append( foie] -unique()) untae appera(2f| col -runsque()) hulls. append(er{coin)-1s0a()-54n0)) return pd.bataFrane(("Columns' olunns » cotuns_snfotse) ° Month ojo W889 etry, Mere Ag May. 1 an eos 8-90.78, 28, 28 4 5.21,3 2 et (Senta ___ tear " Eraew Ente. 3 ‘must Income obec, <7 MOET 4 Ment anand Salary oats eae was39999928, an Ss tnhans Satay 3007 s86068888800, 1 Nm Bank Accounts 1.2.1,7.4.08.5,6.9.10, 144 . Num_credt Cardigan 19855, 1286, 1.7.6, 1028468, 8 ema 136 7 Ines Rate iy 6+ 8+4,5, 8910, 15,7, 12, 20,1 “ a3 Nemo toan objet M13, 987, 100,0,0,2.9, 27 . cm _sttoan bi By 9 day fom, sate nips 1-1 8.6,8,7519,90,0,4.9. 1,12 10 Num ot Detayes Payment objoct 7POPA: BB 11.81 0.8.5.8.9 41 crangas.creat mt object 127. ~ 827,827, 542,742,042 12 Numcrodtinguies toarst _49,20,39,ran,50,90,80.70. 8 Creat object (L.Good, standard, Baa) 4 Outstanding Debt object (908-98, 698.02, 1808.07, 692.46, ~ outliers function with (IQR_stander deviation) et check_outliers (coin, df) agtade[ cola) -quantile(0.25) apnde[ cole -quantile(®. 75) outliers] for 1 sn eange(len(ee)) value = #f-100{3,coln] unique 780 oe n 4004 a) Intps:olab research google. com/érive/th2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWiorniMode=ttue 283 8117123, 1028 PM Creat Score Project pyn~ Colaboratory 4 value > upper_bound or value < Tower bound ‘outliers. append(value) return outliers et handle_outLiers(colmdf) aisd¢{ cele -cvantiie(s.25) (sna¢tecoln]-cuantile(s.75) fora’ = ower, boundeg-1.5¢4q¢ upper boundegdea Séar olen = () for 1 an range(ten(s#)): 4¢ 6f.loct4scoln] > vpper_poura af. locLigcoln] » upper pound ‘if af-loc{iyeoin] < Loser_pound aFloeL,coln] = louer_bound > 1-Month eF{ monn” J-umiqued) array py srebruary", “Mareh’, “Apes, May’, une’, “Daly's "august'), typeronject) plt-atieks(fontstzenns, rotations vertical") Sns.histpiet(ae, weimontn’, huge month’) plt-stont) count eF{ momen] = d€{ Month’ )-napC( January": "February "arch! :3, "sped" 24, May" :5, "une :6, July" e#( Mone’ J-unique() arraytl2, 2, 3, 8, 5) 6 7, 8], etypensnesey + 2-Age ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue aa 811723, 1028 PM Creat Score Project pyn~ Colaboratory FL "age" J-untquet) array (23, 0° 28s cosy “M808_', "2263", "1382"), typerebject) ef{cAge’ | = del ‘age’. steeeplace('=",") ef( sage!) = def Age]. stesreplace('_',"") ef{cage'] = d¢{ Age" astype int) eFC Age" J -uniqued) array(l 23, 500,28, --., eae, 2263, 1342)) ef( cage" )-tsna()-sun0) sns.kaepiot(ael Age") ple-stont) 005 0.003 Density 002 2.000 1 foe check euttans( "Age" ef) (see, 7388, ie, 33," 3085, an, 00," 3368, ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 493 8117123, 1028 PM 2935, 2538, handie_outliens(‘Age" 6) check outers ("Age") 0 ple-flgure(Figss20-(35, 79) snsihlatplotGe'age” "data =df, kaestrue) ple-title("age distesbution") ple stow) + 3- Occupation f{ occupation]. value_counts() npe:feolab research google.comidrive/1h2E_Rxe7SmgocBGCBoPDI73428d0WF CWHorntMod Creat Score Project pyn~ Colaboratory 811723, 1028 PM Creat Score Project pyn~ Colaboratory prenitect Engineer Meola. Manager besten Nave! Occupation, etyper inten ef{-Deeupation’| <4F( "occupation" ).reptace( Freetarcer") ef{ occupation” J-uniquet) array(C'Sctentist', ‘reeLancer', "Teacher's "Engineer", "Entrepreneur" “Boveloper") “Loayer"y "Radia, panager”, "boetor", "Journalsa®", anager", ‘Accouneant*, "Musiesan", "wechonie’, “hrster', ‘arenstect"], dlypecobseet) ple Figure(figssze = (22,5)) Ss barplot (xe Occupation ple-stont) “Age! date =dF,huee'Credit Score!) e#{ Occupation” |.nap(C"ScLentsst’:8, “Engineers! :2,“Teacher":3, entrepreneur”:6, Developer 5, "Lawyer" :6, edi, Nanager":7,"octor':6,‘Journalest':9, Manager 18, ‘countant':12,Wechanic":12, writer" :13,"Arehitect’24}) Hane! Occupation, Length: 106600, etyper stoatee {F{ occupation] .value_caunts() tower e575 prenitece 6358 Engineer 388 ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 643 811723, 1028 PM ochanse Developer Entrepreneur Sovrnadist besser None! occupa can os on as on, atyper Intea Creat Score Project pyn~ Colaboratory 18 dF = pd. get dummies df colunnss{ Occupation"), rop_Firstetrue) Fant) ‘eiass "pandas Rangeindex: 260000 entrtes, 8 ta 99999 Date columns (total 25 colin): tie 106860 ron-nu 2 Oeexpation 100000 norenat 3 dnnval-Encone 180098 non-null 4 Nontnty tovang salary 84998 noneauld 5 Nmaank-accouree 396090 non-ndlL 7 innerest tate 199090 ron-no 9 Delay fron_due-date 100000 hon-null a 160060 non-null 2 58035 nonenul2 E2 Creait tbe 180080 non-nL 35 Crecit_Ueilsantion Ratio 188088 non-null 36 Credit Wistory.age” 30870 noneaula 27 Poynani_ot Ritcpwount 100000" non-null 38 Total GH der-ponth 100000 non-null 29 anound_anvesteg.rontnly 95521 nonenild 20 Payneni_penavioa 16880 non-null 21 money salarce 98800 non-niLd types! #LoSteHts), intea(s), object (3) renory usage » 4- Annual_Income et{-annuat_tacone’ 3esas.22 Jevatue_counts() oats object object Sreee object sblect once sosect et object sosece ect sosect coyect ane: Anoual_Tneone, Length: 28940, dtype: sneoe ¢{-Annuat_tncone Jaf {Annus _treone”J-str-replace(*_",") {F{cannuat_tncone Hafan income’ Jeste-replace('=,"") etl ann e#{-Annuat_tacone’ arvay(( 19126, Jeuniguet) 33)) e¢{Aenudi_Iacone].astype( Float) Intps:olab research google. com/érive/th2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWiorniMode=ttue a3 811723, 1028 PM Creat Score Project pyn~ Colaboratory ss. kaeplot (ae Annu pltsstont) Income’) ae-6. 25) 20: Density 10 09 ne To 1 7 75 ‘anual income ae? ct {Annual_tnconeT.desersbe() mn Se 3 7sracteves ax 34358060107 Mane: Annusl-2ncone, type: Floated check euttars(‘Annuat_Iacone',6#) [20800027.0, a Senesiee, 2709655.) Essoesan, B96.) sige. 32, 19089302.0, sonsia'o, smnse.a, 1750.4, ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue aia 811723, 1028 PM Creat Score Project pyn~ Colaboratory 362550.32, o370582.8, 374304.04," sree. ee, randie_outlters(‘Annusl_Incone" 4") check out tars(‘Annuat_Incone', 44) 0 srs. keeplot af ‘Anmual_tacone']} ple-stont) aes. Density os ‘25000 s0000 75800 100000 125000 150000 ‘anual Income pit. figure(Figsize=(38, 6)) ple-atiexs(fontsize=10, sotatier fns.barplot(yedf{ Annual. Income], nedfl"Occupstion*]) ple-title("amual Incone 6y occupation”) ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 943 8117123, 1028 PM Creat Score Project pyn~ Colaboratory Texe(@.5, 2 ‘Annual Tacone 8y Occupation”) ‘nual Income By Occupation C | | i ooo > 5-Monthly_Inhand_Salary e#{ Monthiytahard_salary"J-unique() array((26.0023933, ran, 3037. 1929,98655657, 3359.63585553]) 5666667, ..., 3097.00833223, s+{ Montniy_tanard Salary” }-#412na(@F[ Monthly trhand Salary")-nean(), LaplacesTrue) 6#( Monty tanard salary" -15na().sun() sns.keeplot al Monthly_Inhand salary") ple-stowt) 1.00025 200020 Density 2.00010 “62509 S000 7500 10000 12800 15000, Monthly hand Salary cneck_ out Lers(nonthly_tnhand salary") nni87.22, saiar.22, 242, 783333333333, iaa2.st, ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 10143 811723, 1028 PM Creat Score Project pyn~ Colaboratory saa st, aasse6ess665, 1473333333332, (4593590331, feuna33333331, raaaseessse?, randle_outhiers( monthly tnhand salary") check out Lers( Monthly. tahand salary") u F{ Monthy Tahand_Sedary"J.deseribe() 5x sz.eenisr Sex Sasa 736887 7% _Sa7L s2s000 fox 3070 686250 Mane: Monthly Tahand Salary, etyper Aoatse ple-flgure(sigsize = (22,6), dpt = 400) Sns-barplot(x= ‘Occupation’ y="Monthly_Toand Salary’ data =6f,hue='Credtt_score') ple.stowt) ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue na 811723, 1028 PM Creat Score Project pyn~ Colaboratory ccises ‘pandas.core.frane.Datstrane'> iangeindex: 200000 entries, 8 £0 99909 Data columns (Rotal 23 colder): * colan Non-wult Count Dtype eF.antooy Stee 190090 non-null oat 2 Oeeupation 300000 poncnuil object 3 dames tncone 100800 non-nutl float 5 7 180090 non-null ineee 5 nterest sate 180090 non-null ineea & 106680 ron-nutl object 3 belay fron 190600 font Snes $0 Mimo? Delayed Paynent $2098 non-null. abject 33. Changed crease_timit 100600 non-null abject $3. Creditante 186990 non-null object SA outstanding pede so0eee non-null object SS Crecit,UsiTiastion atte. 199009 non-null flastee 36 Creait Mistorysage 90978 nonenul2. abject 37 Paynent_of-Rincnwount 100060 non-null abject 38 TotalLOH der-fonth” 190000 fon-nuil flout 39 anowné_anvested.rontly 95521 non-null. object 20 Payneni_tenavioar Sonoee nonenull object 21 noneniysalance 98800 non-null. object 22 Cresit Score ao02ee nonwnull object deypes: flosten(6), int64(5), obseee (2) ~ 6-Num_Bank Accounts F( Man Rank Accounts }.untque() ary 3, 889, 3688, 685, 857, 975, 121, 665, 1748, 1644, 797, . 8, Intps:eolab research google.com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 243 811723, 1028 PM a0, 186, ns, 3s, a, 2, ny, check euters( "Mun Bank Accounts! 4) faa, 488, 1688, 2022, 68, npe:folab research google.comidrive/1h2E_Rxe7SmgocBGCBoPDI73422d0WF CWHorntMod 820, 08, hese, 1503, 38, 233, om, use, a7, 233, sss, ss, Creat Score Project pyn~ Colaboratory see, ei, 1555, 1635, 186, 273, 1558, 298, 949 811723, 1028 PM Creat Score Project pyn~ Colaboratory sn, ne, andie_outlters(°Mun_bank Accounts, 4) check eutters("Min Bank, Accounts!) 0 pit. iure(Fhesize0032,6)) ple xtieks(fontsize=10, rotations vertical") fns-linoplot(data-dr, x="Occupation", "Nun Bank Accounts") plt-shont) rong tee TT rao thbty bi wd eo Vii: Ppl a iiadae ye : Joe sla Nam create are") «8 pit figuve(stgstze(20,6)) Sas.baroiotbee ef ‘ecupation’} . y= oF('hun sank pccounts'} dota = of huen‘Crestt score") ple-stont) 4149 811723, 1028 PM Creat Score Project pyn~ Colaboratory » 7-Num_Credit_Card A A a A a 6FC'Ma edit card" nique() 1385, 5, sos 955, 1438, 679), ctypertintss) arraytt 4 (mn, coedtt_cord”).cesertbe() 3 Name: Nun crecit Card, étype: Aloatee handie_outliers( ‘Mun creditcard’) chock outhars( Min creditcard u ple Figure(igsize = (22,59) Ens.barplot(xe Occupation’ jys"Nun Credit, Card’ data -df,huee‘Credst_ Score!) ple stent) + 8-Interest_Rate ef{cIneerest_Aate value countst) Hane: Interest_Aate, Length: 1758, atypes sntse npe:feolab research google.comidrive/1h2E_Rxe7SmgocBGCBoPDI73428d0WF CWHorntMod 6143 811723, 1028 PM Creat Score Project pyn~ Colaboratory it neeress_Rate'.ssn()-sun() check outltere( “Interest Rate’, 36) handle outliers (“Interest Rate’, 2®) fnterst-Interest Rate’, of) 0 sns.keeplot ee plevstont) 16149 npe:feolab research google.comidrive/1h2E_Rxe7SmgocBGCBoPDI73428d0WF CWHorntMod 811723, 1028 PM Creat Score Project pyn~ Colaboratory 204 03 Density 002 oor pit. figure(Figeize = (22,6), dpi = 490) occupstien ns barplot( pleston() interest fate’ ,dats =A, hues ‘Credit Scare") ef antec) “celass *pandas.core.frane.DataFrane’> Rangeindexs 200000 entries, 9 £0 99999 Oates (ata 2 cll) te 106000 non-null #loat6s 2 Oeeupation 190800 ron-nuil object 3 Annoal_rncone 190990 non-null fueat6e 4 forenigzinnane Satory 100000 nononail Flostat 5 400000 noncnsil object ° 180090 non-null Sneee 2° 52998 nonenull object n 186990 non-null object 2 38035 nonenul Floste Eh Gradina ao0eee nonenuil object 180099 non-null Floste 4997 noncnul object 480000 non-null object 37 Payeni_of Min 34 Tots Sh der-fonth” 108009 pon-nuil Floste 39 Anoundsnvestay ponthly 95521 nonenuld. abject 20 Payne_benavioan Soooee non-null abject B 98898 nonenuli object 22 Crecit, Score 180690 non-null obsect types! F1osten(7), int6aCe), object (22) ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue amiss 811723, 1028 PM Creat Score Project pyn~ Colaboratory + 9-Num_of_Loan ee éLoan*]-anieue() array( C4", °2, 3%, 967", "100", a smi", "908", 89", "1259","*527","*3241', 5198 anes, sggae", 12257", 437"," 357," "368" 251", "365", "291", ‘1487", "742", ‘oBs", “iae', "462", 033", "3879", 12487", "15 574°, °527_', "242", "ais", ‘a69", “958°, "54", "1265", "656", | 927", "653", “662°, "S29", "635", "2027", "897", "2039", "227", sea", ‘907, "657", ‘56°, "a8", San", ‘won', “58', ‘2i6", '30', 966'], atypecobject} ert mn et mn eFC me 11-Delay_from_due_date sf {-Delay_fron_due_date"J-uniquet) array 3, <2 Sse 8 7s 13,18, 8 M9) Bs aD, 27, 38, 2, 2, 26, a7, 15, 23, 22, 23, 18, 18, 52, 53, 54, 62, 67, 36, 4 35, 37, 6), ayo + Wermust conver the negative number to zero s((4t{"Delay fron due ate") ¢0] = @ e¢{-Detay_from_due_date*J-uniquet) arraytl 3, 723,18, 4 38,31, 34, 27, es, 33, 32, 38, 48, 63, 40, 37; 66), dtypenines sns.barplot(xedf{'Num fark Accounts") , y =df{'Delay_fron_due date’) , cata =64) ple-stont) Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 20149 811723, 1028 PM Creat Score Project pyn~ Colaboratory 50 ge 5 ioe creck eutters(-Delay fron due. ¢ Is, . 68, . handie_outiters(-oelay fron ove cate’) check euters(‘Delay fron due date’) u ple-tigure(igsize = (22,5)) Ens baeplot (ee occupation’, ple-stow0) Delay_fron due date’ data ~éf buen" credit_score") Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 24g 811723, 1028 PM 4 id Creat Score Project pyn~ Colaboratory A > 12-Num_of_Delayed_Payment fT Meno selayed_paynent array C75 8, “8, ane “8s Yoantauet) Bade Si Tao aa, saan, 28, Ta a23", 228 20", 3585", Py ves", 5253", 12368 p19") 392", 2 gone", sen", 3388 749", "1166", "2636" 2 282 3978") 1 ey nese! asa, 11337" ny 28", sao, ans, at, sae, 5,27", ios’, "2689", 3858", "642", "3850", ley tain, "793 “aaa! tenn “aan, 12828") nanny 808 5 "1996", Tai 2528") 2488", 4266", 12243") ea, $30", 1502", f vpeae", sen, "3661", "1208", Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 2a 811723, 1028 PM Creat Score Project pyn~ Colaboratory ett mn. un_of Delayed Payment T-str-replace(’ ett no ano eayed Payment] str-replace(*="s Ft "Mnf layed Paynent"] = df['Nun_of Delayed Payment] astype( float) > > chock euters(hin_of_ elayed Payment Af) (5318.8, rs handie_outLers(‘Nun_of Delayed. Payment df) creck utLLere(‘Mun_of Delayed Payment! df) 0 e4( mn, of eayedPayment®}-t5ra().sun() Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 249 8117123, 1028 PM Creat Score Project pyn~ Colaboratory {#{ Meno layed Payment" ]-#£320a(6F{"Nu_of Delayed Paynent"]-nean(), inplaceatrue) s(n, etayed Payment J-Asna()-sun() lt. Figure( tigsize=(28,6)) Sns.barplotOxeef{ Num Sank Accounts") , y =df[ Nun of Delayes_Payment®} , date ~2#) plecxticss(fontsize> 15 , rotation= "vertical’) ple-stowt) ef 30400) Rangeindex: 200000 entries, 0 £0 99599 Date columns (total 23 coluers): * colan Non-Wull count otype @ sonen o0oe9 noncnull Sree 2 oage 1300009 honenuil Floste 2 Occupation 100080 hon-null object 4 Wonthiy_innand Salary 180888 non-null floated © Muncneaie-cara ono non-null floatse & tmot-taan 180090 non-null ine32 5 Delay from due date 188600 non-nuil ince 19 non_o7_pelayet ent 100088 ronanull Floatst Ei changed crediectinit 100000 ponenull object 2 Muneredit theatres 95089 nonenult fuoat58 22 Creditante 300000 non-null object EA outstanding oexe {ono non-null object 36 Greit-History-Age 92038 non-null. abject S7 Payrentof-Rencpwount 160660 non-null abject 38 Tots]_pW_per-nonth” 169989 non-null float 38 dnound invested ponthly S5s48 nonenull. abject 28. Payneni_senavioar oooee non-null object 2 soneniyoalance Sasa non-null abject 22 Crecit Score ‘00080 onenull object types: flostes(s), int32(1), inteaCe), sdject(a8) renory usage: 17.24 68 + 13-Changed_Credit_Limit Intps:olab research google. com/érive/th2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWiorniMode=ttue 2489 811723, 1028 PM Creat Score Project pyn~ Colaboratory cf(changee_ greets Lanse" J-unsque() array({'22.27", 0) “ty sony ‘3P.seoaggeng908900", 25.26", °21.37"), drypa-obect) FL "changes credit Linit"} = df[ "Changed ceedit Limit’ ].ste.reptace(”_', 8") eF{ changed credit_Lintt"} = de{changed_creait_Linit’J.str.replace(*=","") e4{changee credit Linit* Jef ‘Charged Ceedit_Linit']astype(#leat) er{ Change! creatt_Linit"]= off Changed. crecit_Linit"]-replace('8"np.nan) FT changee_crectt_Linit]> off Changed. crecit_Lintt”J-replace(np.nan,dfl "Changed credit Lanse" .nean()) check outliers( changed. cresit_Linte” df) (29.52, a ao.32 aes, aos, sxe, handie_outliens(changed_cresit_Linit' neck outers (Changs u creatt_tinit’ 46) Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 2549 811723, 1028 PM Creat Score Project pyn~ Colaboratory sns.kaeplot(ael ‘Changed coe ple stent) 208 005, ensty oor osm 2 8 CGranged creat Limi > 15-Num_Credit_Inquiries Mo, edt, touir te" unique) aeroy(l 8p Bay voey BBM BIBL, THD fC Ma. enedtt_tnquirses”]-f5na()-#5n0) Sf{'Man, credit Inquiries" ].Fi1Ina(4fC" May Credit_Inquiries'J.median() , inplace =true) ef{ Men, coeute_trquteses”}.£5na()-sun() check outiers(‘Min Credit, toquiries" , 46) [r950.8, Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 8117123, 1028 PM Creat Score Project pyn~ Colaboratory andie_eutliers(-Mun_Credit_Inquiries® , df) check euters(‘Min_Creatttoquirtes” 6) 0 lt. figure(lasize = (34,6) Sna_barplot(ee'Oeeupation”,ye"Mun Credit Inquiries’ dats =f) ple-atieas(fontsize =i2 , rotation «'vercical') pltcatont) ef ante ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue ang 811723, 1028 PM 17- Outstanding Debt ertrout Sanding oebt*J-unteue() array( 809.98", 0, 605.08°5 soon 95727 dtypesobect) 2572.7", *902.38'1, sf{‘outstanding oebt*) «= df ‘cutstanding Oe s¢{-outstanding Debt") = af[ ‘outstanding Oe ef{ ‘outstanding Debt’ = df ‘Outstanding pebt strsreplacel Str-replacel “astypet float) check outlers(‘04t Standing 90bt*,6#) [uor.62, z Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 2oi49 811723, 1028 PM Creat Score Project pyn~ Colaboratory handie_eutlters(-ovtstanding bebe) cneck_eutters(-outstanding oebt' a) 0 ovtstancing pent’). tsna()-sun() so s¢{-ovestanding Oost”) F1tna(4f[ ‘Outstanding bebe ]netan(), Srplace=tre) ef{-outstanding oebt*.tsna()-sun() pit. figure(igeize = (22,6), dpi = 490) fns-barplot(xe"Occupation”y="Outstanding Debt data adf,nuee"Credit_ score") ple-stont) + 18-Credit_Utilization_Ratio cf( credit vsstszntion aatio' J-unique() array((26.e2261962, 0. + 2B.c0035202, ..., 41.25852226, 53,63820798, 3¢.29246285)) sns.kgeplot(ee of{ Creat Utilization patio") , data = ef) ple-ston() Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 304 811723, 1028 PM l 205, Creat Score Project pyn~ Colaboratory {Lterst Credit utstization Ratio", 46) check eutens( “Credit vtinization Ratio", of) c 1 pit. Figure(Figsize = (22,6) ple atiexs(fontsize = sns.barplot(e = €fL "age pltston() ‘rotation = ‘vertical’ ) Py = af{ "Create UetTization Aatiet) , data =a) Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue a4 8117123, 1028 PM Creat Score Project pyn~ Colaboratory > 19- Credit History Age eF{ "credit jstory_pge”)untave() arvoy'22 136 a8 nh 2 ne a on 38 35 25 a8 5 Years ane § Horehe,| ana ara Sra sna ra Sra 1 months, 9 Monens"; “26 Years and 18 Months, faimonths!, “sm Years ane 1 Yonthe', 4 Monens", "27 Years G Mons"; “27 Years WV montns' "38 2 Months", "32 Years 17 Months", "24 Years Sra 3 Honene Sed Honens” ‘and 2 Yonehe Sand 3 Honens” Sed 8 Honens” {aitonths!, "35 Years ane 8 Months, 4 Honene"; "25 Years and $ Rorshe’ 8 Monts", "25 Years and 9 North Srsontns’ "29 years Months! "19 Years 6 Months", "25 Years ‘and 2 Honene nd Honsne ard 7 Honene "22 Years and 3 Wonths', {6 Months! "22 Years and 7 Months", many 40 Months, "25 Years and 12 fonths", 5 Months', "® Years and 11 Honths", ‘9 Years and @ Months", "9 Years and 2 Months", Somonths!, Years and 3 honths" 8 Years and § Honths’, 10 wonths!, “36 Years and 11 Months", 2 Months', "29 Years and 2 Honths"s Hontne"; "29 Years and # Rorsne” Years and 7 tortie”, Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 24a 811723, 1028 PM Creat Score Project pyn~ Colaboratory ef{ Create Mistory age! )-s50a()-sua) c(t creditistory_age").f:TInalatT"cneeitsistory Age! Tonode(}, inplace =True) tC" Credit Mistory Age" )-$ena() stn) ef{ Credit Mistory year" J,df{Creait Mistory_nonth') sdf "Credit Mistory.Age"].ate split (‘and ef droa( Credit History eas ot Inptace True) ef{-credtt story yea ef { credit story_nor [credit story year’ str.replace( "Years" "*) GFL Creat pistory_noneh"].stesneplace( Marts") + 20- Payment_of_Min_Amount fC Paynent_of in_Anount®J-unigue() array('Me", 0, “MH , Yes"], atypenodject) ef {-Paynent_of_Min_tnount”J-value_counts() Mane: Payment of Min Ancunt, atype: intea Paynent_o¢_Min_Anount®].1sn2()-sum() e#{Paynent_of_Min_nnount] = df[Paynent_of hin_pnount)Rap( No" :@, NH :1,"¥e5":2}) ¢T Paynent_of_tin_pnount”]-f412na(4¢T'Paynent_of_Min_anount"T.nedtan(), AnplacenTrve) 4 { Paynent_of-tin_tnountJ-A5n30).sun0) > 21-Total_EMI_per_month #("Total_oMt_per_nonth*)-unique() Slaeaooooneseg)) "7 sns.keeplot(ee of Total, ple-stont) rpenvonth') , data = 46) Intps:olab research google. com/érive/th2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWiorniMode=ttue 34 811723, 1028 PM Creat Score Project pyn~ Colaboratory 0.0008 Density 0.0001 0000 ~—~—0000~—~«wOBD—~—«ROOD check euthLers(-Total OW per_nonth” , 6f) 23, ssanesan07, Savas.e, se54.0, iass2.8, det oisi77<048732, Sedloasi77eoner32, 30752.8, 514,0657978723467, s7a.ossa7e7a3a67, 485. 75643098783753, ‘504.6, Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 344 811723, 1028 PM Creat Score Project pyn~ Colaboratory handie_outLiers(‘Totel_f90_per_nonth', 6) check eutLers(-Total_ OW per_nonth df) 0 It. Figuro(Figsize » (22,6), dpi = 499) fSna_banplot(ee"Geeupstion”y="Total per sonth' dats =f hues"Cnedit score’) plt-shont) + 22- Amount_invested_monthly ef {Anount_tnvested_nonthly"J-unsaue() array({80.42529543000253", 0, “Bi.699521266688", «.., ‘aaleaearraaneaasi", “Ssa.erasaaasvoxeen', “i6?.aeaesseressa"], atypasobject) F{"Anount_invested_nonthay'J-isna() sun) st {cAnount_tnvested_nonthly'J> of[‘Anount_snvested_ponthly”]ostr-replace(’_ fff Anount_investeg_nonthy"] ~ af{"Anoone_tnvested rontniy]-astype( ist) ef {Anount_{nvested.nonthly'J.f31Ina( of[ Amount invested northly'J.nedian() , Snplace =Trus) ef {Anount_tavested_nonthly"J-Ssna().sur() sns-tineplot (ee eff Mn. pltsstont) Accounts" , y= dfl"Atount invested senthly'] , sates d¢) 3649 811723, 1028 PM Creat Score Project pyn~ Colaboratory 2000 ¥ 2000 sted, month check eutiters(‘Anount_{avested_sonthiy” , #f) (200000, n B75. 2600399022, 30000.0, fae. a26n16s051837, 0000-8, ° fua_ a7 7406805, 76, 2242023208, 555, 7438852657853, ‘770. 6964130785489, 20000.8, 623.4097218985353, 74, 7iassaa64sa15, a5. 4275309002364, 1670,5775060877238, 30000.8,, andie_cutiens(‘Anount invested santhly’ , ¢f) check eutiers(“Anount_Lavested_sonthiy’ , of) 0 Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 3649 8117123, 1028 PM Creat Score Project pyn~ Colaboratory sns.barplot(xe of['Mumtank Accounts”), y © df[‘Anount_lovested monthly") , aatae ef) plt-stont) ¥ 200) ‘Amount snvested. month & 10123 85 67 8 5 0 1 um. Bank Accounts > 23- Payment_Behaviour e#(-Paynent_sehaviour® }.untque() array(CMigh_spent_Smatl_value payments’, @ Loy Spent jediun_value_paymets", Low_spent_snallvalue_paynents", ah serpin ele ponents “18, "of, Spent_Large value payments”, dtypecebject) #("Paynant_aehaviourtsna().sun() e#(-Paynant_sehaviour’} = 6f{ "Payment, enaviour’].ste.neplace('IS#%8", "Low spent_snall_value_paynents") 6#(-Paynant_sehaviour®}.untque() array({"Migh_spent_snatl_vatue payments", non, Low apentHediunavalue_paynente", “oe spent_Small value payments”, igh spent Medium, value payments", “Migh-spent_Large value payments", oy Spent_arge_value_paynents'], dtypenobject) e+{-Paynent_sehaviour’} = of{"Payment_Benaviour”J.aap((Migh spent Snail vatue paynents':@ , Low Spent_Large_value_paysents":2 , Low_spent_Nediun_value_paynents':2 , Loucspent_snal value payments" 3, igh spent-Pacsin_valve payments" 4, ‘gh spent_Large valve payments’ + 5)) #("Payent_tehavicur’.4412na(4F['Paynent_tehaviour* J nedian(),inplacesTrue) #{"Paynent_Aehaviour J Asna()-sun() f(-Paynent_sehavtour’}vave_countst) ntps:eolab research google. com/érive/th2E_Ruxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue ang 811723, 1028 PM Creat Score Project pyn~ Colaboratory oo n280 Nave: Paynent_Sehavioun, type: intst eF.antoo, Rargeindex: 200000 entries, 8 t0 99999 Data columns (total 28 colin): cola Non-wull count otype 8 sone 180990 non-null ane6a 2 deexpation 100888 ron-null object 4 wonenij_toand salary 100888 non-null #loat6s 5 Nam dank pecoures 4300000 noncnull Sree 6 tmereeie_cond 196090 non-null floats 7 Interest sate 100000 non-null ineae & Nnet-t20n oo0e non-null int32 9 Delay fron due < 30 Nano? belived 180099 non-null Float6t Si Changed credst_Limit 100000 non-null flout6e 2 Mumeredit-treviries 189080 non-null float6s Sh Credit tte 400000 noncnuil floatoe 24 outstanding oeot 160880 non-null floats 35 Paynenl_of Min-feount 100000 fon-null #loat6% 1B snowné_tnvested.ronthly 160088 fon-nuil float6t 39. Payreni_benavioar 4300000 noncnuil loatoe 22 vontnly salance 38808 non-null. object BE Creait,Seore 100680 non-null obJect 22 Crecityitstory year 9044 nen object Zi Cresithistory-ponch Sbeas non-nult abject types! fLosten(ad), ame32(2), Antsaca, object(s) menor usage: 17.9+ Wa + 25- Monthly Balance e¢{ money satance”] untque() arroy({"312.49408867945653', 0, 331, 2098528537912" «5 ‘stecangeaneya2e%e, aio, szo7ecas7eaa, 2736900638808), satyperobject) e*{ moneniy_satance"].value_counts() ‘Seasanansaasonnse Ta 3 Stosons2aiase a are.anorspisaare a 3 eraesssoaneon 2 Nave! Monthly-Salance, Length: 98232, ctype: inte e¢{-monenty satorce’J= a¢["Monthiy Balance") .stesreplace(’_*, ) ser{°montnly_satarce’J= ae{"Monthiy-Galance"].astype(sioat) ¢{ Monenysatance’)1sna()-sun() pear redian = ef{'Ronchly_ Balance’) .nedtan() AT monthly, salance'].filina(nedsan , inplace ~True) 4 (-nontnly_ Balance" ]-isna()-5in0) Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 3e49 811723, 1028 PM check out bere “honth [1ee3. 2359778660602, handie_outlters(‘hanthty_satance check utters (Monthly, satance 0 + 26- Credit History year eft credit story year array(('22 *, aan, urique() “0 a i") Creat Score Project pyn~ Colaboratory Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 3049 811723, 1028 PM Creat Score Project pyn~ Colaboratory yperobect) ef{ "credit jistory year" )ts04().sun0) e#( "credit Mtstory_yoar*).ftLdnatee[“Credst Mistory year") -median(), snplace-Trve) e#( credit Mistory year" )-1503().5un0) > 28- Credit History month FU "credit, istory sont euniqued) ary yma ST 88 192, ey 2, Stypecobseet) ef{ Credit Mistory_month”J-Sana()-s5n0) F{ "credit uistory_ month" }.FL1Ina(4F[ Credit Mistory_nonth*J.medsan(), SnplacesTeue) e#( "create Mtstory_mortn’}-450a()-5un() + 29- Credit_Score (target) e¢{"Creast_Score"].vaive_counts() Name: credit_seore, type: inte# ef("credtt_score') = oF{ Crecit_Score"}.nap({"Poor':8, "Standard :1, 'cooe':2)) e#{crestt_score")-tsna(). sun) ef("credtt_ Score"). #ilina(df{ ‘Cresit_ score" ].nedian(), inplace-True) ett crease. seo sra()-sun) ns. countpot (ofl Create ple-stont) Intps:eolab research google. com/érive/1h2E_Rxe7SmgocBGCBOPDI7S42sdOWF CWorniMode=ttue 40149 811723, 1028 PM 50000 40000 +g 30000 20000: Fant) Sats caluans (eatal 26 columns): one 10860 2 ie 190000 2 Oeeupation 10880 5 Nim aank-accouits press] 5 00000 te 10880 Eh outeaneing_oeoe 100088 SE Crecit-Utiliaation Ratio. 160008 Se Payrent_ot_hin-nwoore 100000 57 Total Gat jer-ponth 10000 29. Payneni_senavioar so0eee 2 Crecititistery year te009e 23. crecit“history-ronth | ten08e ron-nult ron-nik roncnut ron-nulL on-null ron-nuit ron-nk ronan monn monn ronan on-nul Diype sense Hosts abject sre ‘fostoe oatee foatee oats ‘oatoe Hoatee abject vject types: flostea(ae), incs2(2), InteACA), object@3) renory usage: 17.5 Wa g pl. get_dunntes(ef column: 6F = pd.et_dunntestor) erantoo, Rargerndex: 266000 entre, © to 99999 Data columns (total 85 colums): colan Non-N Sage 00000 5 wuncreeit_card 0000 7 Wamot_t3an 00008 5 Delay from due date 300000 9 tun. belay 300000 20 Gorged_credse_tinit 300000 Bi Mmeresit-trgviries 100000 5) outetaneing_onoe 100000 4 Crecit Utilization Ratio 300800 35 Payreniot_hinsanore 300000 36 Total Em per-nonth 300000 37 dnoune_Srvested.ponthly 300000 35 Payreni_senavioar 00000 39 montniy_oalance xwe8ee ‘occupation, rop_ rs iL count ron-nul ron-rull ron-nult on-nul ron-null ror-null rn-nulk ron-null ron-nuL ron-null ron-rull ron-nul Doyoe fasts foatot sre flsatet ‘foate foatet ‘eave ‘fastest fioatos oats Creat Score Project pyn~ Colaboratory Intps:eolab research google.com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue ana 811723, 1028 PM Creat Score Project pyn~ Colaboratory ‘Oceupation_Developer ‘00000 hon-rull ints Deevpation engineer 108000 foul vines Soo0ee oncnull wines Cresit_history.year=@ 108060 non-null vines Creait history_year=18 100000 non-null vines Creait history.year=1 108000 fon-ull vines Creait history year=12 108000 non-null uines Cresit historyayear=16 108080 fon-null uines Creait history_year=i8 108888 non-null vines Machine Learning ~ Random Forest Classifier X + ef.drop ‘Credit Score’ anise) values 1 df Credit Seore"]values rodel = fandonforestClassifier() ~~ ode) C(x erain,y train) pred ~ nodel-predict(x test) Sr eonantecnoc testy vestnaee) Vored noel presiet y_scorely_test,y_ored) ecall_score(y_test pred, averages’ cro") rezision scarey test.) pred, over #1 = #2_scorety_test,)_pred, average™"nacro") fen = confuston_patrix(y_ testy 9red) return pd.Sertest("Accuracy':2¢e, "Recall" srecall,Preciston'sprecision, Ft Score: pPA.bataFrane((‘Rondon Forest Classifier (est) “sevaluste pose] X test,y_test model), Random Forest Classitier (Train) evaluate pogel(Q_train,y.train node) Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 4249 811723, 1028 PM Creat Score Project pyn~ Colaboratory ~ KNN X + df.drop( ‘erosit_ Score’ aniset) values Y= df "Credit Score] values 2000.2) rom sklearn.preprocessing import Standardscaler scaler = standarescaier() Xutrain » scaler flt_transform(X$ ALgast = sealer. trangform(x test) redel2 = KNeighborsClassifier(n_neighborse5) rodel2.1t(% train y_train) Ypres = nodel2. predict (x test) evaluate, nodel(X testy test nodel2) evaluate_podel(X_train,y_train,aodel2)}) vow (rest) 10m (Train) ‘Accuracy 0883680 0.710150, Fi Score caasioe 0.658128 Intps:feolab rosearch google. com/érive/th2E_Rxe75mgocBGCBOPDI7S42sdOWF CWorniMode=ttue 404

You might also like