To repair the error about classification

indices = crossvalind('Kfold',label,5);
cp=classperf(label);
for i = 1:5
test = (indices == i); train = ~test;
class =knnclassify(dim(test,:),dim(train,:),label(train,:),5,'euclidean', 'nearest');
classperf(cp,class,test)
end
cp.ErrorRate
The error:
Undefined function or variable 'label'.
Error in knn (line 1)
indices = crossvalind('Kfold',label,5);

 採用された回答

Star Strider
Star Strider 2021 年 3 月 23 日

0 投票

The ‘label’ variable must have been defined and must exist in your workspace before it is used as an argument to crossvalind.

7 件のコメント

Frisda Sianipar
Frisda Sianipar 2021 年 3 月 23 日
how to make it sir?
Frisda Sianipar
Frisda Sianipar 2021 年 3 月 23 日
label = ({'Nevus','Melanoma','Pigmented','Bacal'});
indices = crossvalind('Kfold',label,5);
cp=classperf(label);
for i = 1:5
test = (indices == i); train = ~test;
class =knnclassify(dim(test,:),dim(train,:),label(train,:),5,'euclidean', 'nearest');
classperf(cp,class,test)
end
cp.ErrorRate
After i change the code the error is change too:
Undefined function or variable 'dim'.
Error in knn (line 6)
class
=knnclassify(dim(test,:),dim(train,:),label(train,:),5,'euclidean',
'nearest');
Star Strider
Star Strider 2021 年 3 月 23 日
It wouild appear to be a new version of the same problem.
I cannot find documentation on knnclassify, since it was removed in R2017b, and replaced by fitcknn.
Frisda Sianipar
Frisda Sianipar 2021 年 3 月 23 日
so i should change dim to meas?
Star Strider
Star Strider 2021 年 3 月 23 日
I have no idea what either of them are, or what you are doing with them.
Use the one that works in your code, and gives the result you want.
Frisda Sianipar
Frisda Sianipar 2021 年 3 月 24 日
I want to randomly share the data using the code using k-fold cross validation
Star Strider
Star Strider 2021 年 3 月 24 日
I do not understand.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGenomics and Next Generation Sequencing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by