Skip to content
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

When using identify_collinear: too many indices for array: array is 1-dimensional, but 2 were indexed #63

Open
Dongdong-cHU opened this issue Sep 3, 2024 · 0 comments

Comments

@Dongdong-cHU
Copy link

too many indices for array: array is 1-dimensional, but 2 were indexed
How can I solve this problems?

When I am using this code

fs.identify_collinear(correlation_threshold=0.8)
correlated_features = fs.ops['collinear']
correlated_features

it turns out to be:

IndexError Traceback (most recent call last)
Cell In[107], line 1
----> 1 fs.identify_collinear(correlation_threshold=0.8)
2 correlated_features = fs.ops['collinear']
3 correlated_features

File ~/TMOF_ML/feature_selector.py:211, in FeatureSelector.identify_collinear(self, correlation_threshold, one_hot)
207 # Iterate through the columns to drop to record pairs of correlated features
208 for column in to_drop:
209
210 # Find the correlated features
--> 211 corr_features = list(upper.index[upper[column].abs() > correlation_threshold])
213 # Find the correlated values
214 corr_values = list(upper[column][upper[column].abs() > correlation_threshold])

File ~/.conda/envs/ML/lib/python3.8/site-packages/pandas/core/indexes/base.py:5196, in Index.getitem(self, key)
5193 else:
5194 key = np.asarray(key, dtype=bool)
-> 5196 result = getitem(key)
5197 # Because we ruled out integer above, we always get an arraylike here
5198 if result.ndim > 1:

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant