|
1 | | -# Algorithm Optimization Project |
| 1 | +# Algorithm Optimization Project - Machine Learning |
2 | 2 |
|
3 | | - |
| 3 | +[](https://github.com/4GeeksAcademy/gperdrizet-algorithm-optimization-project-machine-learning/actions/workflows/codespaces/create_codespaces_prebuilds) |
4 | 4 |
|
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. |
6 | 6 |
|
7 | | -## What You'll Learn |
| 7 | + |
8 | 8 |
|
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 |
14 | 9 |
|
15 | | -## Assignment Overview |
| 10 | +## Project Overview |
16 | 11 |
|
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: |
18 | 13 |
|
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 |
20 | 19 |
|
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 |
22 | 32 |
|
23 | | -Each exercise includes working but inefficient code that you'll optimize using better algorithms, data structures, and Python idioms. |
24 | 33 |
|
25 | 34 | ## Getting Started |
26 | 35 |
|
27 | 36 | ### 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 |
34 | 54 |
|
35 | 55 | ### 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