mertkarabacak commited on
Commit
886f71b
1 Parent(s): 3ad22ac

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -141,8 +141,7 @@ unique_PRIMARYMETHODPAYMENT = ['Private/commercial insurance', 'Medicaid', 'Medi
141
  y1 = x1.pop('OUTCOME')
142
  categorical_columns1 = list(x1.select_dtypes('object').columns)
143
  le = sklearn.preprocessing.LabelEncoder()
144
- for col in categorical_columns1:
145
- x1[col] = le.fit_transform(x1[col].astype(str))
146
  d1 = dict.fromkeys(x1.select_dtypes(np.int64).columns, str)
147
  x1 = x1.astype(d1)
148
 
@@ -150,8 +149,7 @@ x1 = x1.astype(d1)
150
  y2 = x2.pop('OUTCOME')
151
  categorical_columns2 = list(x2.select_dtypes('object').columns)
152
  le = sklearn.preprocessing.LabelEncoder()
153
- for col in categorical_columns2:
154
- x2[col] = le.fit_transform(x2[col].astype(str))
155
  d2 = dict.fromkeys(x2.select_dtypes(np.int64).columns, str)
156
  x2 = x2.astype(d2)
157
 
@@ -159,8 +157,7 @@ x2 = x2.astype(d2)
159
  y3 = x3.pop('OUTCOME')
160
  categorical_columns3 = list(x3.select_dtypes('object').columns)
161
  le = sklearn.preprocessing.LabelEncoder()
162
- for col in categorical_columns3:
163
- x3[col] = le.fit_transform(x3[col].astype(str))
164
  d3 = dict.fromkeys(x3.select_dtypes(np.int64).columns, str)
165
  x3 = x3.astype(d3)
166
 
@@ -168,8 +165,7 @@ x3 = x3.astype(d3)
168
  y4 = x4.pop('OUTCOME')
169
  categorical_columns4 = list(x4.select_dtypes('object').columns)
170
  le = sklearn.preprocessing.LabelEncoder()
171
- for col in categorical_columns4:
172
- x4[col] = le.fit_transform(x4[col].astype(str))
173
  d4 = dict.fromkeys(x4.select_dtypes(np.int64).columns, str)
174
  x4 = x4.astype(d4)
175
 
@@ -177,8 +173,7 @@ x4 = x4.astype(d4)
177
  y5 = x5.pop('OUTCOME')
178
  categorical_columns5 = list(x5.select_dtypes('object').columns)
179
  le = sklearn.preprocessing.LabelEncoder()
180
- for col in categorical_columns5:
181
- x5[col] = le.fit_transform(x5[col].astype(str))
182
  d5 = dict.fromkeys(x5.select_dtypes(np.int64).columns, str)
183
  x5 = x5.astype(d5)
184
 
 
141
  y1 = x1.pop('OUTCOME')
142
  categorical_columns1 = list(x1.select_dtypes('object').columns)
143
  le = sklearn.preprocessing.LabelEncoder()
144
+ x1[categorical_columns1] = x1[categorical_columns1].apply(le.fit_transform)
 
145
  d1 = dict.fromkeys(x1.select_dtypes(np.int64).columns, str)
146
  x1 = x1.astype(d1)
147
 
 
149
  y2 = x2.pop('OUTCOME')
150
  categorical_columns2 = list(x2.select_dtypes('object').columns)
151
  le = sklearn.preprocessing.LabelEncoder()
152
+ x2[categorical_columns2] = x2[categorical_columns2].apply(le.fit_transform)
 
153
  d2 = dict.fromkeys(x2.select_dtypes(np.int64).columns, str)
154
  x2 = x2.astype(d2)
155
 
 
157
  y3 = x3.pop('OUTCOME')
158
  categorical_columns3 = list(x3.select_dtypes('object').columns)
159
  le = sklearn.preprocessing.LabelEncoder()
160
+ x3[categorical_columns3] = x3[categorical_columns3].apply(le.fit_transform)
 
161
  d3 = dict.fromkeys(x3.select_dtypes(np.int64).columns, str)
162
  x3 = x3.astype(d3)
163
 
 
165
  y4 = x4.pop('OUTCOME')
166
  categorical_columns4 = list(x4.select_dtypes('object').columns)
167
  le = sklearn.preprocessing.LabelEncoder()
168
+ x4[categorical_columns4] = x4[categorical_columns4].apply(le.fit_transform)
 
169
  d4 = dict.fromkeys(x4.select_dtypes(np.int64).columns, str)
170
  x4 = x4.astype(d4)
171
 
 
173
  y5 = x5.pop('OUTCOME')
174
  categorical_columns5 = list(x5.select_dtypes('object').columns)
175
  le = sklearn.preprocessing.LabelEncoder()
176
+ x5[categorical_columns5] = x5[categorical_columns5].apply(le.fit_transform)
 
177
  d5 = dict.fromkeys(x5.select_dtypes(np.int64).columns, str)
178
  x5 = x5.astype(d5)
179