Why do I get this error at the Classifier code line?? Please help

31 visualizaciones (últimos 30 días)
%%Load Image Information from ORL Face Database Directory
faceDatabase = imageSet('orl_faces','recursive');
%%Display Montage of First Face
% (faceDatabase(1) means pull out all images belong to folder 1
title('Images of Single Face');
Display Query Image and Database Side-Side
personToQuery = 1; % Call the a set of images at position 1
galleryImage = read(faceDatabase(personToQuery),1);
for i=1:size(faceDatabase,2)
imageList(i) = faceDatabase(i).ImageLocation(5);
diff = zeros(1,9);
%%Split Database into Training & Test Sets in the ratio 80% to 20%
[training,test] = partition(faceDatabase,[0.8 0.2]);
%%Extract and display Histogram of Oriented Gradient Features for single face
person = 5;
[hogFeature, visualization]= ...
subplot(2,1,1);imshow(read(training(person),1));title('Input Face');
subplot(2,1,2);plot(visualization);title('HoG Feature');
%%Extract HOG Features for training set
trainingFeatures = zeros(size(training,2)*training(1).Count,length(hogFeature));
featureCount = 1;
for i=1:size(training,2)
for j = 1:training(i).Count
trainingFeatures(featureCount,:) = extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount} = training(i).Description;
featureCount = featureCount + 1;
personIndex{i} = training(i).Description;
%%Create 40 class classifier using fitcecoc
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
Error message:
Error using classreg.learning.FullClassificationRegressionModel.prepareDataCR (line 210)
X and Y do not have the same number of observations.
Error in classreg.learning.classif.FullClassificationModel.prepareData (line 487)
Error in classreg.learning.FitTemplate/fit (line 213)
Error in ClassificationECOC.fit (line 116)
this = fit(temp,X,Y);
Error in fitcecoc (line 319)
obj = ClassificationECOC.fit(X,Y,ecocArgs{:});
Error in SimpleFaceRecognition (line 49)
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
  2 comentarios
Walter Roberson
Walter Roberson el 11 de Mzo. de 2020
TrainingimgSets(i).Description is unlikely to happen to be a column vector of character or numbers or string objects. The Description field of a dataset is usually some text that talks about the purpose or origin of the data set.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Abr. de 2018
The most common cause of this message for the classifiers is that you need to transpose the first parameter, X.
  36 comentarios
Walter Roberson
Walter Roberson el 26 de Mzo. de 2020
Error using fillmissing/checkConstantsSize (line 466)
Fill constant must be empty.
You get that error message when you pass in an empty array as the first parameter to fillmissing() and you use 'constant' and the constant is not empty.

Iniciar sesión para comentar.

Más respuestas (1)

mekia el 15 de Feb. de 2020
Editada: Walter Roberson el 16 de Feb. de 2020
load fsdmdata.mat
% x = inputs, t = targets, y = outputs
% Train the Network
[net, tr] = train(net, x, t);
% Training Confusion Plot Variables
yTrn = net(x(:,tr.trainInd));
tTrn = t(:,tr.trainInd);
% Validation Confusion Plot Variables
yVal = net(x(:,tr.valInd));
tVal = t(:,tr.valInd);
% Test Confusion Plot Variables
yTst = net(x(:,tr.testInd));
tTst = t(:,tr.testInd);
% Overall Confusion Plot Variables
yAll = net(x);
tAll = t;
% Plot Confusion
plotconfusion(tTrn, yTrn, 'Training', tVal, yVal, 'Validation', tTst, yTst, 'Test', tAll, yAll, 'Overall')
am new user for ANFIS so when runing the above code to do anfis confusion matrix by using train, valiation and test data then the following error display .any one are there to debugg this problem please.
Error using anfis>validateTrainin
gData (line 74)
Expected TrainingData to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Error in anfis (line 62)
  3 comentarios
mekia el 16 de Feb. de 2020
ANFIS structure button not active or not display neuro-fuzzy model design for training data. please suggest me the the solution if it is neccessary see my anfis toolbox GUI screen shot.

Iniciar sesión para comentar.


Más información sobre Standard State-Space Model en Help Center y File Exchange.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by