TeamHG-Memex / eli5

A library for debugging/inspecting machine learning classifiers and explaining their predictions
http://eli5.readthedocs.io
MIT License
2.76k stars 334 forks source link

Compatibility with newer scikit learn version version: #275

Closed cesar-bonilla-olx closed 6 years ago

cesar-bonilla-olx commented 6 years ago

For example, working with XGBoost 0.8, and Scikit Learn 0.19.2 I've got errors from method def _check_booster_args(xgb,` `is_regression=None): because doesn't handle atribute xgb._Booster instead of call xbg.booster(). I will propose a PR for that

lopuhin commented 6 years ago

@cesar-bonilla-olx please also check the master branch, some issues you mention are already fixed, we didn't make a PyPI release with them yet.

cesar-bonilla-olx commented 6 years ago

Yes, sorry, now I see, is the same that I was going to propose, so good. Done!

cesar-bonilla-olx commented 6 years ago

There is another cool thing to add --> is_regression=False to avoid the problem of (None, False) in the _decision_path

def _check_booster_args(xgb, is_regression=False):
    # type: (Any, bool) -> Tuple[Booster, bool]
    if isinstance(xgb, Booster):
        booster = xgb
    else:
        if hasattr(xgb, 'get_booster'):
            booster = xgb.get_booster()
        else:  # xgb < 0.7
            booster = xgb.booster()
        _is_regression = isinstance(xgb, XGBRegressor)
        if is_regression is not None and is_regression != _is_regression:
            raise ValueError(
                'Inconsistent is_regression={} passed. '
                'You don\'t have to pass it when using scikit-learn API'
                .format(is_regression))
        is_regression = _is_regression
    return booster, is_regression