Я сделал модель, но при создании матрицы путаницы я получаю некоторую ошибку.
код выглядит следующим образом:
from sklearn.utils import shuffle
data,Label = shuffle(A,label,random_state=2)
train_data = [data,Label]
#loading the dataset
X,Y = [train_data[0],train_data[1]]
#splitting into train and test set
X_train,X_test,Y_train,Y_test= train_test_split(X,Y,test_size=0.4,random_state
=4)
#splitting test into test and validation set
x_test,x_validation,y_test,y_validation=train_test_split(X_test,Y_test,test_size=0.5,random_state=4)
print (X_train.shape)
вывод:
(2266, 196608)
X_train = X_train.reshape((X_train.shape[0],256,256,3))
x_validation = x_validation.reshape((x_validation.shape[0],256,256,3))
x_test =x_test.reshape((x_test.shape[0],256,256,3))
X_train = X_train.astype('float32')
x_validation = x_validation.astype('float32')
x_test = x_test.astype('float32')
X_train=X_train/255
x_test = x_test / 255
x_validation = x_validation/255
Y_train = np_utils.to_categorical(Y_train,8)
y_validation = np_utils.to_categorical(y_validation,8)
y_test = np_utils.to_categorical(y_test,8)
print(y_test.shape)
(755, 8)
Затем я создал модель и нашел точность теста. Теперь при создании путаницы я получаю ошибку
print(confusion_matrix(y_test,folder))
Ошибка выглядит следующим образом:
ValueError Traceback (most recent call last)
<ipython-input-83-6d9d65ab1411> in <module>
----> 1 print(confusion_matrix(y_test,folder))
~\Anaconda3\lib\site-packages\sklearn\metrics\classification.py in confusion_matrix(y_true, y_pred, labels, sample_weight)
251
252 """
--> 253 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
254 if y_type not in ("binary", "multiclass"):
255 raise ValueError("%s is not supported" % y_type)
~\Anaconda3\lib\site-packages\sklearn\metrics\classification.py in _check_targets(y_true, y_pred)
69 y_pred : array or indicator matrix
70 """
---> 71 check_consistent_length(y_true, y_pred)
72 type_true = type_of_target(y_true)
73 type_pred = type_of_target(y_pred)
~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays)
203 if len(uniques) > 1:
204 raise ValueError("Found input variables with inconsistent numbers of"
--> 205 " samples: %r" % [int(l) for l in lengths])
206
207
ValueError: Found input variables with inconsistent numbers of samples: [755, 8]
, пожалуйста, помогите мне с этим