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!