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
Error when executing MRMR - IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match)
#41
Hello, I'm with this error below when executing mrmr, however, as far as I searched here, this shows that X and y used have different shapes, and mine doesn't, is there a way to solve this error?
My data x the mrmr example(It's a matrix of 0s and 1s):
---------------------------------------------------------------------------_RemoteTracebackTraceback (mostrecentcalllast)
_RemoteTraceback:
"""Traceback (most recent call last): File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\externals\loky\process_executor.py", line 463, in _process_worker r = call_item() File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\externals\loky\process_executor.py", line 291, in __call__ return self.fn(*self.args, **self.kwargs) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 589, in __call__ return [func(*args, **kwargs) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 589, in <listcomp> return [func(*args, **kwargs) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py", line 31, in _f_classif return X.apply(lambda col: _f_classif_series(col, y)).fillna(0.0) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 9423, in apply return op.apply().__finalize__(self, method="apply") File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\apply.py", line 678, in apply return self.apply_standard() File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\apply.py", line 798, in apply_standard results, res_index = self.apply_series_generator() File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\apply.py", line 814, in apply_series_generator results[i] = self.f(v) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py", line 31, in <lambda> return X.apply(lambda col: _f_classif_series(col, y)).fillna(0.0) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py", line 29, in _f_classif_series return sklearn_f_classif(x[x_not_na].to_frame(), y[x_not_na])[0][0] File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\series.py", line 1029, in __getitem__ key = check_bool_indexer(self.index, key) File "C:\Users\vitor\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexing.py", line 2506, in check_bool_indexer raise IndexingError(pandas.errors.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match)."""Theaboveexceptionwasthedirectcauseofthefollowingexception:
IndexingErrorTraceback (mostrecentcalllast)
CellIn [54], line103# from sklearn.datasets import make_classification4# X, y = make_classification(n_samples = 1000, n_features = 50, n_informative = 10, n_redundant = 40)5# X = pd.DataFrame(X)6# y = pd.Series(y)78# select top 10 features using mRMR9frommrmrimportmrmr_classif--->10selected_features=mrmr_classif(X=X_dtm, y=y, K=10)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py:171, inmrmr_classif(X, y, K, relevance, redundancy, denominator, cat_features, cat_encoding, only_same_domain, return_scores, n_jobs, show_progress)
168relevance_args= {'X': X, 'y': y}
169redundancy_args= {'X': X}
-->171returnmrmr_base(K=K, relevance_func=relevance_func, redundancy_func=redundancy_func,
172relevance_args=relevance_args, redundancy_args=redundancy_args,
173denominator_func=denominator_func, only_same_domain=only_same_domain,
174return_scores=return_scores, show_progress=show_progress)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\main.py:98, inmrmr_base(K, relevance_func, redundancy_func, relevance_args, redundancy_args, denominator_func, only_same_domain, return_scores, show_progress)
44defmrmr_base(K, relevance_func, redundancy_func,
45relevance_args={}, redundancy_args={},
46denominator_func=np.mean, only_same_domain=False,
47return_scores=False, show_progress=True):
48"""General function for mRMR algorithm. 49 50 Parameters (...) 95 List of selected features. 96 """--->98relevance=relevance_func(**relevance_args)
99features=relevance[relevance.fillna(0) >0].index.to_list()
100relevance=relevance.loc[features]
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py:45, inf_classif(X, y, n_jobs)
44deff_classif(X, y, n_jobs):
--->45returnparallel_df(_f_classif, X, y, n_jobs=n_jobs)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\mrmr\pandas.py:17, inparallel_df(func, df, series, n_jobs)
15n_jobs=min(cpu_count(), len(df.columns)) ifn_jobs==-1elsemin(cpu_count(), n_jobs)
16col_chunks=np.array_split(range(len(df.columns)), n_jobs)
--->17lst=Parallel(n_jobs=n_jobs)(
18delayed(func)(df.iloc[:, col_chunk], series)
19forcol_chunkincol_chunks20 )
21returnpd.concat(lst)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:1952, inParallel.__call__(self, iterable)
1946# The first item from the output is blank, but it makes the interpreter1947# progress until it enters the Try/Except block of the generator and1948# reach the first `yield` statement. This starts the aynchronous1949# dispatch of the tasks to the workers.1950next(output)
->1952returnoutputifself.return_generatorelselist(output)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:1595, inParallel._get_outputs(self, iterator, pre_dispatch)
1592yield1594withself._backend.retrieval_context():
->1595yieldfromself._retrieve()
1597exceptGeneratorExit:
1598# The generator has been garbage collected before being fully1599# consumed. This aborts the remaining tasks if possible and warn1600# the user if necessary.1601self._exception=TrueFile~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:1699, inParallel._retrieve(self)
1692whileself._wait_retrieval():
16931694# If the callback thread of a worker has signaled that its task1695# triggered an exception, or if the retrieval loop has raised an1696# exception (e.g. `GeneratorExit`), exit the loop and surface the1697# worker traceback.1698ifself._aborting:
->1699self._raise_error_fast()
1700break1702# If the next job is not ready for retrieval yet, we just wait for1703# async callbacks to progress.File~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:1734, inParallel._raise_error_fast(self)
1730# If this error job exists, immediatly raise the error by1731# calling get_result. This job might not exists if abort has been1732# called directly or if the generator is gc'ed.1733iferror_jobisnotNone:
->1734error_job.get_result(self.timeout)
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:736, inBatchCompletionCallBack.get_result(self, timeout)
730backend=self.parallel._backend732ifbackend.supports_retrieve_callback:
733# We assume that the result has already been retrieved by the734# callback thread, and is stored internally. It's just waiting to735# be returned.-->736returnself._return_or_raise()
738# For other backends, the main thread needs to run the retrieval step.739try:
File~\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py:754, inBatchCompletionCallBack._return_or_raise(self)
752try:
753ifself.status==TASK_ERROR:
-->754raiseself._result755returnself._result756finally:
IndexingError: UnalignablebooleanSeriesprovidedasindexer (indexofthebooleanSeriesandoftheindexedobjectdonotmatch).
The text was updated successfully, but these errors were encountered:
Hello, I'm with this error below when executing mrmr, however, as far as I searched here, this shows that X and y used have different shapes, and mine doesn't, is there a way to solve this error?
My data x the mrmr example(It's a matrix of 0s and 1s):
The error when I execute with my data:
The text was updated successfully, but these errors were encountered: