Yashvj123 commited on
Commit
818ea9b
Β·
verified Β·
1 Parent(s): 4ee561a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +121 -22
app.py CHANGED
@@ -564,34 +564,133 @@ elif st.session_state.current_page == "Model Building":
564
 
565
  # Fianl Model
566
  elif st.session_state.current_page == "Final Model":
567
- st.markdown("<h1 class='title'>Final Model</h1>", unsafe_allow_html=True)
568
-
569
- st.markdown("<hr style='border:1px solid #ddd;'>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570
 
571
- st.markdown("""
572
- <h3>βœ… Best Model: Bagging Regressor (with Decision Tree)</h3>
573
- <ul>
574
- <li><b>Training Score:</b> 98.68%</li>
575
- <li><b>Test Score:</b> 95.04%</li>
576
- <li><b>Generalized Score:</b> 95.45%</li>
577
- </ul>
578
- """, unsafe_allow_html=True)
579
 
580
- st.markdown("<hr style='border:1px solid #ddd;'>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
581
 
582
- st.markdown("""
583
- <h3>βš™οΈ Final Hyperparameters</h3>
584
- <ul>
585
- <li><b>Base Model:</b> Decision Tree Regressor</li>
586
- <li><b>min_samples_leaf:</b> 2</li>
587
- <li><b>min_samples_split:</b> 3</li>
588
- <li><b>n_estimators:</b> 40</li>
589
- <li><b>max_samples:</b> 0.838404</li>
590
- </ul>
591
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
592
 
593
  if st.button("πŸ”™ Go Back to Model Report"):
594
  switch_page("Model Report")
 
595
 
596
  # Hands-on Model Page
597
  elif st.session_state.current_page == "Hands-on Model":
 
564
 
565
  # Fianl Model
566
  elif st.session_state.current_page == "Final Model":
567
+ # st.markdown("<h1 class='title'>Final Model</h1>", unsafe_allow_html=True)
568
+
569
+ # st.markdown("<hr style='border:1px solid #ddd;'>", unsafe_allow_html=True)
570
+
571
+ # st.markdown("""
572
+ # <h3>βœ… Best Model: Bagging Regressor (with Decision Tree)</h3>
573
+ # <ul>
574
+ # <li><b>Training Score:</b> 98.68%</li>
575
+ # <li><b>Test Score:</b> 95.04%</li>
576
+ # <li><b>Generalized Score:</b> 95.45%</li>
577
+ # </ul>
578
+ # """, unsafe_allow_html=True)
579
+
580
+ # st.markdown("<hr style='border:1px solid #ddd;'>", unsafe_allow_html=True)
581
+
582
+ # st.markdown("""
583
+ # <h3>βš™οΈ Final Hyperparameters</h3>
584
+ # <ul>
585
+ # <li><b>Base Model:</b> Decision Tree Regressor</li>
586
+ # <li><b>min_samples_leaf:</b> 2</li>
587
+ # <li><b>min_samples_split:</b> 3</li>
588
+ # <li><b>n_estimators:</b> 40</li>
589
+ # <li><b>max_samples:</b> 0.838404</li>
590
+ # </ul>
591
+ # """, unsafe_allow_html=True)
592
+
593
+
594
+ st.markdown(
595
+ """
596
+ <style>
597
+ .title {
598
+ text-align: center;
599
+ font-size: 36px;
600
+ font-weight: bold;
601
+ color: #1E3A8A;
602
+ }
603
+ .subtitle {
604
+ text-align: center;
605
+ font-size: 20px;
606
+ color: #475569;
607
+ margin-bottom: 20px;
608
+ }
609
+ .image-container {
610
+ display: flex;
611
+ justify-content: center;
612
+ }
613
+ .caption {
614
+ text-align: center;
615
+ font-size: 16px;
616
+ font-style: italic;
617
+ color: #6B7280;
618
+ }
619
+ .box {
620
+ background-color: #F8FAFC;
621
+ padding: 15px;
622
+ border-radius: 10px;
623
+ box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
624
+ margin-bottom: 20px;
625
+ }
626
+ </style>
627
+ """,
628
+ unsafe_allow_html=True,
629
+ )
630
 
631
+ # Title
632
+ st.markdown("<h1 class='title'>Final Model</h1>", unsafe_allow_html=True)
 
 
 
 
 
 
633
 
634
+ # Subtitle
635
+ st.markdown("<p class='subtitle'>Selecting the Best-Fit Model from Optuna Trials</p>", unsafe_allow_html=True)
636
+
637
+ # Explanation Box
638
+ st.markdown(
639
+ "<div class='box'>"
640
+ "<p>After experimenting with multiple trials using Optuna, we selected the best-fit model "
641
+ "by analyzing the training and test scores of different trials. "
642
+ "The following scatter plots provide insights into this selection process.</p>"
643
+ "</div>",
644
+ unsafe_allow_html=True,
645
+ )
646
 
647
+
648
+ st.markdown("<h3>Training vs Test Score (All Trials)</h3>", unsafe_allow_html=True)
649
+ st.markdown(
650
+ "<p class='subtitle'>This scatter plot visualizes the training and test scores of all trials. "
651
+ "The goal was to identify a model where both scores are closely aligned, ensuring minimal overfitting or underfitting.</p>",
652
+ unsafe_allow_html=True,
653
+ )
654
+ scatter_all = Image.open("images/bagging_trails.png")
655
+ st.image(scatter_all, caption="Scatter Plot of All Trials", use_column_width=True)
656
+
657
+
658
+ st.markdown("<h3>Training vs Test Score (First 50 Trials)</h3>", unsafe_allow_html=True)
659
+ st.markdown(
660
+ "<p class='subtitle'>By filtering the first 50 trials, we focused on models that demonstrated balanced performance. "
661
+ "The best-fit model was selected by ensuring that the training and test scores are close to each other.</p>",
662
+ unsafe_allow_html=True,
663
+ )
664
+ scatter_50 = Image.open("images/bagging_50trails.png")
665
+ st.image(scatter_50, caption="Scatter Plot of First 50 Trials", use_column_width=True)
666
+
667
+ # Final Model Summary
668
+ st.markdown("<h3>Selected Best-Fit Model</h3>", unsafe_allow_html=True)
669
+ st.markdown(
670
+ "<div class='box'>"
671
+ "<ul>"
672
+ "<li><b>Base Model:</b> DecisionTreeRegressor</li>"
673
+ "<li><b>Hyperparameters:</b>"
674
+ "<ul>"
675
+ "<li>min_samples_leaf = 2</li>"
676
+ "<li>min_samples_split = 3</li>"
677
+ "</ul></li>"
678
+ "<li><b>Ensemble Method:</b> BaggingRegressor</li>"
679
+ "<li><b>Bagging Hyperparameters:</b>"
680
+ "<ul>"
681
+ "<li>n_estimators = 40</li>"
682
+ "<li>max_samples = 0.838404</li>"
683
+ "</ul></li>"
684
+ "</ul>"
685
+ "<p>This model was selected as it demonstrated a balance between generalization and performance.</p>"
686
+ "</div>",
687
+ unsafe_allow_html=True,
688
+ )
689
+
690
 
691
  if st.button("πŸ”™ Go Back to Model Report"):
692
  switch_page("Model Report")
693
+
694
 
695
  # Hands-on Model Page
696
  elif st.session_state.current_page == "Hands-on Model":