How to solve this error? Invalid types for comparison.

8 ビュー (過去 30 日間)
Bajdar Nouredine
Bajdar Nouredine 2022 年 12 月 30 日
コメント済み: Bajdar Nouredine 2023 年 1 月 3 日
I want to calculate accuracy, sensitivity,...,etc based on actual and predicted data, this code is working well for numbered labels but it gives this error for string labels.

採用された回答

Geoff Hayes
Geoff Hayes 2022 年 12 月 30 日
@Bajdar Nouredine - for string labels, I suspect that you need to use strcmp rather than == for checking to see if two strings are identical (if that is what you mean). You would probably want to check the type (i.e. use isstring) first (of the ACTUAL and PREDICTED arrays) to determine whether you need to use strcmp or ==.
  5 件のコメント
Geoff Hayes
Geoff Hayes 2022 年 12 月 31 日
@Bajdar Nouredine - the ACTUAL and PREDICTED seem to be categorical arrays. I suppose you could convert to string arrays and then compare the two like
idx = strcmp(string(ACTUAL), string(PREDICTED)');
I had to transpose the PREDICTED array so that both it and ACTUAL are 288x1. idx should reference those elements/indices that match in both arrays.
Bajdar Nouredine
Bajdar Nouredine 2023 年 1 月 3 日
thank you @Geoff Hayes

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by