-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
33 lines (26 loc) · 813 Bytes
/
run.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
import boto3
import pandas as pd
from credit_model import CreditScoringModel
#load history data
loans = pd.read_parquet("data/loan_table.parquet")
model = CreditScoringModel()
#train model using Redshift for zopcode and credit hisroty feature
if not model.is_model_trained():
model.train(loans)
#create data sample to prediction online(using DynamoDB for retriveing online feature)
loan_request = {
"zipcode": [76104],
"dob_ssn": ["19630621_4278"],
"person_age": [133],
"person_income": [59000],
"person_home_ownership": ["RENT"],
"person_emp_length": [123.0],
"loan_intent": ["PERSONAL"],
"loan_amnt": [35000],
"loan_int_rate": [16.02],
}
result = model.predict(loan_request)
if result == 0:
print("Loan approved!")
elif result == 1:
print("Loan rejected!")