How do I relabel classes into one sub group?

1 回表示 (過去 30 日間)
tinkiewinkie
tinkiewinkie 2020 年 2 月 11 日
編集済み: Adam Danz 2020 年 2 月 12 日
Suppose I have 3 different classes below, how to I relabel 'versicolor' and 'virginica' into another class named 'abnormal' temporary because I want to do classification for 'setosa' and 'abnormal' using fitcsvm function first and later I will need to relabel the class again for another fitcsvm classifcation model.
Screenshot 2020-02-12 at 12.46.58 AM.png

採用された回答

Adam Danz
Adam Danz 2020 年 2 月 11 日
編集済み: Adam Danz 2020 年 2 月 11 日
load fisheriris
idx = ~ismember(species, 'setosa');
species(idx) = {'abnormal'};
  2 件のコメント
tinkiewinkie
tinkiewinkie 2020 年 2 月 11 日
Thanks it work well, and is there any command that I can use in the later part of the algorithm to revert back to the orginal class? For example from 'abormal' back to 'versicolor' and 'virginica' and relabel 'virginica' and 'setosa' as 'abnormal2'?
Adam Danz
Adam Danz 2020 年 2 月 11 日
編集済み: Adam Danz 2020 年 2 月 12 日
I would just make a copy of the species array so you don't lose that data. You can change the ismember() inputs as needed. For example,
idx = ~ismember(species, {'virginica','setosa'});

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Classification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by