قسم الإعلام الآلي

https://www.univ-soukahras.dz/ar/dept/cs

المقياس: Apprentissage automatique II

  1. معلومات
  2. الأسئلة
  3. التعليم عن بعد

Given the following dataset in Matlab, find the different classes and number of instances

0 votes

Given the following dataset in Matlab, Write a function in Matlab to find the different classes and number of instances per class:

data=[
{'sunny'};
{'sunny'};
{'overcast'};
{'sunny'};
{'sunny'};
{'rain'};
{'sunny'};
{'rain'};
{'overcast'};
{'sunny'};
{'rain'};
{'rain'};
]

نشر على 11:12, الاثنين 18 نوفمبر 2019 By Imed BOUCHRIKA
In Apprentissage automatique II


أجوبة (1)




جواب (1)

0 votes

1/ the function

============================================

function [classes, instancesN] = findClasses(dataset)

m_map = containers.Map();

[rows, columns] = size(dataset);

for i=1:rows

     if m_map.isKey(dataset{i,1})

            m_map(dataset{i,1}) = m_map(dataset{i,1})+1;

     else

            m_map(dataset{i,1}) = 1;

     end

end

classes = m_map.keys();

instancesN = m_map.values();

for k=1:length(classes)
     x = classes{k};
     i = num2str(instancesN{k});
     strcat("Class: '",x,"' has: ",i," instance(s)")
end

=============================================

Execution:

test

 

نشر على 16:41, الاثنين 18 نوفمبر 2019 by abdennour redjaibia (282 points)
In Apprentissage automatique II



هل لديك جواب ?