Closed jishaaugustine closed 12 months ago
Hi @jishaaugustine ,
Could you please check the version of Mealpy library you are using?. Make sure that you are using Mealpy version 2.5.4. You can install it in colab by this command:
!pip install mealpy==2.5.4
The latest version of Mealpy 3.0.1 is not compatible with mafese. I will update Mafese to fit with latest version of Mealpy soon.
Its working!! Thanks
While executing the following code in colab
from mafese.wrapper.mha import MhaSelector from mafese import get_dataset
data = get_dataset("Arrhythmia") data.split_train_test(test_size=0.2) print(data.X_train.shape, data.X_test.shape) # (361, 279) (91, 279)
define mafese feature selection method
feat_selector = MhaSelector(problem="classification", estimator="knn", optimizer="BaseGA", optimizer_paras=None, transfer_func="vstf_01", obj_name="AS")
find all relevant features
feat_selector.fit(data.X_train, data.y_train, fit_weights=(0.9, 0.1), verbose=True)
check selected features - True (or 1) is selected, False (or 0) is not selected
print(feat_selector.selected_feature_masks) print(feat_selector.selected_feature_solution)
check the index of selected features
print(feat_selector.selected_feature_indexes)
call transform() on X to filter it down to selected features
X_train_selected = feat_selector.transform(data.X_train) X_test_selected = feat_selector.transform(data.X_test)
I am getting the following error
Requested CLASSIFICATION dataset: Arrhythmia found and loaded! (361, 279) (91, 279)
TypeError Traceback (most recent call last)
1 frames
/usr/local/lib/python3.10/dist-packages/mafese/utils/mealpy_util.py in init(self, lb, ub, minmax, data, estimator, transfer_func, obj_name, metric_class, fit_weights, fit_sign, obj_paras, name, kwargs) 25 self.obj_paras = obj_paras 26 self.name = name ---> 27 super().init(lb, ub, minmax, kwargs) 28 29 def amend_position(self, position=None, lb=None, ub=None):
TypeError: Problem.init() takes from 2 to 3 positional arguments but 4 were given
This is only for MhaSelector, MultiMhaSelector