You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Why do I get this error at the Classifier code line?? Please help
    5 views (last 30 days)
  
       Show older comments
    
%%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 Comments
  Saira
 on 11 Mar 2020
				How can I solve this error?
Error:
Subscripted assignment dimension mismatch.
trainingLabel(featureCount,:) = TrainingimgSets(i).Description;
Thanks
  Walter Roberson
      
      
 on 11 Mar 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.
Accepted Answer
  Walter Roberson
      
      
 on 2 Apr 2018
        The most common cause of this message for the classifiers is that you need to transpose the first parameter, X.
36 Comments
  Chidiebere Ike
 on 2 Apr 2018
				
      Edited: Walter Roberson
      
      
 on 2 Apr 2018
  
			Thanks Walter. I will appreciate if you kindly guide me on how to do this. I did transposed my first parameter trainingFeatures using the lines of code below but still got errors.
My error message reads:
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 50)
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
%%Create 40 class classifier using fitcecoc
trainingFeatures = trainingFeatures';
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
Thank you
  Chidiebere Ike
 on 3 Apr 2018
				
      Edited: Walter Roberson
      
      
 on 3 Apr 2018
  
			Thanks Walter for you assistance,
From my workspace, my trainingFeatures and trainingLabel are:
trainingFeatures : 700*8100 double
trainingLabel : 1*679 cell
I have attached a screenshot.
What are the likely solution to this errors ?
I will appreciate your response and suggestions.
Thank you
  mekia
 on 13 Feb 2020
				am also get  the same error message like above when am running  genetic algorithm for  feature selection on pima diabete.please any one have there to fix the broblem below
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 ClassificationKNN.prepareData (line 878)
                prepareData@classreg.learning.classif.FullClassificationModel(X,Y,varargin{:},'OrdinalIsCategorical',true);
Error in classreg.learning.FitTemplate/fit (line 213)
                    this.PrepareData(X,Y,this.BaseFitObjectArgs{:});
Error in ClassificationKNN.fit (line 863)
            this = fit(temp,X,Y);
Error in fitcknn (line 261)
    this = ClassificationKNN.fit(X,Y,RemainingArgs{:});
Error in jFitnessFunction>jwrapperKNN (line 20)
Model=fitcknn(feat,label,'NumNeighbors',k,'Distance','euclidean');
Error in jFitnessFunction (line 15)
fitness=jwrapperKNN(feat(:,X==1),label,k,kfold);
Error in jGA (line 39)
  fit(i)=fun(feat,label,X(i,:));
Error in Main (line 31)
[sFeat,Sf,Nf,curve]=jGA(feat,label,N,T,CR,MR);
  Walter Roberson
      
      
 on 13 Feb 2020
				You should probably use the debugger to figure out what sizes are being passed in.
The most common cause of this problem is accidentally passing in the transpose of the way the feature data is expected. Some routines that work with this kind of data need each column to correspond to a different feature, with the rows corresponding to different samples, but other routines need the rows to correspond to different features, with the columns corresponding to different samples. It is easy to make a mistake about this; I know that I get it wrong more than half the time myself.
  mekia
 on 14 Feb 2020
				thank you so much sir for your helpful assistance. you are t right am fix and get the solution.again thanks so much mr. walter.
  mekia
 on 12 Mar 2020
				any one having a matlab  code that  accept a new data from user and then testing  a machine learning trained model using user data please share me.
  Walter Roberson
      
      
 on 12 Mar 2020
				The machine learning functions do not care where the data came from, so this task can be divided into two parts, one of which is the user interface to get data from the user, and the second of which is invoking the machine learning routines on whatever data is present in memory.
There are different ways to interface with the the user to get data, depending on what you would like it to look like. For example you could put up a uitable and let the user fill out the entries. I would however suggest to you that users would quickly lose interest in typing in data, so an interface that permitted loading from file might be more appropriate.
  mekia
 on 17 Mar 2020
				thank you very much sir for your helpfull suggestion!i agree with your suggest that convince me.
  mekia
 on 17 Mar 2020
				please debug this code. am try to split  pima diabetes dataset with total of 768 into 538 instance for training set,115 for validation set and the rest 115 for test set but the below code cant split like that please help me i don no what is my mistake?
