Shapley based feature selection
이전 댓글 표시
Hello everyone, I am trying to perform Shapley based feature selection. I wrote the code below but I did not use the Ytest variable. Xtest does not contain the class labels; they are in the Ytest variable. I am a little confused. Am I doing something wrong? Thanks for the help.
DataSet = load('Seeds.txt');
[~,nFeatures] = size(DataSet);
X = DataSet(:,(1:nFeatures - 1));
Y = DataSet(:,nFeatures);
c = cvpartition(Y, 'Holdout', 0.20, 'Stratify', true);
Xtrain = X(training(c), :);
Xtest = X(test(c), :);
Ytrain = Y(training(c));
Ytest = Y(test(c));
Mdl = fitcecoc(Xtrain, Ytrain);
LimeRes = shapley(Mdl);
FitRes = fit(LimeRes, Xtest);
plot(FitRes)
댓글 수: 3
the cyclist
2025년 3월 1일
Can you upload the data? You can use the paper clip icon in the INSERT section of the toolbar.
MB
2025년 3월 2일
채택된 답변
추가 답변 (1개)
Walter Roberson
2025년 3월 2일
편집: Walter Roberson
2025년 3월 2일
YtestPred = predict(Mdl, Xtest);
test_accuracy = nnz(Ytest(:) == YtestPred(:)) / numel(Ytest) * 100;
fprintf('test accuracy: %.2f\n', test_accuracy);
카테고리
도움말 센터 및 File Exchange에서 MATLAB Mobile에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!