I keep getting a warning and poor classification using fitcecoc.
8 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm wondering if anyone may be able to help with a problem I'm having in classifiying some data?
I'm trying to classify a predictor which is a 4 x 154 double array against a response which is a 80 x 1 double array.
I'm very new to using the machine learning tools and have been trying to follow examples, but get the warning (see below), I'm struggling to see the problem. I wondered if anyone may be able to help or if this is even the best way of classifying data in this format?
Kind regards,
Andy
I'm using the following code:
%Create a classifier that takes as input the condition indicators and returns the combined fault flag.
%Train a support vector machine that uses a 2nd order polynomial kernel.
%Use the cvpartition command to partition the ensemble members into a set for training and a set for validation.
rng('default') % for reproducibility
predictors = scTrain(:,:);
response = data.CombinedFlag;
cvp = cvpartition(size(predictors,1),'KFold',5);
% Create and train the classifier
template = templateSVM(...
'KernelFunction', 'polynomial', ...
'PolynomialOrder', 2, ...
'KernelScale', 'auto', ...
'BoxConstraint', 1, ...
'Standardize', true);
combinedClassifier = fitcecoc(...
predictors(cvp.training(1),:), ...
response(cvp.training(1),:), ...
'Learners', template, ...
'Coding', 'onevsone', ...
'ClassNames', [0; 1; 2; 3; 4; 5; 6; 7]);
% Check performance by computing and plotting the confusion matrix
actualValue = response(cvp.test(1),:);
predictedValue = predict(combinedClassifier, predictors(cvp.test(1),:));
confdata = confusionmat(actualValue,predictedValue);
figure,
labels = {'None','Capacitor','Thermal','Bondwire','Bondwire & Capacitor', ...
'Thermal & Bondwire','Thermal & Capacitor','All'};
h = heatmap(confdata,...
'YLabel', 'Actual IGBT fault', ...
'YDisplayLabels', labels, ...
'XLabel', 'Predicted IGBT fault', ...
'XDisplayLabels', labels, ...
'ColorbarVisible','off');
However, I keep getting the following warning for each learner which in turn leads to no classes being classified.
Warning: The number of folds K is greater than the number of observations N. K will be set to the
value of N.
> In internal.stats.cvpartitionInMemoryImpl (line 158)
In cvpartition (line 175)
In Boost_DT (line 206)
Warning: Unable to fit learner 1 (SVM) because: No class names are found in input labels.
> In ClassificationECOC>localFitECOC/loopBody (line 647)
In internal.stats.parallel.smartForSliceout (line 174)
In ClassificationECOC>localFitECOC (line 571)
In ClassificationECOC (line 171)
In classreg.learning/FitTemplate/fit (line 263)
In ClassificationECOC.fit (line 116)
In fitcecoc (line 356)
In Boost_DT (line 215)
0 件のコメント
採用された回答
Prince Kumar
2022 年 3 月 31 日
Hi,
Please have a look at your data first, it seems you data is not in correct format.
You are having 4 x 154 double array, it means you have 4 data point of 154 dimension each. But you are trying to do 5-fold validation.
Hope this helps!
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Classification Ensembles についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!