function data=LoadData()
    data=load('pima diabetes_dataset');
    Inputs=data.Inputs';
    Targets=data.Targets';
    Targets=Targets(:,1);
    nSample=size(Inputs,1);
    % Shuffle Data
    S=randperm(nSample);
    Inputs=Inputs(S,:);
    Targets=Targets(S,:);
    % Train Data
    pTrain=0.7;
    nTrain=round(pTrain*nSample);
    TrainInputs=Inputs(1:nTrain,:);
    TrainTargets=Targets(1:nTrain,:);
   % Validation Data
    pvalid=0.15;
    nvalid=round(pvalid*nSample);  
    ValInputs=Inputs(nvTrain+1:nvalid,:);
    ValTargets=Targets(nTrain+1:nvalid,:);
    % Test Data
    TestInputs=Inputs(nvalid+1:end,:);
    TestTargets=Targets(nvalid+1:end,:);
    % Export
    data.TrainInputs=TrainInputs;
    data.TrainTargets=TrainTargets;
    data.ValInputs=ValInputs;
    data.ValTargets=ValTargets;
    data.TestInputs=TestInputs;
    data.TestTargets=TestTargets;
end
  Walter Roberson
      
      
 on 18 Mar 2020
				    ValInputs=Inputs(nvTrain+1:nvalid,:);
nvTrain does not exist as a variable. I suspect you mean nTrain .
Corrected code:
   ValInputs = Inputs(nTrain+1:nTrain+nvalid,:);
   ValTargets = Targets(nTrain+1:nTrain+nvalid,:);
   % Test Data
   TestInputs = Inputs(nTrain+nvalid+1:end,:);
   TestTargets=Targets(nTrain+nvalid+1:end,:);
  mekia
 on 19 Mar 2020
				thanks so much sir. i get a solution. you are correcting my code thank you sir again!
  mekia
 on 19 Mar 2020
				am try to plot confusion matrix for adaptive neuro-fuzzy inference system(anfis). i want to call plotconfusions function in to main class but i cant afford it and the code below can run with out any result or i mean never stop running unless am pause run. here i attach both class(main.m & plotconfusions.m) please help me by debug these code.thank you for you help sir.
%main.m
clear;
close all;
%% Load Data
data=LoadData();
%% Generate Basic FIS
fis=CreateInitialFIS(data,10);
%% Results
% Train Data
TrainOutputs=evalfis(data.TrainInputs,fis);
PlotResults(data.TrainTargets,TrainOutputs,'Train Data');
plotconfusions(data.TrainTargets,TrainOutputs,'Train Data');
% Valid Data
ValOutputs=evalfis(data.ValInputs,fis);
PlotResults(data.ValTargets,ValOutputs,'Valid Data');
Plotconfusions(data.ValTargets,ValOutputs,'Test Data');
% Test Data
TestOutputs=evalfis(data.TestInputs,fis);
PlotResults(data.TestTargets,TestOutputs,'Test Data');
Plotconfusions(data.TestTargets,TestOutputs,'Test Data');
%overall Data
overallOutputs=evalfis(data.Inputs,fis);
PlotcResults(data.Targets,overallOutputs,'overall Data');
Plotconfusions(data.Targets,overallOutputs,'overall Data');
%plotconfusions.m
close all
clear variable
clc
function plotconfusion(tTrn, yTrn,tval,yval, tTst, yTst,tAll,yAll)
    data=load('dmdataset');
    Inputs=data.Inputs';
    Targets=data.Targets';
    Targets=Targets(:,1);
% Training Confusion Plot Variables
yTrn = data.TrainOutputs;
tTrn = data.TrainTargets;
%validation confusion plot variables
yval = data.ValOutputs;
tval = data.ValTargets;
% Test Confusion Plot Variables
yTst = data.TestsOutput;
tTst = data.TestTarget;
%all data Confusion Plot Variables
yAll = Inputs;
tAll = Targets;
end
  Walter Roberson
      
      
 on 19 Mar 2020
				plotconfusions(data.TrainTargets,TrainOutputs,'Train Data');
