Skip to content

Strange behavior in: Example 7 -- Sequential Feature Selection and GridSearch #456

@defaultusername0

Description

@defaultusername0

I'm running the code from the tutorial http://rasbt.github.io/mlxtend/user_guide/feature_selection/SequentialFeatureSelector/#example-7-sequential-feature-selection-and-gridsearch

As in the example, I print the "best parameters" using:
print("Best parameters via GridSearch", gs.best_params_)_

However, the "best parameter" seems to change when changing the order of the values in the param_grid, e.g.:

[...]

param_grid = [
  {'sfs__k_features': [1, 2, 3, 4],
   'sfs__estimator__n_neighbors': [4, 3, 2, 1]} # order reversed
  ]

[...]

print("Best parameters via GridSearch", gs.best_params_)_

will yield

('Best parameters via GridSearch', {'sfs__k_features': 3, 'sfs__estimator__n_neighbors': 4})

instead of

('Best parameters via GridSearch', {'sfs__k_features': 3, 'sfs__estimator__n_neighbors': 1})

Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions