A collection of machine learning competition solutions and exercises, focusing on practical implementations and best practices.
This repository contains 6 different machine learning problems with complete solutions and tutorials:
- Adversarial Attacks - Neural network security and robustness
- Color Quantization - Image processing and clustering
- Dependency Parsing - Natural language processing
- Imbalanced Classification - Handling skewed datasets
- Neural Network Pruning - Model compression techniques
- Word Riddles - Text analysis and pattern recognition
βββ .github/ # CI/CD pipelines
βββ data/ # Central data storage
βββ problems/ # Competition tasks
β βββ 01_adversarial_attacks/
β β βββ problem/ # Problem statement
β β βββ solution/ # Complete solution
β β βββ tutorial/ # Learning materials
β βββ 02_color_quantization/
β βββ ... (other problems)
βββ scripts/ # Utility scripts
βββ tests/ # Unit/integration tests
βββ requirements.txt # Python dependencies
βββ environment.yml # Conda environment
βββ pyproject.toml # Project configuration
# Clone the repository
git clone <repository-url>
cd SelfStudy_OAI
# Run the setup script
chmod +x scripts/setup.sh
./scripts/setup.sh
# Activate the environment
source venv/bin/activate# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Create and activate conda environment
conda env create -f environment.yml
conda activate selfstudy_oai- Python: 3.8 or higher
- OS: macOS, Linux, or Windows
- Memory: 4GB RAM minimum (8GB recommended)
- Storage: 2GB free space
- The setup script automatically detects Apple Silicon and uses system Python to avoid SSL issues
- If you encounter SSL problems, try using conda instead of pip
- Xcode Command Line Tools are required:
xcode-select --install
- Standard Python installation should work fine
- Both pip and conda options are supported
- Most distributions work out of the box
- Ensure you have
python3-venvinstalled:sudo apt install python3-venv
- Use PowerShell or Command Prompt
- Replace
source venv/bin/activatewithvenv\Scripts\activate
Run the test suite to ensure everything is working:
# Activate environment first
source venv/bin/activate
# Run all tests
pytest tests/
# Run specific test
pytest tests/test_basic.py -v
# Run tests with coverage
pytest tests/ --cov=.The project uses several tools to maintain code quality:
- Black: Code formatting
- isort: Import sorting
- flake8: Linting
- nbqa: Apply tools to Jupyter notebooks
- pytest: Testing
# Format code
black .
nbqa black .
# Sort imports
isort .
nbqa isort .
# Lint code
flake8 .
nbqa flake8 .
# Run all quality checks
black . --check && nbqa black . --check && \
isort . --check-only && nbqa isort . --check-only && \
flake8 . && nbqa flake8 .For automatic code formatting on commit:
pip install pre-commit
pre-commit install# Activate environment
source venv/bin/activate
# Start Jupyter Lab (recommended)
jupyter lab
# Or start classic Jupyter Notebook
jupyter notebookEach problem follows this structure:
- Problem notebook: Contains the task description and starter code
- Solution notebook: Complete working solution
- Tutorial notebook: Step-by-step explanation and learning materials
- Data is automatically downloaded when running problem notebooks
- All data is stored in the
data/directory - Each notebook handles its own data dependencies
Problem: SSL: CERTIFICATE_VERIFY_FAILED or similar SSL errors
Solutions:
- On macOS with Apple Silicon: Use the automated setup script
- Try using conda instead of pip:
conda env create -f environment.yml - Update certificates:
pip install --upgrade certifi
Problem: Some packages fail to install
Solutions:
- Update pip:
pip install --upgrade pip - Install packages individually:
pip install numpy pandas scikit-learn - Try using conda:
conda install numpy pandas scikit-learn - Clear pip cache:
pip cache purge
Problem: Library architecture incompatibility
Solutions:
- Use the automated setup script which detects architecture
- Use system Python:
/usr/bin/python3 -m venv venv - Reinstall Python for your architecture from python.org
Problem: Jupyter can't find the virtual environment
Solutions:
- Install ipykernel:
pip install ipykernel - Add environment to Jupyter:
python -m ipykernel install --user --name=selfstudy_oai - Restart Jupyter and select the correct kernel
If you encounter issues:
- Check the troubleshooting section above
- Run the setup script with verbose output:
bash -x scripts/setup.sh - Verify your Python installation:
python --version - Check virtual environment:
which python(should point to venv)
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests and quality checks
- Submit a pull request
- Follow PEP 8 guidelines
- Use Black for formatting
- Add docstrings to functions
- Write tests for new features
MIT License - see LICENSE file for details.
- Competition problems inspired by OAI (Olimpiada AlgorytmΓ³w i Inteligencji Sztucznej)
- Reference implementations and tutorials created for educational purposes
- Thanks to all contributors and the machine learning community
Happy Learning! π