okay, that calls plotconfusions with three inputs
Plotconfusions(data.ValTargets,ValOutputs,'Test Data');
That is three inputs again, but that is Plotconfusions, with capital P, which is a different function than plotconfusions (lower-case P)
function plotconfusion(tTrn, yTrn,tval,yval, tTst, yTst,tAll,yAll)
but that is 8 inputs?
... none of which are used as inputs in the function ??
And no plotting is done??
  mekia
 on 20 Mar 2020
				still no plotting .i make both lower case and am changing the code like this:
clc;
clear;
close all;
%% Load Data
data=LoadData();
%% Generate Basic FIS
fis=CreateInitialFIS(data,10);
%% Results
% Train Data
TrainOutputs=evalfis(data.TrainInputs,fis);
PlotResults(data.TrainTargets,TrainOutputs,'Train Data');
Plotconfusions(data.TrainTargets,TrainOutputs,'Train Data');
% Valid Data
ValOutputs=evalfis(data.ValInputs,fis);
PlotResults(data.ValTargets,ValOutputs,'Valid Data');
Plotconfusions(data.ValTargets,ValOutputs,'valid Data');
% Test Data
TestOutputs=evalfis(data.TestInputs,fis);
plotResults(data.TestTargets,TestOutputs,'Test Data');
plotconfusions(data.TestTargets,TestOutputs,'Test Data');
% overall Data
overallOutputs=evalfis(data.Inputs,fis);
plotResults(data.Targets,overallOutputs,'overall Data');
plotconfusions(data.Targets,overallOutputs,'overall Data');
%plotconfusion.m
close all
clear variable
clc
function plotconfusion(Targets,Inputs,name)
    data=load('dmdataset');
% Training Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets = data.TrainTargets;
%validation confusion plot variables
Inputs=evalfis(data.ValInputs,fis);
Targets = data.ValTargets;
% Test Confusion Plot Variables
Inputs=evalfis(data.TestInputs,fis);
Targets = data.TestTarget;
%all data Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets=data.Targets;
end
  Walter Roberson
      
      
 on 20 Mar 2020
				Are you aware that in MATLAB, if you have a variable name in the input parameters section, the right hand side after the function name, and inside the function you assign a value to the (entire) variable, that the change has no effect on the calling function? Inside functions, any change you make to an entire variable is made only locally inside the function and discarded when the function returns.
Furthermore, the same thing happens if you modify part of a variable that is input, with one exception:
If you pass the handle to an object on input, and you modify a property of the handle object, then you do affect the calling environment. For example, if you pass gca() to a function and inside the function you change the XTicks property of the handle, then the change is made permanently to the graphics object. However this does not apply unless you are passed a handle: it does not apply if you are passed a struct for example.
Now reread your function definition and try to figure out why you are ignoring the data passed in, and you are assigning to local variables that you do nothing with, and especially you need to decide why your function is not plotting anything.
Also, you still have two calls to Plotconfusions with a capital P
  mekia
 on 21 Mar 2020
				i cant identify a logic behind the function call please sir  may i ask you kindly to make me correct the area that's cause error in assigning of  local and global variable when i create plotconfusion fuction.
  Walter Roberson
      
      
 on 21 Mar 2020
				
      Edited: Walter Roberson
      
      
 on 21 Mar 2020
  
			clc;
clear;
close all;
%% Load Data
data=LoadData();
%% Generate Basic FIS
fis=CreateInitialFIS(data,10);
%% Results
% Train Data
TrainOutputs=evalfis(data.TrainInputs,fis);
PlotResults(data.TrainTargets,TrainOutputs,'Train Data');
function_that_does_useless_things(data.TrainTargets,TrainOutputs,'Train Data');
% Valid Data
ValOutputs=evalfis(data.ValInputs,fis);
PlotResults(data.ValTargets,ValOutputs,'Valid Data');
function_that_does_useless_things(data.ValTargets,ValOutputs,'valid Data');
% Test Data
TestOutputs=evalfis(data.TestInputs,fis);
plotResults(data.TestTargets,TestOutputs,'Test Data');
function_that_does_useless_things(data.TestTargets,TestOutputs,'Test Data');
% overall Data
overallOutputs=evalfis(data.Inputs,fis);
plotResults(data.Targets,overallOutputs,'overall Data');
function_that_does_useless_things(data.Targets,overallOutputs,'overall Data');
%function_that_does_useless_things.m
%close all
%clear variable
%clc
function function_that_does_useless_things(Targets,Inputs,name)
    data=load('dmdataset');
