WSYAM806 commited on
Commit
4c96e97
·
1 Parent(s): 87c4f47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -104,12 +104,12 @@ with App:
104
  input = pd.DataFrame(data, index=[0])
105
  st.subheader('User Input')
106
  st.write(input)
107
- label_pred = []
108
  if st.button('Cluster'):
109
  num_col = [' income_annum', ' loan_amount', ' loan_term', ' cibil_score', ' residential_assets_value', ' commercial_assets_value', ' luxury_assets_value', ' bank_asset_value']
110
  def_cluster = input.drop(columns=[col for col in input.columns if col not in num_col])
111
  def_pca = cluster.transform(def_cluster)
112
  labelz = k_3.predict(def_pca)
 
113
 
114
  if np.all(labelz == 0):
115
  st.write('Based on user input, the placement cluster: Moderate-Risk Customers')
@@ -117,16 +117,9 @@ with App:
117
  st.write('Based on user input, the placement cluster: Low-Risk Customers')
118
  elif np.all(labelz == 2):
119
  st.write('Based on user input, the placement cluster: High-Risk Customers')
120
-
121
- for label in labelz:
122
- label_pred.append(label)
123
-
124
- label_pred = pd.DataFrame(label_pred)
125
- input_pred = pd.concat([label_pred.reset_index(drop=True), input], axis=1)
126
- input_pred.rename(columns={0: "cluster"}, inplace=True)
127
-
128
  if st.button('predict'):
129
- prediction = model.predict(input_pred)
130
 
131
  if prediction == 0:
132
  prediction = ' Rejected'
 
104
  input = pd.DataFrame(data, index=[0])
105
  st.subheader('User Input')
106
  st.write(input)
 
107
  if st.button('Cluster'):
108
  num_col = [' income_annum', ' loan_amount', ' loan_term', ' cibil_score', ' residential_assets_value', ' commercial_assets_value', ' luxury_assets_value', ' bank_asset_value']
109
  def_cluster = input.drop(columns=[col for col in input.columns if col not in num_col])
110
  def_pca = cluster.transform(def_cluster)
111
  labelz = k_3.predict(def_pca)
112
+ input['cluster'] = labelz
113
 
114
  if np.all(labelz == 0):
115
  st.write('Based on user input, the placement cluster: Moderate-Risk Customers')
 
117
  st.write('Based on user input, the placement cluster: Low-Risk Customers')
118
  elif np.all(labelz == 2):
119
  st.write('Based on user input, the placement cluster: High-Risk Customers')
120
+
 
 
 
 
 
 
 
121
  if st.button('predict'):
122
+ prediction = model.predict(input)
123
 
124
  if prediction == 0:
125
  prediction = ' Rejected'