AttributeError: 'numpy.ndarray' object has no attribute 'columns'
See original GitHub issueThis looks amazing but I can’t run it on my dataset. I get the following error:
runfile('E:/Machine Learning Projects/ML UFC/genetic_algorithm_cluster_UFC_database_TPOT.py', wdir='E:/Machine Learning Projects/ML UFC')
Traceback (most recent call last):
File "E:\Machine Learning Projects\ML UFC\genetic_algorithm_cluster_UFC_database_TPOT.py", line 533, in <module>
ExplainerDashboard(ClassifierExplainer(RandomForestClassifier().fit(X_train, y_train), X_test, y_test)).run()
File "C:\Users\apavl\anaconda3\envs\neuro\lib\site-packages\explainerdashboard\explainers.py", line 1774, in __init__
super().__init__(model, X, y, permutation_metric,
File "C:\Users\apavl\anaconda3\envs\neuro\lib\site-packages\explainerdashboard\explainers.py", line 149, in __init__
self.onehot_cols, self.onehot_dict = parse_cats(self.X, cats)
File "C:\Users\apavl\anaconda3\envs\neuro\lib\site-packages\explainerdashboard\explainer_methods.py", line 103, in parse_cats
all_cols = X.columns
AttributeError: 'numpy.ndarray' object has no attribute 'columns'
Any idea why that is?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
AttributeError: 'numpy.ndarray' object has no attribute 'columns'
The problem is that train_test_split(X, y, ...) returns numpy arrays and not pandas dataframes. Numpy arrays have no attribute named columns.
Read more >AttributeError: 'numpy.ndarray' object has no attribute 'columns'
I'm trying to create a function to remove the features that are highly correlated with each other. However, I am getting the error...
Read more >[Code]-'numpy.ndarray' object has no attribute 'columns'-pandas
'numpy.ndarray' object has no attribute 'columns'. Here is a portion of my code : import pandas as pd import numpy as np import...
Read more >How to Fix: 'numpy.ndarray' object has no attribute 'index'
'numpy.ndarray' object has no attribute 'index' is an attribute error which indicates that there is no index method or attribute available ...
Read more >numpy.ndarray' object has no attribute 'columns' - You.com
Numpy arrays have no attribute named columns. If you want to see what features SelectFromModel kept, you need to substitute X_train (which is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @apavlo89, I agree that it would be cool to support sklearn pipelines and I’ve tried to get them to work, but the problem is with how they are internally structured: the stages of the pipeline forward numpy arrays instead of dataframes, and it doesn’t track what the newly generated features should be called.
There is a proposed fix for this with here: https://scikit-learn-enhancement-proposals.readthedocs.io/en/latest/slep007/proposal.html
Given that the dashboard needs to know the names of the features in order to give meaningful importance and dependence plots, that means that until that proposal is implemented it will only accept pipelines that do not add or remove any columns.
def vif_score(x): sc = StandardScaler() arr = sc.fit_transform(x) return pd.DataFrame([[x.columns[i] , variance_inflation_factor(arr , i)] for i in range(arr.shape[1])] , columns = [‘Features’ , ‘VIF’])
I am trying to run this function … earlier it worked fine , but don’t know what’s the issue , it shows the error “‘numpy.ndarray’ object has no attribute ‘columns’”.