% Training Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets = data.TrainTargets;
%validation confusion plot variables
Inputs=evalfis(data.ValInputs,fis);
Targets = data.ValTargets;
% Test Confusion Plot Variables
Inputs=evalfis(data.TestInputs,fis);
Targets = data.TestTarget;
%all data Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets=data.Targets;
end
  mekia
 on 21 Mar 2020
				is that possible sir  plotting confusion matrix for each of them( am mean for training ,for validation,for testing) in matlab? the  programming code available in mathlab help center  most of them  are done only in test-predicted.so that i can try  code with respect  to my work. here is the modifed code accourding to your comment.
%plotconfusion.m
close all
clear variable
clc
data=load('dmdataset');
Targets=data.Targets;%declare global variable 
Inputs=data.Inputs; 
% Training Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets = data.TrainTargets;
%validation confusion plot variables
Inputs=evalfis(data.ValInputs,fis);
Targets = data.ValTargets;
% Test Confusion Plot Variables
Inputs=evalfis(data.TestInputs,fis);
Targets = data.TestTarget;
%all data Confusion Plot Variables
Inputs=evalfis(data.TrainInputs,fis);
Targets=data.Targets;
function plotconfusion(Targets,Inputs,name)  
end
  mekia
 on 21 Mar 2020
				and also am modify main.m class depend on your coment.still not done
clc;
clear;
close all;
%% Load Data
data=LoadData();
%% Generate Basic FIS
fis=CreateInitialFIS(data,10);
%% Results
% Train Data
TrainOutputs=evalfis(data.TrainInputs,fis);
PlotResults(data.TrainTargets,TrainOutputs,'Train Data');
% Valid Data
ValOutputs=evalfis(data.ValInputs,fis);
PlotResults(data.ValTargets,ValOutputs,'Valid Data');
% Test Data
TestOutputs=evalfis(data.TestInputs,fis);
PlotResults(data.TestTargets,TestOutputs,'Test Data');
% overall Data
overallOutputs=evalfis(data.overallInputs,fis);
PlotResults(data.overallTargets,overallOutputs,'overall Data');
%plot confusion
plotconfusions(data.TrainTargets,TrainOutputs,'Train Data');
plotconfusions(data.ValTargets,ValOutputs,'valid Data');
plotconfusions(data.TestTargets,TestOutputs,'Test Data');
plotconfusions(data.overallTargets,overallOutputs,'overall Data');
  Walter Roberson
      
      
 on 21 Mar 2020
				function plotconfusions(Targets, Outputs, name)
  unique_classes = unique([Targets(:); Outputs(:)]);
  numclasses = length(unique_classes);
  for K = 1 : numclasses
      this_class = unique_classes(K);
      true_positive(K) = nnz(Targets == this_class & Outputs == this_class);
      false_positive(K) = nnz(Targets ~= this_class & Outputs == this_class);
      false_negative(K) = nnz(Targets == this_class & Outputs ~= this_class);
      true_negative(K) = nnz(Targets ~= this_class & Outputs ~= this_class);
  end
  %now that you have the statistics per class, do some plotting
  fig = figure();
  ax = axes('Parent', fig);
  x = 1 : numclasses;
  scatter(ax, x, true_positive, '+g');
  hold(ax, 'on');
  scatter(ax, x, true_negative, '-g');
  scatter(ax, x, false_positive, '^r');
  scatter(ax, x, false_negative, 'vr');
  hold(ax, 'off');
  xticks(ax, x);
  xticklabels(ax, unique_classes);
  title(name);
