Spaces:
Running
Running
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/) | |
""") |