Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
141 lines (127 loc) · 5.12 KB
/
Copy pathapp.py
File metadata and controls
141 lines (127 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
Algorithm Arena — Main Entrypoint
Uses modern st.navigation and st.Page to coordinate 7 pages:
- Home
- Round 1: Regression
- Round 2: Classification
- Round 3: Clustering
- Round 4: Images
- Round 5: Reinforcement
- Cheat Sheet
"""
import streamlit as st
from core import ui
from rounds import (
cheatsheet,
r1_regression,
r2_classification,
r3_clustering,
r4_images,
r5_reinforcement,
)
def render_home() -> None:
"""Render the Algorithm Arena Home page."""
ui.page_header(
title="Algorithm Arena",
subtitle="An educational laboratory exploring model suitability, geometric constraints, and inductive biases.",
)
ui.section("About The Project")
st.markdown(
"""
<p>
Algorithm Arena is an educational tool designed to demonstrate which machine learning
algorithm fits which type of problem and why. Rather than treating models as opaque black-box
systems, each round pairs distinct mathematical architectures on identical datasets to expose
their inductive biases. By systematically varying dataset geometry, sample density, and noise
variance, you can observe firsthand where linear assumptions break down and where non-linear
models excel. The arena emphasizes empirical trade-offs between decision boundary flexibility,
sample efficiency, computational latency, and interpretability. Use the sidebar navigation to
explore five dedicated rounds spanning regression, classification, clustering, spatial image
recognition, and reinforcement learning.
</p>
""",
unsafe_allow_html=True,
)
ui.section("The Five Pedagogical Rounds")
st.markdown(
"""
<table class="arena-table">
<thead>
<tr>
<th style="width: 15%;">Round</th>
<th style="width: 25%;">Problem Type</th>
<th style="width: 35%;">Key Archetypes & Manifolds</th>
<th style="width: 25%;">Contenders</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Round 1</strong></td>
<td>Regression</td>
<td>Linear trends, sine oscillations, noisy continuous response surfaces</td>
<td>OLS, Ridge, Polynomial, Random Forest, MLP</td>
</tr>
<tr>
<td><strong>Round 2</strong></td>
<td>Classification</td>
<td>Interleaved moons, concentric circles, multi-class Gaussian blobs</td>
<td>Logistic Regression, Decision Trees, Kernel SVM, MLP</td>
</tr>
<tr>
<td><strong>Round 3</strong></td>
<td>Clustering</td>
<td>Arbitrary densities, intertwined shapes, anisotropic clusters</td>
<td>K-Means, DBSCAN, Agglomerative, GMM</td>
</tr>
<tr>
<td><strong>Round 4</strong></td>
<td>Image Classification</td>
<td>8x8 optical handwritten digit grids, translation variance</td>
<td>Linear Classifiers, Random Forests, PyTorch MLP, CNN</td>
</tr>
<tr>
<td><strong>Round 5</strong></td>
<td>Reinforcement Learning</td>
<td>Sequential gridworld environments with delayed sparse rewards</td>
<td>Tabular Q-Learning, SARSA, Deep Q-Networks</td>
</tr>
</tbody>
</table>
""",
unsafe_allow_html=True,
)
ui.why_box(
"No single algorithm dominates all problem domains. The No Free Lunch theorem establishes "
"that every learner's success stems directly from how well its mathematical inductive bias aligns "
"with the true underlying data-generating geometry."
)
# Configure Streamlit page shell
st.set_page_config(
page_title="Algorithm Arena",
layout="wide",
initial_sidebar_state="expanded",
)
# Inject lab notebook styles
ui.load_css()
# Define navigation pages with explicit unique url_path values
home_page = st.Page(render_home, title="Home", url_path="", default=True)
r1_page = st.Page(r1_regression.render, title="Round 1: Regression", url_path="round-1-regression")
r2_page = st.Page(r2_classification.render, title="Round 2: Classification", url_path="round-2-classification")
r3_page = st.Page(r3_clustering.render, title="Round 3: Clustering", url_path="round-3-clustering")
r4_page = st.Page(r4_images.render, title="Round 4: Images", url_path="round-4-images")
r5_page = st.Page(r5_reinforcement.render, title="Round 5: Reinforcement", url_path="round-5-reinforcement")
cheatsheet_page = st.Page(cheatsheet.render, title="Cheat Sheet", url_path="cheat-sheet")
# Coordinate 7-page navigation
navigation = st.navigation(
[
home_page,
r1_page,
r2_page,
r3_page,
r4_page,
r5_page,
cheatsheet_page,
]
)
# Run navigation
navigation.run()