Spaces:
Running
Running
File size: 23,605 Bytes
31653a7 |
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
def show():
st.title("Week 8: Research Paper Writing and LaTeX")
# Introduction
st.header("Learning Objectives")
st.markdown("""
By the end of this week, you will be able to:
**Remember (Knowledge):**
- Recall LaTeX syntax for document structure, figures, citations, and spacing
- Identify components of ML research papers (introduction, methods, results, conclusion, limitations)
- Recognize standard formatting requirements for academic conferences and journals
**Understand (Comprehension):**
- Describe the purpose and audience for each section of a research paper
**Apply (Application):**
- Format complete research papers in LaTeX with proper figures, tables, and citations
- Write clear methodology sections with sufficient detail for reproducibility
- Present experimental results using appropriate visualizations and statistical analysis
**Analyze (Analysis):**
- Diagnose LaTeX formatting issues and resolve compilation errors
- Examine related work to identify research gaps and position their contributions
- Compare methodology approaches with existing methods
**Evaluate (Evaluation):**
- Critically assess the validity and reliability of experimental design
- Evaluate the clarity and persuasiveness of written arguments
**Create (Synthesis):**
- Produce research papers
- Develop compelling visualizations that effectively communicate complex ML concepts
- Synthesize technical knowledge into coherent research narratives
""")
# Module 1: Research Paper Architecture
st.header("Module 1: Research Paper Architecture")
st.markdown("""
Every section of your paper must answer specific questions that reviewers ask. Think of your paper as a conversation
with skeptical experts who need convincing.
""")
# Paper Structure Table
st.subheader("Research Paper Structure")
paper_structure = {
"Section": ["π₯ Introduction", "π¬ Methods", "π Results", "π― Conclusion", "β οΈ Limitations"],
"Key Problems/Focus": [
"What problem are you solving? Why does it matter? How is your approach different?",
"How did you collect data? What analysis techniques? Can others replicate this?",
"What concrete findings emerged? How do they address your research questions?",
"What's the key takeaway? How does this advance the field? What are practical implications?",
"What are honest constraints? What biases might exist? What couldn't you address?"
],
"Aim For": [
"Compelling motivation",
"Rigorous reproducibility",
"Clear evidence",
"Lasting impact",
"Honest transparency"
]
}
st.dataframe(pd.DataFrame(paper_structure))
# Detailed Section Guidelines
st.subheader("Detailed Section Guidelines")
# Introduction Section
with st.expander("π₯ Introduction: Building Compelling Motivation"):
st.markdown("""
**What is it:** The introduction is your paper's first impression and often determines whether reviewers continue reading.
**Why this matters:** A weak introduction leads to immediate rejection, regardless of how brilliant your technical contribution might be.
**What to do:**
1. Use the "inverted pyramid" approach
2. Start with broad context, then narrow to specific problem
3. Clearly articulate the gap in existing solutions
4. Present your approach as a logical response
5. Conclude with explicit contributions (3-4 bullet points)
**Example Structure:**
```
1. Broad context about the field
2. Specific problem you're addressing
3. Gap in existing solutions
4. Your approach as response to gap
5. Explicit contributions
```
""")
# Methods Section
with st.expander("π¬ Methods: Ensuring Rigorous Reproducibility"):
st.markdown("""
**What is it:** The methods section has evolved from simple description to detailed documentation that enables complete replication.
**Why this matters:** Irreproducible research wastes community resources and undermines scientific credibility.
**What to document:**
- Dataset specifics (exact version, preprocessing steps, train/validation/test splits)
- Model architecture details (layer sizes, activation functions, initialization schemes)
- Training procedures (optimization algorithm, learning rate schedules, batch sizes)
- Computational environment (hardware specifications, software versions, random seeds)
**Write as if creating a recipe** that a competent colleague could follow to recreate your exact results.
""")
# Results Section
with st.expander("π Results: Presenting Clear Evidence"):
st.markdown("""
**What is it:** The results section synthesizes your raw findings into compelling evidence for your claims.
**Why this matters:** This section proves whether your methodology actually works and answers your research questions.
**What to do:**
1. Organize results logically (general performance to specific analyses)
2. Start with overall model performance using standard metrics
3. Include detailed comparisons, ablation studies, and error analysis
4. Use clear visualizations with appropriate error bars
5. Report negative results honestly
6. Connect each finding back to your original research questions
""")
# Conclusion Section
with st.expander("π― Conclusion: Creating Lasting Impact"):
st.markdown("""
**What is it:** The conclusion shapes how the research community understands and remembers your contribution.
**Why this matters:** Your technical contribution only matters if others can understand its significance and apply it.
**What to do:**
1. Begin with concise summary of key findings (2-3 sentences)
2. State how findings advance theoretical understanding or practical applications
3. Discuss broader implications beyond your specific problem domain
4. Suggest concrete directions for future research
5. Balance confidence with humility about scope
""")
# Limitations Section
with st.expander("β οΈ Limitations: Demonstrating Honest Transparency"):
st.markdown("""
**What is it:** Acknowledging limitations shows scientific maturity and helps readers appropriately interpret your findings.
**Why this matters:** Every study has constraints, and attempting to hide them makes reviewers suspicious.
**Three types of limitations to address:**
1. **Scope limitations:** What populations, contexts, or problem types might your results not apply to?
2. **Methodological constraints:** Sample size issues, measurement limitations, or experimental design trade-offs
3. **Potential biases:** Dataset bias, researcher bias, or systematic errors in your approach
**For each limitation:** Explain potential impact and suggest how future work could address it.
""")
# Quick Reference Framework
st.subheader("Quick Reference Framework")
st.markdown("""
**Title β Problem β Gap β Method β Findings β Impact β Limitations**
This progression ensures logical flow and helps readers follow your research narrative from motivation through contribution to appropriate interpretation.
""")
# Module 2: LaTeX Introduction
st.header("Module 2: Introduction to LaTeX")
st.markdown("""
**What is LaTeX?**
Think of LaTeX as a sophisticated word processor that works differently from Microsoft Word or Google Docs.
Instead of clicking buttons to format text, you write commands that tell the computer how to format your document.
""")
# Why LaTeX
st.subheader("Why Learn LaTeX for Academic Writing?")
latex_benefits = {
"Benefit": [
"Professional appearance",
"Mathematical notation",
"Reference management",
"Industry standard"
],
"Description": [
"LaTeX automatically handles spacing, fonts, and layout to meet academic standards",
"Essential for ML papers with equations and formulas",
"Automatically formats citations and bibliographies",
"Most computer science conferences and journals expect LaTeX submissions"
]
}
st.dataframe(pd.DataFrame(latex_benefits))
# LaTeX Code Examples
st.subheader("LaTeX Code Examples")
# Basic Structure
with st.expander("Basic Document Structure"):
st.markdown("**LaTeX Code:**")
st.code("""
\\documentclass{article}
\\usepackage[utf8]{inputenc}
\\usepackage{graphicx}
\\title{Your Research Paper Title}
\\author{Your Name}
\\date{\\today}
\\begin{document}
\\maketitle
\\section{Introduction}
Your introduction text goes here.
\\section{Methods}
Your methods section goes here.
\\section{Results}
Your results section goes here.
\\section{Conclusion}
Your conclusion goes here.
\\end{document}
""", language="latex")
st.markdown("**Rendered Output:**")
st.markdown("""
<div style="border: 1px solid #ccc; padding: 40px; margin: 20px auto; background-color: white; font-family: 'Times New Roman', Times, serif; color: black; box-shadow: 0 0 10px rgba(0,0,0,0.1); max-width: 800px;">
<h1 style="text-align: center; font-size: 22px; font-weight: bold; margin-bottom: 10px; color: black;">Your Research Paper Title</h1>
<p style="text-align: center; font-size: 16px; margin-bottom: 30px; color: black;"><em>Your Name</em><br><em>Today's Date</em></p>
<h2 style="font-size: 18px; font-weight: bold; margin-top: 20px; margin-bottom: 10px; color: black;">1. Introduction</h2>
<p style="font-size: 16px; line-height: 1.6; color: black;">Your introduction text goes here.</p>
<h2 style="font-size: 18px; font-weight: bold; margin-top: 20px; margin-bottom: 10px; color: black;">2. Methods</h2>
<p style="font-size: 16px; line-height: 1.6; color: black;">Your methods section goes here.</p>
<h2 style="font-size: 18px; font-weight: bold; margin-top: 20px; margin-bottom: 10px; color: black;">3. Results</h2>
<p style="font-size: 16px; line-height: 1.6; color: black;">Your results section goes here.</p>
<h2 style="font-size: 18px; font-weight: bold; margin-top: 20px; margin-bottom: 10px; color: black;">4. Conclusion</h2>
<p style="font-size: 16px; line-height: 1.6; color: black;">Your conclusion goes here.</p>
</div>
""", unsafe_allow_html=True)
# Sections and Subsections
with st.expander("Creating Sections and Subsections"):
st.markdown("**LaTeX Code:**")
st.code("""
\\section{Introduction} % Creates: 1. Introduction
\\subsection{Background} % Creates: 1.1 Background
\\subsubsection{Deep Learning} % Creates: 1.1.1 Deep Learning
% Tip: Overleaf shows section structure in the left panel for easy navigation
""", language="latex")
st.markdown("**Rendered Output:**")
st.markdown("""
<div style="border: 1px solid #ddd; padding: 20px; background-color: white; font-family: 'Times New Roman', serif; color: black;">
<h2 style="color: black; font-size: 18px; font-weight: bold;">1. Introduction</h2>
<h3 style="color: black; font-size: 16px; font-weight: bold; padding-left: 20px;">1.1 Background</h3>
<h4 style="color: black; font-size: 16px; font-style: italic; padding-left: 40px;">1.1.1 Deep Learning</h4>
<p style="color: black; padding-left: 40px; margin-top: 10px;"><em>Tip: Overleaf shows section structure in the left panel for easy navigation</em></p>
</div>
""", unsafe_allow_html=True)
# Figures
with st.expander("Adding Figures"):
st.markdown("**LaTeX Code:**")
st.code("""
\\begin{figure}[h]
\\centering
\\includegraphics[width=0.8\\textwidth]{research_question.jpg}
\\caption{The cycle of research from practical problem to research answer.}
\\label{fig:research_cycle}
\\end{figure}
% Reference it in your text
Figure~\\ref{fig:research_cycle} shows the relationship between problems, questions, and answers.
""", language="latex")
st.markdown("**Rendered Output:**")
# Center the image using columns
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
st.image("assets/Pictures/research_question.jpg", width=384, caption="Figure 1: The cycle of research from practical problem to research answer.")
st.markdown("""
<div style="background-color: white; font-family: 'Times New Roman', serif; color: black; padding: 0 20px 20px 20px;">
<p style="color: black; text-align: left;">Figure 1 shows the relationship between problems, questions, and answers.</p>
</div>
""", unsafe_allow_html=True)
# Citations and Bibliography
with st.expander("Citations and Bibliography"):
st.markdown("**LaTeX Code:**")
st.code("""
% In your main document
\\usepackage{biblatex}
\\addbibresource{sample.bib}
% Cite a reference
Our approach builds on recent work \\cite{einstein} and extends it by...
% Print bibliography
\\printbibliography
% In sample.bib file:
@article{einstein,
title={On the electrodynamics of moving bodies},
author={Einstein, Albert},
journal={Annalen der Physik},
volume={322},
number={10},
pages={891--921},
year={1905}
}
""", language="latex")
st.markdown("**Rendered Output:**")
st.markdown("""
<div style="border: 1px solid #ddd; padding: 20px; background-color: white; font-family: Times, 'Times New Roman', serif; color: black;">
<p style="color: black; margin-bottom: 1.5em;">Our approach builds on recent work [1] and extends it by...</p>
<h3 style="color: black; margin-bottom: 0.5em; font-weight: bold;">References</h3>
<p style="line-height: 1.6; padding-left: 2em; text-indent: -2em;">
[1] A. Einstein, "On the electrodynamics of moving bodies," <i>Annalen der Physik</i>, vol. 322, no. 10, pp. 891β921, 1905.
</p>
</div>
""", unsafe_allow_html=True)
# Mathematical Equations
with st.expander("Mathematical Equations"):
st.markdown("**LaTeX Code:**")
st.code("""
% Inline math
The loss function $L(\\theta)$ is defined as...
% Display math
\\begin{equation}
L(\\theta) = \\frac{1}{n} \\sum_{i=1}^{n} (y_i - f(x_i, \\theta))^2
\\label{eq:loss}
\\end{equation}
% Reference the equation
As shown in Equation~\\ref{eq:loss}, the loss function...
""", language="latex")
st.markdown("**Rendered Output:**")
st.markdown("""
<div style="border: 1px solid #ddd; padding: 20px; background-color: white; font-family: 'Times New Roman', serif; color: black;">
<p style="color: black;">The loss function <em>L(θ)</em> is defined as...</p>
<div style="display: flex; justify-content: space-between; align-items: center; margin: 20px 0;">
<div style="flex-grow: 1; text-align: center;">
<img src="https://latex.codecogs.com/svg.latex?L(\\theta)%20=%20\\frac{1}{n}%20\\sum_{i=1}^{n}%20(y_i%20-%20f(x_i,%20\\theta))^2" />
</div>
<div style="font-style: italic; color: black;">(1)</div>
</div>
<p style="color: black;">As shown in Equation (1), the loss function...</p>
</div>
""", unsafe_allow_html=True)
# Tables
with st.expander("Creating Tables"):
st.markdown("**LaTeX Code:**")
st.code("""
\\begin{table}[h]
\\centering
\\begin{tabular}{|l|c|r|}
\\hline
\\textbf{Method} & \\textbf{Accuracy} & \\textbf{Time (s)} \\\\
\\hline
Baseline & 85.2\\% & 120 \\\\
Our Method & 89.7\\% & 95 \\\\
\\hline
\\end{tabular}
\\caption{Performance comparison of different methods}
\\label{tab:results}
\\end{table}
% Reference the table
Table~\\ref{tab:results} shows the performance comparison...
""", language="latex")
st.markdown("**Rendered Output:**")
st.markdown("""
<div style="border: 1px solid #ddd; padding: 20px; background-color: white; font-family: 'Times New Roman', serif; color: black;">
<div style="text-align: center; margin: 20px 0;">
<table style="border-collapse: collapse; width: 100%; max-width: 500px; margin: 0 auto;">
<tr style="border: 1px solid #000;">
<th style="border: 1px solid #000; padding: 8px; text-align: left; font-weight: bold;">Method</th>
<th style="border: 1px solid #000; padding: 8px; text-align: center; font-weight: bold;">Accuracy</th>
<th style="border: 1px solid #000; padding: 8px; text-align: right; font-weight: bold;">Time (s)</th>
</tr>
<tr style="border: 1px solid #000;">
<td style="border: 1px solid #000; padding: 8px; text-align: left;">Baseline</td>
<td style="border: 1px solid #000; padding: 8px; text-align: center;">85.2%</td>
<td style="border: 1px solid #000; padding: 8px; text-align: right;">120</td>
</tr>
<tr style="border: 1px solid #000;">
<td style="border: 1px solid #000; padding: 8px; text-align: left;">Our Method</td>
<td style="border: 1px solid #000; padding: 8px; text-align: center;">89.7%</td>
<td style="border: 1px solid #000; padding: 8px; text-align: right;">95</td>
</tr>
</table>
<p style="margin-top: 10px; font-style: italic; color: black;">Table 1: Performance comparison of different methods</p>
</div>
<p style="color: black;">Table 1 shows the performance comparison...</p>
</div>
""", unsafe_allow_html=True)
# Interactive LaTeX Practice
st.header("Interactive LaTeX Practice")
st.markdown("""
Let's practice some common LaTeX commands. Try these exercises:
""")
# Exercise 1: Basic Document
with st.expander("Exercise 1: Create a Basic Document"):
st.markdown("""
**Task:** Create a basic LaTeX document with title, author, and three sections.
**Steps:**
1. Open Overleaf and create a new project
2. Replace the default content with your own
3. Add a title and your name
4. Create three sections: Introduction, Methods, Results
5. Add some placeholder text to each section
6. Compile to see your PDF
""")
st.code("""
\\documentclass{article}
\\title{My First LaTeX Document}
\\author{Your Name}
\\date{\\today}
\\begin{document}
\\maketitle
\\section{Introduction}
This is the introduction section.
\\section{Methods}
This is the methods section.
\\section{Results}
This is the results section.
\\end{document}
""", language="latex")
# Exercise 2: Adding Figures
with st.expander("Exercise 2: Adding a Figure"):
st.markdown("""
**Task:** Add a figure to your document.
**Steps:**
1. Upload an image to your Overleaf project
2. Add the figure code to your document
3. Add a caption and label
4. Reference the figure in your text
""")
st.code("""
\\begin{figure}[h]
\\centering
\\includegraphics[width=0.7\\textwidth]{your-image.png}
\\caption{Description of your figure}
\\label{fig:example}
\\end{figure}
As shown in Figure~\\ref{fig:example}, our results demonstrate...
""", language="latex")
# Exercise 3: Citations
with st.expander("Exercise 3: Adding Citations"):
st.markdown("""
**Task:** Add citations to your document.
**Steps:**
1. Create a .bib file with your references
2. Add the bibliography package to your document
3. Add citations in your text
4. Include the bibliography at the end
""")
st.code("""
% In your main document
\\usepackage{biblatex}
\\addbibresource{references.bib}
% Add citations
Recent work \\cite{smith2023} has shown that...
\\printbibliography
% In references.bib:
@article{smith2023,
title={Recent advances in machine learning},
author={Smith, John and Johnson, Jane},
journal={Journal of ML Research},
year={2023}
}
""", language="latex")
# Common LaTeX Issues and Solutions
st.header("Common LaTeX Issues and Solutions")
issues_solutions = {
"Issue": [
"Document won't compile",
"Figure not appearing",
"Citations not showing",
"Math equations not rendering",
"Bibliography not generating"
],
"Common Cause": [
"Missing closing brace or bracket",
"Wrong filename or path",
"Missing \\printbibliography command",
"Missing math mode delimiters",
"Missing \\addbibresource command"
],
"Solution": [
"Check for matching braces and brackets",
"Verify filename and upload to Overleaf",
"Add \\printbibliography at end of document",
"Use $ for inline, \\begin{equation} for display",
"Add \\addbibresource{filename.bib}"
]
}
st.dataframe(pd.DataFrame(issues_solutions))
# Best Practices
st.header("Best Practices for Research Paper Writing")
st.markdown("""
**Writing Tips:**
1. **Start with an outline** - Plan your paper structure before writing
2. **Write the methods first** - It's usually the easiest section
3. **Use clear, concise language** - Avoid jargon when possible
4. **Be specific** - Use concrete numbers and examples
5. **Revise multiple times** - Good writing is rewriting
**LaTeX Tips:**
1. **Compile frequently** - Catch errors early
2. **Use meaningful labels** - fig:results is better than fig:1
3. **Keep backups** - Version control your LaTeX files
4. **Use templates** - Start with conference/journal templates
5. **Learn keyboard shortcuts** - Speed up your workflow
""")
# Additional Resources
st.header("Additional Resources")
st.markdown("""
**LaTeX Resources:**
- [Overleaf Documentation](https://www.overleaf.com/learn)
- [LaTeX Wikibook](https://en.wikibooks.org/wiki/LaTeX)
- [CTAN (Comprehensive TeX Archive Network)](https://ctan.org/)
""") |