Repository navigation
Description
Describe the issue:
Previously with scikit-activeml 0.4.1 and Python 3.8, xgboost classes could be used with scikit-activeml. However, after updating to version 0.5.2 and Python 3.12, attempting to use an xgboost class results in a parsing error. This error is not a fatal syntax error that would kill the program when instantiating the SklearnClassifier object. Instead, when attempting to use the object, call clf.fit, etc., then the error is pitched.
Reproduce the bug via a code example:
import xgboost as xgb
from skactiveml.classifier import SklearnClassifier
xgbc = xgb.XGBClassifier()
clf = SklearnClassifier(xgbc, classes=[0, 1])
clfError message:
Error in generated code:
def fit(self, X: Any, y: Any, *, sample_weight: Optional[Any] = None, base_margin: Optional[Any] = None, eval_set: Optional[Sequence[Tuple[Any, Any]]] = None, verbose: Union[bool, int, NoneType] = True, xgb_model: Union[xgboost.core.Booster, str, xgboost.sklearn.XGBModel, NoneType] = None, sample_weight_eval_set: Optional[Sequence[Any]] = None, base_margin_eval_set: Optional[Sequence[Any]] = None, feature_weights: Optional[Any] = None) -> 'XGBClassifier):
pass
File <makefun-gen-4>:1
def fit(self, X: Any, y: Any, *, sample_weight: Optional[Any] = None, base_margin: Optional[Any] = None, eval_set: Optional[Sequence[Tuple[Any, Any]]] = None, verbose: Union[bool, int, NoneType] = True, xgb_model: Union[xgboost.core.Booster, str, xgboost.sklearn.XGBModel, NoneType] = None, sample_weight_eval_set: Optional[Sequence[Any]] = None, base_margin_eval_set: Optional[Sequence[Any]] = None, feature_weights: Optional[Any] = None) -> 'XGBClassifier):
^
SyntaxError: unterminated string literal (detected at line 1)
Error in generated code:
def fit(self, X: Any, y: Any, *, sample_weight: Optional[Any] = None, base_margin: Optional[Any] = None, eval_set: Optional[Sequence[Tuple[Any, Any]]] = None, verbose: Union[bool, int, NoneType] = True, xgb_model: Union[xgboost.core.Booster, str, xgboost.sklearn.XGBModel, NoneType] = None, sample_weight_eval_set: Optional[Sequence[Any]] = None, base_margin_eval_set: Optional[Sequence[Any]] = None, feature_weights: Optional[Any] = None) -> 'XGBClassifier):
pass
File <makefun-gen-5>:1
def fit(self, X: Any, y: Any, *, sample_weight: Optional[Any] = None, base_margin: Optional[Any] = None, eval_set: Optional[Sequence[Tuple[Any, Any]]] = None, verbose: Union[bool, int, NoneType] = True, xgb_model: Union[xgboost.core.Booster, str, xgboost.sklearn.XGBModel, NoneType] = None, sample_weight_eval_set: Optional[Sequence[Any]] = None, base_margin_eval_set: Optional[Sequence[Any]] = None, feature_weights: Optional[Any] = None) -> 'XGBClassifier):
^
SyntaxError: unterminated string literal (detected at line 1)Context for the issue:
No response
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]BUG: XGBoost Classes unusable with scikit-activeml 0.5.2[/-][+]BUG: XGBoost Classes unusable with scikit-activeml 0.5.2 and Python 3.12[/+]tpham93 commentedon Feb 6, 2025
Hi @perceptualJonathan
Thanks for bringing this issue to our awareness! We have changed the way how the signatures for wrapped functions are copied now, so type hints and references to non-native default values and types should work correctly now (see #482). The upcoming release should include this change.
If you want to try out the changes before the release, feel free to check out the following branch #481 branch.
To install it locally, change the version in
setup.pyand usepip -e <path to repo>.Here is the output for the #481 branch:
Output:
perceptualJonathan commentedon Feb 6, 2025
Super. Thanks.
mherde commentedon Apr 9, 2025
Hi @perceptualJonathan
We've just released
skactiveml 0.6.0, wherexgboostis supported according to the above example.