Mpavan45 commited on
Commit
cda081c
·
verified ·
1 Parent(s): 05efc03

Update pages/4_Model Creation and Evaluation.py

Browse files
pages/4_Model Creation and Evaluation.py CHANGED
@@ -12,14 +12,14 @@ import optuna
12
  st.markdown("<h1 style='text-align:center; color:purple;'>Model Creation and Evaluation</h1>", unsafe_allow_html=True)
13
 
14
  # Background Styling
15
- background_image_url = "https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/zK1vosRLYAQ4EFqG8JyEs.png"
16
  # Apply custom CSS for the background image and overlay
17
  st.markdown(
18
  f"""
19
  <style>
20
  .stApp {{
21
  background-image: url("{background_image_url}");
22
- background-size: 100% auto; /* Ensure the image width is 100% of the screen, and the height scales proportionally */
23
  background-repeat: repeat-y; /* Repeat only vertically */
24
  background-position: top center; /* Start repeating from the top center */
25
  background-attachment: fixed; /* Keeps the background fixed as you scroll */
@@ -45,7 +45,7 @@ st.markdown(
45
  }}
46
  /* Styling the markdown content */
47
  .stMarkdown {{
48
- color: white; /* White text to ensure visibility */
49
  font-size: 100px; /* Adjust font size for readability */
50
  }}
51
  </style>
@@ -140,13 +140,6 @@ study.optimize(objective, n_trials=200)
140
  """
141
  st.code(code_3, language='python')
142
 
143
- # Output for Optuna Optimization
144
- study = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler())
145
- study.optimize(objective, n_trials=200)
146
-
147
- st.write("Best Parameters found by Optuna:", study.best_params)
148
- st.write("All Trials Dataframe:")
149
- st.write(study.trials_dataframe())
150
 
151
  # Code and Output 4: Model Training with Best Parameters
152
  st.subheader("Step 4: Model Training with Best Parameters")
@@ -154,18 +147,21 @@ st.subheader("Step 4: Model Training with Best Parameters")
154
  # Code for Model Training
155
  code_4 = """
156
  # Model Training with Best Parameters
157
- solver = study.best_params.get('solver', 'lbfgs')
158
- penalty = study.best_params.get('penalty', 'l2')
159
- C = study.best_params.get('lambda', 1.0)
160
- model = LogisticRegression(C=C, solver=solver, penalty=penalty, max_iter=500)
 
 
 
 
 
161
  model.fit(x_train_std, y_train)
 
162
  """
163
  st.code(code_4, language='python')
164
 
165
  # Output for Model Training
166
- solver = study.best_params.get('solver', 'lbfgs')
167
- penalty = study.best_params.get('penalty', 'l2')
168
- C = study.best_params.get('lambda', 1.0)
169
  model = LogisticRegression(C=C, solver=solver, penalty=penalty, max_iter=500)
170
  model.fit(x_train_std, y_train)
171
 
 
12
  st.markdown("<h1 style='text-align:center; color:purple;'>Model Creation and Evaluation</h1>", unsafe_allow_html=True)
13
 
14
  # Background Styling
15
+ background_image_url = "https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/uuRffDOdqb_CQPlKm3_J5.jpeg"
16
  # Apply custom CSS for the background image and overlay
17
  st.markdown(
18
  f"""
19
  <style>
20
  .stApp {{
21
  background-image: url("{background_image_url}");
22
+ background-size: auto; /* Ensure the image width is 100% of the screen, and the height scales proportionally */
23
  background-repeat: repeat-y; /* Repeat only vertically */
24
  background-position: top center; /* Start repeating from the top center */
25
  background-attachment: fixed; /* Keeps the background fixed as you scroll */
 
45
  }}
46
  /* Styling the markdown content */
47
  .stMarkdown {{
48
+ color: black; /* White text to ensure visibility */
49
  font-size: 100px; /* Adjust font size for readability */
50
  }}
51
  </style>
 
140
  """
141
  st.code(code_3, language='python')
142
 
 
 
 
 
 
 
 
143
 
144
  # Code and Output 4: Model Training with Best Parameters
145
  st.subheader("Step 4: Model Training with Best Parameters")
 
147
  # Code for Model Training
148
  code_4 = """
149
  # Model Training with Best Parameters
150
+ # Use the hyperparameters obtained from Optuna
151
+ solver = 'newton-cg'
152
+ penalty = 'l2'
153
+ C = 999.8628541436512
154
+
155
+ # Initialize Logistic Regression model with the best hyperparameters
156
+ model = LogisticRegression(C=C, solver=solver, penalty=penalty, multi_class="multinomial", max_iter=500)
157
+
158
+ # Train the model
159
  model.fit(x_train_std, y_train)
160
+
161
  """
162
  st.code(code_4, language='python')
163
 
164
  # Output for Model Training
 
 
 
165
  model = LogisticRegression(C=C, solver=solver, penalty=penalty, max_iter=500)
166
  model.fit(x_train_std, y_train)
167