-
Notifications
You must be signed in to change notification settings - Fork 1
/
getRiskCol.py
46 lines (35 loc) · 1.31 KB
/
getRiskCol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import numpy as np
def getRiskCol(loanStatus, returnCoversionDict= False):
"""
Returns the three-way risk classfication:
yes: defaulting
no: reliable, e.g. current loan, fully paid, issued
maybe: in grace, late, etc.
(and possibly the conversion dictionary)
Required:
---------
* loanStatus: string array: status of the borrowers' loans.
Optional:
---------
* returnCoversionDict: bool: True if want the conversion dictionary/
Default: False
"""
great= ["Fully Paid",'Does not meet the credit policy. Status:Fully Paid']
unsure= ["In Grace Period",
"Late (16-30 days)", "Late (31-120 days)",
"Current", "Issued"]
bad= ["Default", "Charged Off", "Does not meet the credit policy. Status:Charged Off", ]
conversionDict= {}
for status in bad:
conversionDict[status]= 'Default'
for status in unsure:
conversionDict[status]= 'Maybe'
for status in great:
conversionDict[status]= 'NotDefault'
risk= loanStatus.copy()
for entry in np.unique(loanStatus):
risk[risk==entry]= conversionDict[entry]
if returnCoversionDict:
return risk, conversionDict
else:
return risk