-
Notifications
You must be signed in to change notification settings - Fork 52
/
Score_HOME_EQUITY.txt
32 lines (23 loc) · 1.29 KB
/
Score_HOME_EQUITY.txt
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
## Copyright © 2022, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0
import pickle
import numpy as np
import pandas as pd
with open(settings.pickle_path + dm_pklname, 'rb') as f:
imputer = pickle.load(f)
ohe = pickle.load(f)
model = pickle.load(f)
def score_method(DELINQ, DEROG, JOB, NINQ, REASON, CLAGE, CLNO, DEBTINC, LOAN, MORTDUE, VALUE, YOJ):
"Output: P_BAD0, P_BAD1, I_BAD"
record = pd.DataFrame([[DELINQ, DEROG, JOB, NINQ, REASON, CLAGE, CLNO, DEBTINC, LOAN, MORTDUE, VALUE, YOJ]],\
columns=['DELINQ', 'DEROG', 'JOB', 'NINQ', 'REASON', 'CLAGE', 'CLNO', 'DEBTINC', 'LOAN', 'MORTDUE', 'VALUE', 'YOJ'])
dm_class_input = ["DELINQ", "DEROG", "JOB", "NINQ", "REASON"]
dm_interval_input = ["CLAGE", "CLNO", "DEBTINC", "LOAN", "MORTDUE", "VALUE", "YOJ"]
rec_intv = record[dm_interval_input]
rec_intv_imp = imputer.transform(rec_intv)
rec_class = record[dm_class_input].applymap(str)
rec_class_ohe = ohe.transform(rec_class).toarray()
rec = np.concatenate((rec_intv_imp, rec_class_ohe), axis=1)
rec_pred_prob = model.predict_proba(rec)
rec_pred = model.predict(rec)
return float(rec_pred_prob[0][0]), float(rec_pred_prob[0][1]), float(rec_pred[0])