shapiq_benchmark.setups.FeatureSelectionSetup¶
- class shapiq_benchmark.setups.FeatureSelectionSetup(*, dataset, random_state=42, dataset_params=<factory>, test_size=0.2, model='decision_tree', preset=None, model_params=<factory>, metric=None, n_train=None, normalize=True)[source]¶
Bases:
ModelSetupA
FeatureSelectiongame: a model retrained on feature subsets.- Variables:
model – The model name. Defaults to
"decision_tree".metric – The metric name, or
Nonefor the default of the task.n_train – Use a seeded subset of this many training rows (
Nonefor all).normalize – Whether to center the game. Defaults to
True.
Examples
>>> FeatureSelectionSetup(dataset="breast_cancer", n_train=100).build().n_players 30
- build()[source]¶
Build the game with the unfitted model; the game trains it per coalition.
- Return type:
- estimator(task, **overrides)¶
Return the unfitted, seeded model for a task.
- Parameters:
task (
Task) –"classification"or"regression".**overrides (
Any) – Hyperparameters overridingmodel_params.
- Return type:
- load_split()¶
Load the dataset and split it (seeded, stratified for classification).
- Return type:
- sample_rows(n_rows, n)¶
Return
nsorted row indices out ofn_rows, drawn withrandom_state.All rows are returned if
nisNoneor at leastn_rows.- Return type:
- stratified_rows(y, n, task)¶
Return
nsorted row indices, drawn withrandom_stateand stratified by class.The rows are stratified for classification where every class has enough rows. All rows are returned if
nisNoneor at least the number of rows.- Return type:
GenericAlias[integer]
- to_dict()¶
Return the setup as a JSON-serializable dictionary (the inverse of
setup_from_dict()).
- dataset¶
- dataset_params¶
- property key¶
A stable identifier of the game this setup builds, used as its cache key.
It is a digest of the setup’s name,
version,RECIPE_VERSION, and fields (runtime fields excluded), so it is the same across processes and machines.
- metric = None¶
- model = 'decision_tree'¶
- model_params¶
- n_train = None¶
- name = 'feature_selection'¶
The registered name of the setup.
- normalize = True¶
- preset = None¶
- random_state = 42¶
- tasks = ('classification', 'regression')¶
The tasks of the datasets the setup accepts.
- test_size = 0.2¶