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

39 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
figure;
montage(faceDatabase(1).ImageLocation);
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);
figure;
for i=1:size(faceDatabase,2)
imageList(i) = faceDatabase(i).ImageLocation(5);
end
subplot(1,2,1);imshow(galleryImage);
subplot(1,2,2);montage(imageList);
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]= ...
extractHOGFeatures(read(training(person),1));
figure;
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;
end
personIndex{i} = training(i).Description;
end
%%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)
classreg.learning.FullClassificationRegressionModel.prepareDataCR(...
Error in classreg.learning.FitTemplate/fit (line 213)
this.PrepareData(X,Y,this.BaseFitObjectArgs{:});
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
Saira
Saira el 11 de Mzo. de 2020
How can I solve this error?
Error:
Subscripted assignment dimension mismatch.
trainingLabel(featureCount,:) = TrainingimgSets(i).Description;
Thanks
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
mekia
mekia el 26 de Mzo. de 2020
Editada: mekia el 26 de Mzo. de 2020
first am down load data and replace all zero by blank then am done import by click on matlab import data button method from file location. is there any problem make blank the missing field and import to matlab.or else is there any other method that apply instead of these.
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
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)
validateTrainingData(trn_data);
  3 comentarios
mekia
mekia el 16 de Feb. de 2020
Editada: mekia el 16 de Feb. de 2020
Hope this will be helping me. thanks!
mekia
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by