Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Dealing with categorical features in machine learning | MATLAB

This concept is called One Hot Encoding :
It refers to splitting the column which contains numerical categorical data to many columns depending on the number of categories present in that column. Each column contains “0” or “1” corresponding to which column it has been placed.

%Code:

k=unique(Data.Purchased);
dummy_varibale=[];
variable=Data.Purchased;
for i=1:length(k)
    dummy_variable(:,i)=double(ismember(variable,k(i)));
end
k=cellstr(k);
rs=array2table(dummy_variable,'VariableNames',k);
Data=[Data rs];





Free program: https://www.matlabcoding.com Free Support: castorclasses2014@gmail.com Live Support: t.me/matlabirawen Like us: https://www.facebook.com/matlabirawen/ Join us: https://www.facebook.com/groups/MATLA... MATLAB Book for the beginner: https://amzn.to/3fTfmTa

No comments

Popular Posts