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!