TypeError: '(slice(None, None, None), slice(None, None, None))' is an invalid key
See original GitHub issueI’m facing mentioned issue. I initially thought the issue is due to version of python I was using i.e python3, but I tried to used it with python2, the same error pops up.
clf = RandomForestClassifier(n_estimators=50, max_depth=5, random_state=0, n_jobs=3)
clf.fit(X_train,y_train)
predict_fn_rf = lambda x : clf.predict_proba(X_test).astype(float)
explainer = lime.lime_tabular.LimeTabularExplainer(X_train[:,:])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-c2cd4dda4439> in <module>()
----> 1 explainer = lime.lime_tabular.LimeTabularExplainer(X_train[:,:])
/home/crisp/cnn/local/lib/python2.7/site-packages/pandas/core/frame.pyc in __getitem__(self, key)
2925 if self.columns.nlevels > 1:
2926 return self._getitem_multilevel(key)
-> 2927 indexer = self.columns.get_loc(key)
2928 if is_integer(indexer):
2929 indexer = [indexer]
/home/crisp/cnn/local/lib/python2.7/site-packages/pandas/core/indexes/base.pyc in get_loc(self, key, method, tolerance)
2654 'backfill or nearest lookups')
2655 try:
-> 2656 return self._engine.get_loc(key)
2657 except KeyError:
2658 return self._engine.get_loc(self._maybe_cast_indexer(key))
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '(slice(None, None, None), slice(None, None, None))' is an invalid key](url)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:8
Top Results From Across the Web
Getting TypeError: '(slice(None, None, None), 0)' is an invalid ...
Since you are trying to access directly as array, you are getting that issue. Try this: from sklearn.impute import SimpleImputer imputer ...
Read more >TypeError: '(slice(None, None, None), 0)' is an invalid key
TypeError : '(slice(None, None, None), 0)' is an invalid key. arrow_drop_up 0. I got this error, when i was using from matplotlib.color import...
Read more >TypeError: '(slice(None, None, None), 0)' is an invalid key
TypeError : '(slice(None, None, None), 0)' is an invalid key. Do not use DataFrame with LIME. Convert it to a numpy array first....
Read more >What does (slice (None),None) mean in Python? - Quora
So slice(None) is adding "::", and the None as the last element in tup is adding a new axis, to transpose the result...
Read more >Getting az.compare to work in 4.2.0 - v4 - PyMC Discourse
IndexEngine.get_loc() TypeError: 'slice(None, None, None)' is an invalid key During handling of the above exception, another exception ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
X_train is a Pandas DataFrame. In Pandas you can use X_train.iloc[:,:] and that fixes the issue, but I think it is the same as X_train without any indexing. If you would like to get the Numpy array from a Pandas DataFrame you can use X_train.values . In this case you again can use your type of indexing like X_train.values[:,:]
I think it does not depend on Python version.
Hi @WetzlerkAI, I changed my input to a numpy array instead and it worked. I have still not been able to sort this issue with a Pandas dataframe input. If it is urgent in your case, I suggest changing your input to numpy and moving ahead.