split data by classes

2 ビュー (過去 30 日間)
sun rise
sun rise 2021 年 10 月 13 日
回答済み: Simran 2025 年 2 月 26 日
Hello everyone .I want code split data in two class based on the Excel file ,where 01 and oo non_melanoma and 1 0 melanoma . I work in skin cancer detection. Please if any one have the code of split data in two class send it to me

回答 (1 件)

Simran
Simran 2025 年 2 月 26 日
I see you that you want to split your existing excel data into two classes, non_malenoma for “01’ and “00” and melanoma for “10”.
To do so you can use the “strcmp” function which is used to compare strings.
The following steps will help you:
1.) Read data from your Excel file, say named “skin_cancer_data.xlsx” with preserved column names.
filename = 'skin_cancer_data.xlsx';
data = readtable(filename, 'VariableNamingRule', 'preserve');
2.) Then display column names for verification and check unique labels.
3.)Then use tis code script to split your data into two classes “non_malenoma” and “malenoma”:
non_melanoma_data = data(strcmp(labels, '01') | strcmp(labels, '00'), :);
melanoma_data = data(strcmp(labels, '10'), :);
4.) You can also save the split data into separate Excel files for verification using the “writetable” function.
You can refer to the following documentation for more help:
readtable”-
writetable”-

カテゴリ

Help Center および File ExchangeBiotech and Pharmaceutical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by