saherPervaiz commited on
Commit
94ce526
·
verified ·
1 Parent(s): 29c4365

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -22,6 +22,19 @@ if uploaded_file is not None:
22
 
23
  # Show the dataset
24
  st.write("Dataset:")
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  st.dataframe(df)
26
 
27
  # Model Training Section
 
22
 
23
  # Show the dataset
24
  st.write("Dataset:")
25
+ st.dataframe(df)
26
+
27
+ # Convert categorical (str) data to numerical
28
+ st.write("Converting Categorical Columns to Numerical Values:")
29
+ label_encoder = LabelEncoder()
30
+
31
+ for col in df.columns:
32
+ if df[col].dtype == 'object' or len(df[col].unique()) <= 10:
33
+ st.write(f"Encoding Column: **{col}**")
34
+ df[col] = label_encoder.fit_transform(df[col])
35
+
36
+ # Display the dataset after conversion
37
+ st.write("Dataset After Conversion:")
38
  st.dataframe(df)
39
 
40
  # Model Training Section