Getting Typeerror: '(slice(none, None, None), 0)' Is An Invalid Key
Trying to plot the decision Boundary of the k-NN Classifier but is unable to do so getting TypeError: '(slice(None, None, None), 0)' is an invalid key h = .01 # step size in the m
Solution 1:
Since you are trying to access directly as array, you are getting that issue. Try this:
from sklearn.impute importSimpleImputerimputer= SimpleImputer(missing_values = np.nan, strategy = 'mean',verbose=0)
imputer = imputer.fit(X.iloc[:, 1:3])
X.iloc[:, 1:3] = imputer.transform(X.iloc[:, 1:3])
Solution 2:
Solution 3:
I had the same issue with the following
X = dataset.iloc[:,:-1]
Then I added .values
property, after that it worked without problem
X = dataset.iloc[:,:-1].values
Solution 4:
I fixed it by converting the pandas dataframe to a numpy array. Got help from here
Solution 5:
When you are trying to fetch the dataset using pandas use the below code:
dataset = pd.read_csv("path or file name")
x = dataset.iloc[:,:-1].values
y = dataset.iloc[:,-1].values
Post a Comment for "Getting Typeerror: '(slice(none, None, None), 0)' Is An Invalid Key"