-
Notifications
You must be signed in to change notification settings - Fork 335
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
Returning an empty subset as the best subset for feature selection #110
Comments
Hi @ahcantao , sorry for the late reply. Let me check on this real quick this weekend. Thanks for reporting! |
@ljvmiranda921 Check if it is possible to avoid the creation of a subset containing only zeros. If this is possible, as a future update, you can add an extra parameter asking for the minimum quantity of 1's in the subset. Ex: minOnes = 3. Will return a subset containing 3 or more attributes out of the full set ([1 1 1 0 0 0 0 0 0 0]. |
Thanks for your input, I'm currently in the process of updating PySwarms' backend (in |
Note to self: make another PR to test this. This should be solved using the new backend implementation but further testing is needed. |
Add pyswarms.backend module This commit adds the `backend` module for PySwarms. It enables users to define their own optimization loop using primitives provided by this module (white-box approach). In addition, this commit also updates the existing implementations of GlobalBestPSO, LocalBestPSO, and BinaryPSO to use these backend primitives. Some major updates: 1. Topologies are introduced to segregate computation of best_cost/pos and velocity or position updates. 2. A Swarms class is implemented to serve as a DataClass for data storage. 3. SwarmBase is now called SwarmOptimizer (more semantically meaningful) 4. The user can now set his/her initial positions. 5. Remove py27 compatibility Additional tasks: 1. Documentation and new notebook examples 2. Check feature selection example (#110 ) Signed-off-by: Lester James V. Miranda <[email protected]>
This should be solved by #145 |
I am still facing the error for best subset for feature selection. Perform optimizationcost, pos = optimizer.optimize(f,iters=700, fast=False)
|
Description
The code is returning an empty subset of attributes as the best subset selection. It is even returning the cost of the subset with only zeros. Even with a minor change on the exemple code it is possible to replicate this output.
There is a checking condition on the code to avoid empty subsets but it still outputs empty as the best subset.
if np.count_nonzero(m) == 0:
#if the particle subset is only zeros, get the original set of attributes
X_subset = X
Describe what you were trying to get done.
Return a non-empty subset of attributes (a binary list containing at least one element 1)
What I Did
I ran the "feature_subset_selection" notebook (https://github.com/ljvmiranda921/pyswarms/blob/master/examples/feature_subset_selection.ipynb) up to the # Perform optimization point. It all runs ok, but when I do a minor change, just on the number of iterations from 1000 to 10, it most of the times return an empty subset as the best subset.
The only line changed was the following:
and the output was:
The text was updated successfully, but these errors were encountered: