Creating numerical variables from categorical variables in an unbalanced dataset
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Grigorios Kyritsakas
am 12 Feb. 2020
Kommentiert: Grigorios Kyritsakas
am 17 Feb. 2020
Hello there,
I would like to apply Random Forrest method in a highly unbalanced dataset that includes both numerical and categoorical variables.In order to improve my classification results, before applying the method for classification I thought to create synthtic datasets using the SMOTE and the ADASYN algorithm. However, both methods work only with numerical variables, therefore, I would like to ask if you have any suggestion regarding the way to transform my categorical variables into numerical ones.
With many thanks in advance for your help
0 Kommentare
Akzeptierte Antwort
Lei Hou
am 14 Feb. 2020
Hi Grigorios,
You can do something as the following.
catVar = categorical(["a" "b" "c" "b" "a"]);
numValue = [0.1 3 100]; % The order of numbers refers to the order of categories returned by categories(catVar)
numVar = numValue(catVar)
Hoping my solution helpful to you.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Classification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!