end
  mekia
 on 22 Mar 2020
				display  the below error message and also the plotting look like this:

Error using scatter (line 130)
There is no LineStyle property on the Scatter class.
Error in plotconfusions (line 17)
  scatter(ax, x, true_negative, '-g');
Error in main (line 32)
plotconfusions(data.TrainTargets,TrainOutputs,'Train Data');
>> plotconfusions
Not enough input arguments.
Error in plotconfusions (line 2)
  unique_classes = unique([Targets(:); Outputs(:)]);
  mekia
 on 22 Mar 2020
				my intension is do confusion matrix for example  just like neural network confusion matrix.

  Walter Roberson
      
      
 on 22 Mar 2020
				scatter(ax, x, true_negative, '-g');
Should be
scatter(ax, x, true_negative, '*g');
Your output seems to indicate that you have over 500 different classes??
I wonder if your outputs are control levels of some kind, rather than classifications? Confusion plots do not apply unless your outputs are class numbers that are either correct or incorrect. For example if you are trying to predict motor speed to use, then confusion matrix would only apply if the motor speed had to exactly right or else would be considered wrong; confusion matrix is not suitable for the case where the predicted motor speed is wrong by just a little and that is to be considered "close enough"
  mekia
 on 22 Mar 2020
				my class is binary class which encode in 0( mean healthy) or 1 (sick) therefore i have 500 healthy instance and 278 sick instace in pima diabetes dataset.when am train neural network using pima dataset then am getting result just like above posted confusion ploting, now am try to improve the 82% accuracy am using hybrid method called adaptive neuro-fuzzy inference system in the same dataset( pima diabetes dataset) but i can't get cofusion matrix just like that even now am  change scatter(ax, x, true_negative, '*g'); the result is the following.

  Walter Roberson
      
      
 on 22 Mar 2020
				plotconfusion with no final s is present in the Neural Network toolbox since r2008b. The classification functions you are using are from after that release.
Anyhow, see https://www.mathworks.com/matlabcentral/fileexchange/64185-plot-confusion-matrix
  mekia
 on 23 Mar 2020
				when am try to train anfis using dmpdataset  workspace with 2 variable (Inputs and Outputs) then the following error will be get at line of code 2 which say
Undefined function or variable 'dmpdataset'.
here is code  i cant find what my mistake at line 2 please if it possible debug line2 code.thank you for your help!
load dmpdataset;
fis = anfis(dmpdataset);
  Walter Roberson
      
      
 on 23 Mar 2020
				The only dmpdataset I find is
https://github.com/dbpedia/dataid/blob/master/dataid_to_datahub_mapper/DatahubDataidMappingService/OntologyObjectMapping/src/main/java/org/aksw/dataid/dmpExtension/DmpDataset.java
I have no reason to expect you would be able to load a dataset by that name in MATLAB
  Walter Roberson
      
      
 on 23 Mar 2020
				Try
load dmpdataset.dat;
Yes, there are big differences between mat and dat files.
  mekia
 on 25 Mar 2020
				am working preprocessing  using Pima datase (thttps://www.kaggle.com/kumargh/pimaindiansdiabetescsv) and also am using  class based mean preprocessing  method for each input variable  with respect to class( o or 1)and getting some error  such as:
Error using fillmissing/parseInputs (line 361)
Fill method must be 'constant', 'previous', 'next', 'nearest', 'linear', 'spline', 'pchip', 'movmean', or 'movmedian'.
Error in fillmissing (line 116)
[A,AisTable,intM,intConstOrWinSize,extM,x,dim,dataVars] = parseInputs(A,fillMethod,varargin{:});
Error in prep1 (line 4)
data.Pregnancies(class_1)=fillmissing(data.Pregnancies,(class_1),'constant',class_1_mean_Pregnancies); 
the code are  found in below please debug my mistake if you have a little bit time.thank you for kindly accept my request.  
with regard!
load ('pimadatapre.mat');
class_1=categorical(data.Outcome)=="o";
class_1_mean_Pregnancies = mean(data.Pregnancies(class_1), 'omitnan');
data.Pregnancies(class_1)=fillmissing(data.Pregnancies,(class_1),'constant',class_1_mean_Pregnancies);
class_2=categorical(data.Outcome)=="1";
class_2_mean_Pregnancies = mean(data.Gulcose(class_2), 'omitnan');
data.Pregnancies(class_2)=fillmissing(data.Gulcose,(class_2),'constant',class_2_mean_Pregnancies);
class_1=categorical(data.Outcome)=="o";
class_1_mean_Gulcose = mean(data.Gulcose(class_1), 'omitnan');
data.Gulcose(class_1)=fillmissing(data.Gulcose,(class_1),'constant',class_1_mean_Gulcose);
class_2=categorical(data.Outcome)=="1";
class_2_mean_Gulcose = mean(data.Gulcose(class_2), 'omitnan');
data.Gulcose(class_2)=fillmissing(data.Gulcose,(class_2),'constant',class_2_mean_Gulcose);
class_1=categorical(data.Outcome)=="o";
class_1_mean_BloodPressure = mean(data.BloodPressure(class_1), 'omitnan');
data.BloodPressure(class_1)=fillmissing(data.BloodPressure,(class_1),'constant',class_1_mean_BloodPressure);
class_2=categorical(data.Outcome)=="1";
class_2_mean_BloodPressure = mean(data.BloodPressure(class_2), 'omitnan');
data.BloodPressure(class_2)=fillmissing(data.BloodPressure,(class_2),'constant',class_2_mean_BloodPressure);
class_1=categorical(data.Outcome)=="o";
class_1_mean_SkinThickness = mean(data.BloodPressure(class_1), 'omitnan');
data.SkinThickness(class_1)=fillmissing(data.BloodPressure,(class_1),'constant',class_1_mean_SkinThickness);
class_2=categorical(data.Outcome)=="1";
class_2_mean_SkinThickness = mean(data.BloodPressure(class_2), 'omitnan');
data.SkinThickness(class_2)=fillmissing(data.BloodPressure,(class_2),'constant',class_2_mean_SkinThickness);
class_1=categorical(data.Outcome)=="o";
class_1_mean_BMI = mean(data.BMI(class_1), 'omitnan');
data.BMI(class_1)=fillmissing(data.BMI,(class_1),'constant',class_1_mean_BMI);
class_2=categorical(data.Outcome)=="1";
class_2_mean_BMI = mean(data.BMI(class_2), 'omitnan');
data.BMI(class_2)=fillmissing(data.BMI,(class_2),'constant',class_2_mean_BMI);
  Walter Roberson
      
      
 on 25 Mar 2020
				data.Pregnancies(class_1)=fillmissing(data.Pregnancies,(class_1),'constant',class_1_mean_Pregnancies);
has an extra comma.
data.Pregnancies(class_1)=fillmissing(data.Pregnancies(class_1),'constant',class_1_mean_Pregnancies);
  mekia
 on 26 Mar 2020
				but till now display the following error:
Error using fillmissing/checkConstantsSize (line 466)
Fill constant must be empty.
Error in fillmissing/parseInputs (line 444)
    intConstOrWindowSize = checkConstantsSize(A,AisTable,false,intConstOrWindowSize,dim,dataVars,'');
Error in fillmissing (line 116)
[A,AisTable,intM,intConstOrWinSize,extM,x,dim,dataVars] = parseInputs(A,fillMethod,varargin{:});
  mekia
 on 26 Mar 2020
				
      Edited: mekia
 on 26 Mar 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
      
      
 on 26 Mar 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.
More Answers (1)
  mekia
 on 15 Feb 2020
        
      Edited: Walter Roberson
      
      
 on 16 Feb 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 Comments
  Walter Roberson
      
      
 on 15 Feb 2020
				
      Edited: Walter Roberson
      
      
 on 15 Feb 2020
  
			What is class(x) and class(t) ?
Note that routine cannot handle categorical data or cell array of character vectors or string array.
  mekia
 on 16 Feb 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.

See Also
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)



