You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i get the below issue. i think the reason might be when we are calculating the num_features=len(X[0]) it is causing error, should we use .iloc method to access the dataframe using index. But i am not sure. Help needed
/content/MLMethods/feature_selection/mRMR.py in fit(self, X, y, k)
377 # select random feature to start search
378 if self.score_func == 'MID':
--> 379 self.selected_indices = MID(X, y, k)
380 elif self.score_func == 'MIQ':
381 self.selected_indices = MIQ(X, y, k)
/content/MLMethods/feature_selection/mRMR.py in MID(X, y, k)
52 # mutual information difference
53 def MID(X, y, k):
---> 54 num_features = len(X[0])
55 start_feature_index = random.randint(0, num_features-1)
56 selected_indices = set()
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in getitem(self, key)
2900 if self.columns.nlevels > 1:
2901 return self._getitem_multilevel(key)
-> 2902 indexer = self.columns.get_loc(key)
2903 if is_integer(indexer):
2904 indexer = [indexer]
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2895 return self._engine.get_loc(casted_key)
2896 except KeyError as err:
-> 2897 raise KeyError(key) from err
2898
2899 if tolerance is not None:
KeyError: 0
The text was updated successfully, but these errors were encountered:
Hi, i tried using the mRMR selector as specified in the documentation
selector = mRMR(score_func='MIQ', k=10)
selector.fit(X, y)
X_transformed = selector.transform(X)
i get the below issue. i think the reason might be when we are calculating the num_features=len(X[0]) it is causing error, should we use .iloc method to access the dataframe using index. But i am not sure. Help needed
KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2894 try:
-> 2895 return self._engine.get_loc(casted_key)
2896 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 0
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
4 frames
in ()
---> 19 selector.fit(xtrain,ytrain)
20 X_transformed = selector.transform(df,3)
/content/MLMethods/feature_selection/mRMR.py in fit(self, X, y, k)
377 # select random feature to start search
378 if self.score_func == 'MID':
--> 379 self.selected_indices = MID(X, y, k)
380 elif self.score_func == 'MIQ':
381 self.selected_indices = MIQ(X, y, k)
/content/MLMethods/feature_selection/mRMR.py in MID(X, y, k)
52 # mutual information difference
53 def MID(X, y, k):
---> 54 num_features = len(X[0])
55 start_feature_index = random.randint(0, num_features-1)
56 selected_indices = set()
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in getitem(self, key)
2900 if self.columns.nlevels > 1:
2901 return self._getitem_multilevel(key)
-> 2902 indexer = self.columns.get_loc(key)
2903 if is_integer(indexer):
2904 indexer = [indexer]
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2895 return self._engine.get_loc(casted_key)
2896 except KeyError as err:
-> 2897 raise KeyError(key) from err
2898
2899 if tolerance is not None:
KeyError: 0
The text was updated successfully, but these errors were encountered: