Spaces:
Running
Running
Update app/main.py
Browse files- app/main.py +184 -28
app/main.py
CHANGED
@@ -2,6 +2,9 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import glob
|
4 |
import sys
|
|
|
|
|
|
|
5 |
|
6 |
# Add the parent directory to the Python path
|
7 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
@@ -114,7 +117,159 @@ def sidebar_navigation():
|
|
114 |
for week in range(1, 11):
|
115 |
if st.button(f"Week {week}", key=f"week_{week}"):
|
116 |
st.session_state.current_week = week
|
117 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
# Main content
|
120 |
def main():
|
@@ -125,33 +280,34 @@ def main():
|
|
125 |
return
|
126 |
|
127 |
# User is logged in, show course content
|
128 |
-
st.
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
|
156 |
if __name__ == "__main__":
|
157 |
load_css()
|
|
|
2 |
import os
|
3 |
import glob
|
4 |
import sys
|
5 |
+
import numpy as np
|
6 |
+
import plotly.graph_objects as go
|
7 |
+
from sklearn.linear_model import LinearRegression
|
8 |
|
9 |
# Add the parent directory to the Python path
|
10 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
117 |
for week in range(1, 11):
|
118 |
if st.button(f"Week {week}", key=f"week_{week}"):
|
119 |
st.session_state.current_week = week
|
120 |
+
st.rerun()
|
121 |
+
|
122 |
+
def show_week_content():
|
123 |
+
st.markdown("""
|
124 |
+
## Week 1: Research Topic Selection and Literature Review
|
125 |
+
|
126 |
+
This week, you'll learn how to:
|
127 |
+
- Select a suitable research topic
|
128 |
+
- Conduct a literature review
|
129 |
+
- Define your research objectives
|
130 |
+
- Create a research proposal
|
131 |
+
""")
|
132 |
+
|
133 |
+
# Topic Selection Section
|
134 |
+
st.header("1. Topic Selection")
|
135 |
+
st.markdown("""
|
136 |
+
### Guidelines for Selecting Your Research Topic:
|
137 |
+
- Choose a topic that interests you
|
138 |
+
- Ensure sufficient data availability
|
139 |
+
- Consider the scope and complexity
|
140 |
+
- Check for existing research gaps
|
141 |
+
""")
|
142 |
+
|
143 |
+
# Interactive Topic Selection
|
144 |
+
st.subheader("Topic Selection Form")
|
145 |
+
with st.form("topic_form"):
|
146 |
+
research_area = st.selectbox(
|
147 |
+
"Select your research area",
|
148 |
+
["Computer Vision", "NLP", "Time Series", "Recommendation Systems", "Other"]
|
149 |
+
)
|
150 |
+
|
151 |
+
topic = st.text_input("Proposed Research Topic")
|
152 |
+
problem_statement = st.text_area("Brief Problem Statement")
|
153 |
+
motivation = st.text_area("Why is this research important?")
|
154 |
+
|
155 |
+
submitted = st.form_submit_button("Submit Topic")
|
156 |
+
|
157 |
+
if submitted:
|
158 |
+
st.success("Topic submitted successfully! We'll review and provide feedback.")
|
159 |
+
|
160 |
+
# Linear Regression Visualization
|
161 |
+
st.header("2. Linear Regression Demo")
|
162 |
+
st.markdown("""
|
163 |
+
### Understanding Linear Regression
|
164 |
+
|
165 |
+
Linear regression is a fundamental machine learning algorithm that models the relationship between a dependent variable and one or more independent variables.
|
166 |
+
Below is an interactive demonstration of simple linear regression.
|
167 |
+
""")
|
168 |
+
|
169 |
+
# Create interactive controls
|
170 |
+
col1, col2 = st.columns(2)
|
171 |
+
with col1:
|
172 |
+
n_points = st.slider("Number of data points", 10, 100, 50)
|
173 |
+
noise = st.slider("Noise level", 0.1, 2.0, 0.5)
|
174 |
+
with col2:
|
175 |
+
slope = st.slider("True slope", -2.0, 2.0, 1.0)
|
176 |
+
intercept = st.slider("True intercept", -5.0, 5.0, 0.0)
|
177 |
+
|
178 |
+
# Generate synthetic data
|
179 |
+
np.random.seed(42)
|
180 |
+
X = np.random.rand(n_points) * 10
|
181 |
+
y = slope * X + intercept + np.random.normal(0, noise, n_points)
|
182 |
+
|
183 |
+
# Fit linear regression
|
184 |
+
X_reshaped = X.reshape(-1, 1)
|
185 |
+
model = LinearRegression()
|
186 |
+
model.fit(X_reshaped, y)
|
187 |
+
y_pred = model.predict(X_reshaped)
|
188 |
+
|
189 |
+
# Create the plot
|
190 |
+
fig = go.Figure()
|
191 |
+
|
192 |
+
# Add scatter plot of actual data
|
193 |
+
fig.add_trace(go.Scatter(
|
194 |
+
x=X,
|
195 |
+
y=y,
|
196 |
+
mode='markers',
|
197 |
+
name='Actual Data',
|
198 |
+
marker=dict(color='blue')
|
199 |
+
))
|
200 |
+
|
201 |
+
# Add regression line
|
202 |
+
fig.add_trace(go.Scatter(
|
203 |
+
x=X,
|
204 |
+
y=y_pred,
|
205 |
+
mode='lines',
|
206 |
+
name='Regression Line',
|
207 |
+
line=dict(color='red')
|
208 |
+
))
|
209 |
+
|
210 |
+
# Update layout
|
211 |
+
fig.update_layout(
|
212 |
+
title='Linear Regression Visualization',
|
213 |
+
xaxis_title='X',
|
214 |
+
yaxis_title='Y',
|
215 |
+
showlegend=True,
|
216 |
+
height=500
|
217 |
+
)
|
218 |
+
|
219 |
+
# Display the plot
|
220 |
+
st.plotly_chart(fig, use_container_width=True)
|
221 |
+
|
222 |
+
# Display regression coefficients
|
223 |
+
st.markdown(f"""
|
224 |
+
### Regression Results
|
225 |
+
- Estimated slope: {model.coef_[0]:.2f}
|
226 |
+
- Estimated intercept: {model.intercept_:.2f}
|
227 |
+
- R² score: {model.score(X_reshaped, y):.2f}
|
228 |
+
""")
|
229 |
+
|
230 |
+
# Literature Review Section
|
231 |
+
st.header("3. Literature Review")
|
232 |
+
st.markdown("""
|
233 |
+
### Steps for Conducting Literature Review:
|
234 |
+
1. Search for relevant papers
|
235 |
+
2. Read and analyze key papers
|
236 |
+
3. Identify research gaps
|
237 |
+
4. Document your findings
|
238 |
+
""")
|
239 |
+
|
240 |
+
# Literature Review Template
|
241 |
+
st.subheader("Literature Review Template")
|
242 |
+
with st.expander("Download Template"):
|
243 |
+
st.download_button(
|
244 |
+
label="Download Literature Review Template",
|
245 |
+
data="Literature Review Template\n\n1. Introduction\n2. Related Work\n3. Methodology\n4. Results\n5. Discussion\n6. Conclusion",
|
246 |
+
file_name="literature_review_template.txt",
|
247 |
+
mime="text/plain"
|
248 |
+
)
|
249 |
+
|
250 |
+
# Weekly Assignment
|
251 |
+
st.header("Weekly Assignment")
|
252 |
+
st.markdown("""
|
253 |
+
### Assignment 1: Research Proposal
|
254 |
+
1. Select your research topic
|
255 |
+
2. Write a brief problem statement
|
256 |
+
3. Conduct initial literature review
|
257 |
+
4. Submit your research proposal
|
258 |
+
|
259 |
+
**Due Date:** End of Week 1
|
260 |
+
""")
|
261 |
+
|
262 |
+
# Assignment Submission
|
263 |
+
st.subheader("Submit Your Assignment")
|
264 |
+
with st.form("assignment_form"):
|
265 |
+
proposal_file = st.file_uploader("Upload your research proposal (PDF or DOC)")
|
266 |
+
comments = st.text_area("Additional comments or questions")
|
267 |
+
|
268 |
+
if st.form_submit_button("Submit Assignment"):
|
269 |
+
if proposal_file is not None:
|
270 |
+
st.success("Assignment submitted successfully!")
|
271 |
+
else:
|
272 |
+
st.error("Please upload your research proposal.")
|
273 |
|
274 |
# Main content
|
275 |
def main():
|
|
|
280 |
return
|
281 |
|
282 |
# User is logged in, show course content
|
283 |
+
if st.session_state.current_week == 1:
|
284 |
+
show_week_content()
|
285 |
+
else:
|
286 |
+
st.title("Data Science Research Paper Course")
|
287 |
+
st.markdown("""
|
288 |
+
## Welcome to the Data Science Research Paper Course! 📚
|
289 |
+
|
290 |
+
This 10-week course will guide you through the process of creating a machine learning research paper.
|
291 |
+
Each week, you'll learn new concepts and complete tasks that build upon each other.
|
292 |
+
|
293 |
+
### Getting Started
|
294 |
+
1. Use the sidebar to navigate between weeks
|
295 |
+
2. Complete the weekly tasks and assignments
|
296 |
+
3. Track your progress using the progress bar
|
297 |
+
4. Submit your work for feedback
|
298 |
+
|
299 |
+
### Course Overview
|
300 |
+
- Week 1: Research Topic Selection and Literature Review
|
301 |
+
- Week 2: Data Collection and Preprocessing
|
302 |
+
- Week 3: Exploratory Data Analysis
|
303 |
+
- Week 4: Feature Engineering
|
304 |
+
- Week 5: Model Selection and Baseline
|
305 |
+
- Week 6: Model Training and Optimization
|
306 |
+
- Week 7: Model Evaluation
|
307 |
+
- Week 8: Results Analysis
|
308 |
+
- Week 9: Paper Writing
|
309 |
+
- Week 10: Final Review and Submission
|
310 |
+
""")
|
311 |
|
312 |
if __name__ == "__main__":
|
313 |
load_css()
|