Is it possible , to use NaiveBayes.fit prediction with crossvalind
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Subha
el 10 de Mzo. de 2013
Comentada: Narges J
el 3 de Sept. de 2014
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...
0 comentarios
Respuesta aceptada
Tom Lane
el 10 de Mzo. de 2013
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 comentarios
Narges J
el 3 de Sept. de 2014
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!