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
from sklearn.metrics import confusion_matrix
cm_KNN = confusion_matrix(y_test, y_pred)
print(cm_KNN)
print("Accuracy score of train KNN")
print(accuracy_score(y_train, trained_model.predict(X_train))*100)
print("Accuracy score of test KNN")
print(accuracy_score(y_test, y_pred)*100)
knn.append(accuracy_score(y_test, y_pred)*100)
plt.figure(figsize=(12, 6))
plt.plot(range(1, 21),knn, color='red', linestyle='dashed', marker='o',
markerfacecolor='blue', markersize=10)
plt.title('Accuracy for different K Value')
plt.xlabel('K Value')
plt.ylabel('Accuracy')
the error
ValueError Traceback (most recent call last)
in
11 plt.figure(figsize=(12, 6))
12 plt.plot(range(1, 21),knn, color='red', linestyle='dashed', marker='o',
---> 13 markerfacecolor='blue', markersize=10)
14 plt.title('Accuracy for different K Value')
15 plt.xlabel('K Value')
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2794 return gca().plot(
2795 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2796 is not None else {}), **kwargs)
2797
2798
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1663 """
1664 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
-> 1665 lines = [*self._get_lines(*args, data=data, **kwargs)]
1666 for line in lines:
1667 self.add_line(line)
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in call(self, *args, **kwargs)
223 this += args[0],
224 args = args[1:]
--> 225 yield from self._plot_args(this, kwargs)
226
227 def get_next_color(self):
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in _plot_args(self, tup, kwargs)
389 x, y = index_of(tup[-1])
390
--> 391 x, y = self._xy_from_xy(x, y)
392
393 if self.command == 'plot':
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in _xy_from_xy(self, x, y)
268 if x.shape[0] != y.shape[0]:
269 raise ValueError("x and y must have same first dimension, but "
--> 270 "have shapes {} and {}".format(x.shape, y.shape))
271 if x.ndim > 2 or y.ndim > 2:
272 raise ValueError("x and y can be no greater than 2-D, but have "
ValueError: x and y must have same first dimension, but have shapes (20,) and (3,)
pls help me
The text was updated successfully, but these errors were encountered:
Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
cm_KNN = confusion_matrix(y_test, y_pred)
print(cm_KNN)
print("Accuracy score of train KNN")
print(accuracy_score(y_train, trained_model.predict(X_train))*100)
print("Accuracy score of test KNN")
print(accuracy_score(y_test, y_pred)*100)
knn.append(accuracy_score(y_test, y_pred)*100)
plt.figure(figsize=(12, 6))
plt.plot(range(1, 21),knn, color='red', linestyle='dashed', marker='o',
markerfacecolor='blue', markersize=10)
plt.title('Accuracy for different K Value')
plt.xlabel('K Value')
plt.ylabel('Accuracy')
the error
ValueError Traceback (most recent call last)
in
11 plt.figure(figsize=(12, 6))
12 plt.plot(range(1, 21),knn, color='red', linestyle='dashed', marker='o',
---> 13 markerfacecolor='blue', markersize=10)
14 plt.title('Accuracy for different K Value')
15 plt.xlabel('K Value')
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2794 return gca().plot(
2795 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2796 is not None else {}), **kwargs)
2797
2798
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1663 """
1664 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
-> 1665 lines = [*self._get_lines(*args, data=data, **kwargs)]
1666 for line in lines:
1667 self.add_line(line)
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in call(self, *args, **kwargs)
223 this += args[0],
224 args = args[1:]
--> 225 yield from self._plot_args(this, kwargs)
226
227 def get_next_color(self):
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in _plot_args(self, tup, kwargs)
389 x, y = index_of(tup[-1])
390
--> 391 x, y = self._xy_from_xy(x, y)
392
393 if self.command == 'plot':
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py in _xy_from_xy(self, x, y)
268 if x.shape[0] != y.shape[0]:
269 raise ValueError("x and y must have same first dimension, but "
--> 270 "have shapes {} and {}".format(x.shape, y.shape))
271 if x.ndim > 2 or y.ndim > 2:
272 raise ValueError("x and y can be no greater than 2-D, but have "
ValueError: x and y must have same first dimension, but have shapes (20,) and (3,)
pls help me
The text was updated successfully, but these errors were encountered: