Why testing accuracy is 0.000?
1 回表示 (過去 30 日間)
古いコメントを表示
I am attaching the matlab code and input file. This code is not giving any error and running very smoothly. However, It is giving testing accuracy 0.000
Out-of-Bag Error: 0.0412
Out-of-Bag Classification Error: 0.6729
Training Accuracy: 0.9588
Testing Accuracy: 0.0000
is it okey or some problem in computing testing error?
please suggest me.
Sanchit
0 件のコメント
採用された回答
Aniketh
2023 年 7 月 9 日
Hi Sanchit,
It seems the problem in your code is in the respective datatypes of y_test.Var11 and y_pred.
To address this problem, let's examine the code and make the necessary corrections. In the original code, the line test_accuracy = sum(strcmp(y_pred, y_test.Var11)) / numel(y_test.Var11); is used to calculate the testing accuracy. However, based on the given information, it appears that y_test.Var11 contains numeric values, while y_pred contains cell arrays of strings.
y_test_str = cellfun(@num2str, num2cell(y_test.Var11), 'UniformOutput', false);
test_accuracy = sum(strcmp(y_pred, y_test_str)) / numel(y_test_str);
fprintf('Testing Accuracy: %.4f\n', test_accuracy);
With this change testing accuracy is being printed correctly, you could employ other methods as well to change the datatypes.
Hope this helped!
3 件のコメント
Aniketh
2023 年 7 月 10 日
You're welcome! I'm glad to hear that the solution worked for you.
An equivalent of mse can be done in MATLAB as:
y_train_pred = predict(rf_classifier, X_train);
oob_mse = mean((y_train - y_train_pred).^2);
For the sceond part can't say for sure without looking at the complete code but if you are evaluating on the same dataset that you used for training, it is possible the classifier has learned to predict the training data very well and you are getting a loss as 0.000
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!