harish199 commited on
Commit
2accf89
1 Parent(s): c73aef0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -16,12 +16,9 @@ categorical_features = ["person_home_ownership", "loan_intent", "loan_grade", "c
16
  X = pd.get_dummies(X, categorical_features)
17
  X.columns
18
 
19
-
20
-
21
  from sklearn.model_selection import train_test_split
22
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2)
23
 
24
- X_train.head()
25
 
26
  from sklearn.preprocessing import StandardScaler
27
  scaler_normal = StandardScaler()
@@ -39,6 +36,10 @@ X_test = scaler(X_test, True)
39
  rf_model = RandomForestClassifier(max_depth = 5)
40
  rf_model.fit(X_train, y_train)
41
 
 
 
 
 
42
  features = {
43
  "person_home_ownership": ['MORTGAGE', 'OTHER','OWN', 'RENT',],
44
  "loan_intent": ['DEBTCONSOLIDATION', 'EDUCATION', 'HOMEIMPROVEMENT', 'MEDICAL', 'PERSONAL', 'VENTURE'],
@@ -53,15 +54,13 @@ def preprocess(model_input):
53
  model_input[f'{feature}_{option}'] = 1
54
  else:
55
  model_input[f'{feature}_{option}'] = 0
56
-
57
  model_input.drop([_ for _ in features], inplace = True, axis = 1)
58
  return model_input
59
 
60
-
61
 
62
- def credit_run(person_age, person_income, person_home_ownership,
63
- person_emp_length, loan_intent, loan_grade, loan_amnt,
64
- loan_int_rate, cb_person_default_on_file, cb_person_cred_hist_length):
65
  model_input = preprocess(
66
  pd.DataFrame( { 'person_age': person_age,
67
  'person_income': person_income,
@@ -76,7 +75,7 @@ def credit_run(person_age, person_income, person_home_ownership,
76
  }, index = [0]
77
  ))
78
  out = rf_model.predict(model_input)
79
- return "High risk of defaulting" if out[0] == 1 else "Low risk of defaulting"
80
 
81
  import gradio as gr
82
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
16
  X = pd.get_dummies(X, categorical_features)
17
  X.columns
18
 
 
 
19
  from sklearn.model_selection import train_test_split
20
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2)
21
 
 
22
 
23
  from sklearn.preprocessing import StandardScaler
24
  scaler_normal = StandardScaler()
 
36
  rf_model = RandomForestClassifier(max_depth = 5)
37
  rf_model.fit(X_train, y_train)
38
 
39
+ y_predict = rf_model.predict(X_test)
40
+ y_predict
41
+
42
+
43
  features = {
44
  "person_home_ownership": ['MORTGAGE', 'OTHER','OWN', 'RENT',],
45
  "loan_intent": ['DEBTCONSOLIDATION', 'EDUCATION', 'HOMEIMPROVEMENT', 'MEDICAL', 'PERSONAL', 'VENTURE'],
 
54
  model_input[f'{feature}_{option}'] = 1
55
  else:
56
  model_input[f'{feature}_{option}'] = 0
57
+
58
  model_input.drop([_ for _ in features], inplace = True, axis = 1)
59
  return model_input
60
 
 
61
 
62
+ def credit_run(person_age, person_emp_length,person_home_ownership,cb_person_default_on_file,loan_intent,loan_grade,person_income, loan_amnt,
63
+ loan_int_rate, cb_person_cred_hist_length):
 
64
  model_input = preprocess(
65
  pd.DataFrame( { 'person_age': person_age,
66
  'person_income': person_income,
 
75
  }, index = [0]
76
  ))
77
  out = rf_model.predict(model_input)
78
+ return "High risk of defaulting" if out[0] == 1 else "Low risk of defaulting"
79
 
80
  import gradio as gr
81
  with gr.Blocks(theme=gr.themes.Soft()) as demo: