Is it possible , to use NaiveBayes.fit prediction with crossvalind

조회 수: 1 (최근 30일)
Subha
Subha 2013년 3월 10일
댓글: Narges J 2014년 9월 3일
Sir, with the given code i executed the program but it returns error.... i'm in need to calculate sensitivity and specificity also.. ... ??? Error using ==> subsindex Function 'subsindex' is not defined for values of class 'biolearning.classperformance'. .... so is it not possible for us to use crossvalind with NaiveBayes.fit?????? ...
load target
load data
GroupTrain=target;
TrainingSet=data;
Indices = crossvalind('Kfold', GroupTrain,10);
cp1 = classperf(GroupTrain)
for i = 1:10
test = (Indices == i); train = ~test;
Bayes_Model = NaiveBayes.fit(TrainingSet(train,:), GroupTrain(train,:), 'Distribution','kernel');
[Bayes_Predicted] = Bayes_Model.predict(data(test(cp1,1),:));
[conf, classorder] = confusionmat(target(test(c,1)),Bayes_Predicted);
classperf(cp1,Bayes_Model,test)
end
.. waiting for valuable suggestion...

채택된 답변

Tom Lane
Tom Lane 2013년 3월 10일
The error comes from this:
test(cp1,1)
You're using cp1 to index into the logical vector test. I suspect you want something like
data(test,:)
Then you may move on to the line where "c" is undefined, but perhaps you can take it from there.
  댓글 수: 2
Subha
Subha 2013년 3월 11일
Thanks a lot sir, now it works.. really helpful now i have another question too.. which i posed in http://www.mathworks.in/matlabcentral/answers/66440-how-to-implement-cross-validation-with-back-propogation-network
if i get answer for that too.. it will be really useful for me.. thanks ...
Narges J
Narges J 2014년 9월 3일
Hi,
I wrote the code like above and did modification but I received this error:
Error using classreg.learning.internal.DisallowVectorOps/subsref (line 16) You cannot index into an object of class NaiveBayes using () indexing.
Error in classperf (line 219) gps = varargin{1}(:);
Please can you help me how I can solve it.
Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Run Unit Tests에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by