Skip to content

Commit add1ee0

Browse files
authored
Merge pull request #2 from 4GeeksAcademy/dev
Updated environment and README
2 parents 25a3973 + 631d8cd commit add1ee0

File tree

6 files changed

+360
-63
lines changed

6 files changed

+360
-63
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/python
33
{
4-
"name": "Python 3",
4+
// Container definition for a Python 3.11 development environment
5+
"name": "Python 3.11",
56
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
6-
"onCreateCommand": "sudo apt update && sudo apt upgrade -y && pip3 install --upgrade pip && pip3 install --user -r requirements.txt",
7+
8+
// Custom configuration options
79
"customizations": {
810
"vscode": {
11+
12+
// Use 'settings' to set default VS code values on container create
913
"settings": {
1014
"jupyter.kernels.excludePythonEnvironments": ["/usr/bin/python3"],
11-
"remote.portsAttributes": {
12-
"ipykernel_launcher": {"onAutoForward": "ignore"}
13-
}
15+
"remote.autoForwardPorts": false,
16+
"remote.restoreForwardedPorts": false
1417
},
18+
19+
// Add the IDs of VS code extensions you want to install here
1520
"extensions": [
1621
"-dbaeumer.vscode-eslint",
1722
"ms-python.python",
@@ -20,5 +25,10 @@
2025
]
2126
}
2227
},
28+
29+
// Use 'onCreateCommand' to run commands once when the container is created
30+
"onCreateCommand": "sudo apt update && sudo apt upgrade -y && pip3 install --upgrade pip && pip3 install --user -r requirements.txt",
31+
32+
// Use 'postAttachCommand' to run commands each time a user connects to the container
2333
"postAttachCommand": "htop"
2434
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
.vscode
1+
__pycache__
22
.ipynb_checkpoints
3+
.vscode
4+
.venv

README.md

Lines changed: 116 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,131 @@
1-
# Algorithm Optimization Project
1+
# Algorithm Optimization Project - Machine Learning
22

3-
![Preview](assets/preview.png)
3+
[![Codespaces Prebuilds](https://github.com/4GeeksAcademy/gperdrizet-algorithm-optimization-project-machine-learning/actions/workflows/codespaces/create_codespaces_prebuilds/badge.svg)](https://github.com/4GeeksAcademy/gperdrizet-algorithm-optimization-project-machine-learning/actions/workflows/codespaces/create_codespaces_prebuilds)
44

5-
This repository contains exercises designed to help you practice optimizing Python algorithms for better performance and readability.
5+
A comprehensive programming optimization project focused on improving algorithm efficiency and code performance. This project demonstrates essential optimization techniques through practical exercises involving text processing and list operations.
66

7-
## What You'll Learn
7+
![Project Preview](assets/preview.png)
88

9-
- Text processing optimization techniques
10-
- Efficient list operations and filtering
11-
- Using Python's built-in functions and data structures
12-
- Code modularity and best practices
13-
- Performance analysis and improvement strategies
149

15-
## Assignment Overview
10+
## Project Overview
1611

17-
The `problems.ipynb` notebook contains two main exercises:
12+
This project focuses on algorithm optimization through two main exercises that teach fundamental performance improvement techniques:
1813

19-
1. **Text Processing Optimization** - Improve code that processes text by converting to lowercase, removing punctuation, counting word frequencies, and finding the most common words.
14+
**Exercise 1: Text Processing Optimization**
15+
- Convert text to lowercase
16+
- Remove punctuation marks efficiently
17+
- Count word frequencies
18+
- Extract most common words
2019

21-
2. **List Processing Optimization** - Enhance code that filters even numbers, duplicates values, sums results, and checks for prime numbers.
20+
**Exercise 2: List Processing Optimization**
21+
- Filter even numbers from lists
22+
- Duplicate list elements
23+
- Sum numerical values
24+
- Prime number detection
25+
26+
The project provides hands-on experience with:
27+
- Code refactoring and optimization
28+
- Efficient data structure usage
29+
- Python built-in function utilization
30+
- Modular programming practices
31+
- Performance analysis and improvement
2232

23-
Each exercise includes working but inefficient code that you'll optimize using better algorithms, data structures, and Python idioms.
2433

2534
## Getting Started
2635

2736
### Option 1: GitHub Codespaces (Recommended)
28-
1. Fork this repository to your GitHub account
29-
2. Click the green "Code" button on your forked repository
30-
3. Select "Codespaces" tab
31-
4. Click "Create codespace on main"
32-
5. Wait for the environment to load (this may take a few minutes)
33-
6. Open `problems.ipynb` and start working!
37+
38+
1. **Fork the Repository**
39+
- Click the "Fork" button on the top right of the GitHub repository page
40+
- 4Geeks students: set 4GeeksAcademy as the owner - 4Geeks pays for your codespace usage. All others, set yourself as the owner
41+
- Give the fork a descriptive name. 4Geeks students: I recommend including your GitHub username to help in finding the fork if you loose the link
42+
- Click "Create fork"
43+
- 4Geeks students: bookmark or otherwise save the link to your fork
44+
45+
2. **Create a GitHub Codespace**
46+
- On your forked repository, click the "Code" button
47+
- Select "Create codespace on main"
48+
- If the "Create codespace on main" option is grayed out - go to your codespaces list from the three-bar menu at the upper left and delete an old codespace
49+
- Wait for the environment to load (dependencies are pre-installed)
50+
51+
3. **Start Working**
52+
- Open `notebooks/assignment.ipynb` in the Jupyter interface
53+
- Follow the step-by-step instructions in the notebook
3454

3555
### Option 2: Local Development
36-
1. Fork and clone this repository
37-
2. Create a virtual environment: `python -m venv venv`
38-
3. Activate the virtual environment:
39-
- On Windows: `venv\Scripts\activate`
40-
- On macOS/Linux: `source venv/bin/activate`
41-
4. Install Jupyter: `pip install jupyter`
42-
5. Install dependencies: `pip install -r requirements.txt`
43-
6. Launch Jupyter: `jupyter notebook`
44-
7. Open `problems.ipynb`
45-
46-
## Working with the Notebook
47-
48-
- Each exercise contains the original inefficient code followed by optimization points
49-
- Review the provided solutions as reference implementations
50-
- Try implementing your own optimizations before checking the solutions
51-
- Run each cell to test your code and compare performance
52-
53-
## Learning Goals
54-
55-
By completing this assignment, you will:
56-
- Understand common performance bottlenecks in Python code
57-
- Learn to use appropriate data structures for different problems
58-
- Practice writing clean, modular, and efficient code
59-
- Gain experience with Python's built-in optimization tools
60-
61-
## Assessment
62-
63-
Focus on:
64-
- **Correctness**: Does your optimized code produce the same results?
65-
- **Efficiency**: Is your solution faster and more memory-efficient?
66-
- **Readability**: Is your code clean and well-structured?
67-
- **Best Practices**: Are you using appropriate Python idioms?
68-
69-
Happy coding!
56+
57+
1. **Prerequisites**
58+
- Git
59+
- Python >= 3.10
60+
61+
2. **Fork the repository**
62+
- Click the "Fork" button on the top right of the GitHub repository page
63+
- Optional: give the fork a new name and/or description
64+
- Click "Create fork"
65+
66+
3. **Clone the repository**
67+
- From your fork of the repository, click the green "Code" button at the upper right
68+
- From the "Local" tab, select HTTPS and copy the link
69+
- Run the following commands on your machine, replacing `<LINK>` and `<REPO_NAME>`
70+
71+
```bash
72+
git clone <LINK>
73+
cd <REPO_NAME>
74+
```
75+
76+
4. **Set Up Environment**
77+
78+
```bash
79+
python -m venv venv
80+
source venv/bin/activate
81+
pip install -r requirements.txt
82+
```
83+
84+
5. **Launch Jupyter & start the notebook**
85+
```bash
86+
jupyter notebook notebooks/assignment.ipynb
87+
```
88+
89+
90+
## Project Structure
91+
92+
```
93+
├── .devcontainer/ # Development container configuration
94+
├── assets/ # Files and resources directory
95+
96+
├── notebooks/ # Jupyter notebook directory
97+
│ ├── assignment.ipynb # Assignment notebook with exercises
98+
│ └── solution.ipynb # Solution notebook with optimized code
99+
100+
├── .gitignore # Files/directories not tracked by git
101+
├── requirements.txt # Python dependencies
102+
└── README.md # Project documentation
103+
```
104+
105+
106+
## Learning Objectives
107+
108+
1. **Algorithm Analysis**: Identify performance bottlenecks in existing code
109+
2. **Data Structure Optimization**: Use appropriate Python data structures for efficiency
110+
3. **Built-in Functions**: Leverage Python's optimized built-in functions
111+
4. **List Comprehensions**: Replace loops with more efficient comprehensions
112+
5. **Modular Design**: Break code into focused, reusable functions
113+
6. **Performance Comparison**: Understand the impact of different approaches
114+
115+
## Technologies Used
116+
117+
- **Python 3.11**: Core programming language
118+
- **Collections**: Counter for efficient frequency counting
119+
- **String**: Built-in string processing utilities
120+
- **Math**: Mathematical operations and functions
121+
- **Jupyter**: Interactive development environment
122+
123+
124+
## Contributing
125+
126+
This is an educational project. Contributions for improving the optimization examples or adding new exercises are welcome:
127+
128+
1. Fork the repository
129+
2. Create a feature branch
130+
3. Make your changes
131+
4. Submit a pull request

0 commit comments

Comments
 (0)