Contributing
Thank you for considering contributing to FairSample!
Ways to Contribute
- Report bugs and issues
- Suggest new features or techniques
- Improve documentation
- Submit bug fixes
- Add new resampling techniques
- Add new complexity measures
Development Setup
- Fork and clone the repository:
- Create a virtual environment:
- Install in development mode:
- Run tests:
Code Style
- Follow PEP 8
- Use type hints where possible
- Write docstrings for all public functions
- Keep functions focused and small
Adding a New Technique
- Create a new file in
fairsample/techniques/ - Implement the technique following scikit-learn's API:
from imblearn.base import BaseSampler
class MyTechnique(BaseSampler):
def __init__(self, param1=default1, random_state=None):
self.param1 = param1
self.random_state = random_state
def fit_resample(self, X, y):
# Your implementation
return X_resampled, y_resampled
- Add to
fairsample/techniques/__init__.py - Write tests in
tests/ - Update documentation
Adding a Complexity Measure
- Add method to
ComplexityMeasuresclass infairsample/complexity/measures.py:
def calculate_my_measure(self):
"""
Calculate my complexity measure.
Returns
-------
float
The complexity score.
"""
# Your implementation
return score
- Add to appropriate category in
get_all_complexity_measures() - Write tests
- Update documentation
Testing
Write tests for all new code:
def test_my_technique():
from fairsample import MyTechnique
X, y = make_classification(n_samples=100, n_classes=2, weights=[0.9, 0.1])
sampler = MyTechnique()
X_resampled, y_resampled = sampler.fit_resample(X, y)
assert len(X_resampled) > 0
assert len(X_resampled) == len(y_resampled)
Run tests:
Documentation
Update documentation for any changes:
- Update docstrings in code
- Update relevant markdown files in
docs/ - Preview documentation:
- Build documentation:
Pull Request Process
- Create a new branch:
- Make your changes and commit:
- Push to your fork:
-
Open a Pull Request on GitHub
-
Ensure all tests pass and documentation is updated
Code Review
All submissions require review. We'll provide feedback and may request changes.
Questions?
Open an issue or start a discussion on GitHub.
License
By contributing, you agree that your contributions will be licensed under the MIT License.