0
votes

Suppose nominal attribute is Outlook which contains three values Sunny , Overcast and Rainy. I want to convert this values of outlook attribute in numeric form i.e. 1,2,3 (order can be change). I saw one filter nominaltobinary in weka but this will create three columns. I don't want to create separate column for each value. How I can do this using Weka.

2
Why do you want to do that? - xro7
because some model will give error if input variable contains non-numeric values. - neha pawar
That is true but i think that applies for string attributes and not for nominal ones. I think nominal are converted to numbers internally. What model are you using? - xro7
but when I am loading this kind of data in Weka then some of the models will get disabled - neha pawar
What models are you using? - xro7

2 Answers

0
votes

In the ARFF, if you are using it, you can have a comment which specifies what the values of the "Outlook" attribute are.

For example, you ARFF can contain this comment at the top -

%% Numeric values for the "Outlook" Attribute
%%   Sunny = 1
%%   Overcast = 2
%%   Rainy = 3
%%   Windy = 4

Then you can define the attribute as -

@attribute Outlook {1,2,3,4}

I dont think there is a way to do this in the UI. But you can use a text editor to edit the ARFF itself.

0
votes

For this you can use "RenameNominalValues" filter under unsupervised ---> attributes.

Then under "selectedAttribute" type the attribute and

under "valueReplacements" type as Sunny:1,Overcast:2,Rainy:3,Windy:4

enter image description here