Canstralian
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -110,10 +110,16 @@ if 'df' in locals():
|
|
110 |
df[features], df[target_col], test_size=test_size, random_state=42
|
111 |
)
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
st.subheader("Select and Train Model")
|
114 |
model_type = st.selectbox("Choose a model:", ["Logistic Regression", "Decision Tree", "Random Forest"])
|
115 |
if model_type == "Logistic Regression":
|
116 |
-
model = LogisticRegression()
|
117 |
elif model_type == "Decision Tree":
|
118 |
model = DecisionTreeClassifier()
|
119 |
else:
|
|
|
110 |
df[features], df[target_col], test_size=test_size, random_state=42
|
111 |
)
|
112 |
|
113 |
+
# Encode the target variable (if categorical) using LabelEncoder
|
114 |
+
if y_train.dtypes == 'object': # Check if the target column is categorical
|
115 |
+
le = LabelEncoder()
|
116 |
+
y_train = le.fit_transform(y_train)
|
117 |
+
y_test = le.transform(y_test)
|
118 |
+
|
119 |
st.subheader("Select and Train Model")
|
120 |
model_type = st.selectbox("Choose a model:", ["Logistic Regression", "Decision Tree", "Random Forest"])
|
121 |
if model_type == "Logistic Regression":
|
122 |
+
model = LogisticRegression(max_iter=200) # Increase max_iter if needed
|
123 |
elif model_type == "Decision Tree":
|
124 |
model = DecisionTreeClassifier()
|
125 |
else:
|