Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xgboost sampler #30

Merged
merged 2 commits into from
Dec 12, 2022
Merged

Add xgboost sampler #30

merged 2 commits into from
Dec 12, 2022

Conversation

AldoGl
Copy link
Contributor

@AldoGl AldoGl commented Dec 11, 2022

Proposed changes

  • I added the XGBoost sampler used in "Agent-based model calibration using machine learning surrogates"
  • I added a test for the new sampler
  • I added the XGBoost sampler to the Jupyter notebook with the samplers overview

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING doc
  • I am making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2022

Codecov Report

Merging #30 (f51d2bf) into main (f666b54) will increase coverage by 0.08%.
The diff coverage is 98.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
+ Coverage   97.50%   97.59%   +0.08%     
==========================================
  Files          24       28       +4     
  Lines        1325     1413      +88     
==========================================
+ Hits         1292     1379      +87     
- Misses         33       34       +1     
Impacted Files Coverage Δ
black_it/samplers/xgboost.py 98.00% <98.00%> (ø)
black_it/__init__.py 100.00% <0.00%> (ø)
black_it/utils/base.py 100.00% <0.00%> (ø)
black_it/utils/__init__.py 100.00% <0.00%> (ø)

@AldoGl AldoGl force-pushed the add-xgboost-sampler branch from 589dfb4 to f51d2bf Compare December 11, 2022 15:40
@@ -39,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 108,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(very picky) Could you fully execute the notebook from scratch so to make the execution count reasonable?

@marcofavoritobi marcofavoritobi self-requested a review December 12, 2022 11:52
Copy link
Contributor

@marcofavoritobi marcofavoritobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is a useful feature.

I wonder whether we could develop a generalized sampler based on machine learning surrogates (i.e. regressors). Something like:

class Regressor(ABC):

    @abstractmethod
    def fit(self, X, y):
        raise NotImplementedError

    @abstractmethod
    def predict(x):
        raise NotImplementedError


class SurrogateSampler(BaseSampler):


    def __init__(  # pylint: disable=too-many-arguments
        self,
        batch_size: int,
        regressor: Regressor,
        random_state: Optional[int] = None,
        max_deduplication_passes: int = 5,
        candidate_pool_size: Optional[int] = None):
        ...
        self.regressor = regressor

@AldoGl
Copy link
Contributor Author

AldoGl commented Dec 12, 2022

Yes I completely agree, it's something that I also thought I would do, but I wanted to do this in a different PR

@AldoGl
Copy link
Contributor Author

AldoGl commented Dec 12, 2022

Thank you for the review @marcofavoritobi

@AldoGl AldoGl merged commit 42669f8 into main Dec 12, 2022
@AldoGl AldoGl deleted the add-xgboost-sampler branch December 12, 2022 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants