0
$\begingroup$

I am trying to do some classification tasks on mixed data set (Hepatitis data set)from UCI ,I will apply SVM and Naive Bayes in R & WEKA, both of them can not handle mixed data directly. Naive Bayes for example deals with categorical data only, in this case I need to convert numerical to nominal for Naive Bayes ,or dummy the variables for SVM, I am not sure if I am dong the correct steps or no , does any body has any idea how can the two algorithms deal with such data?

$\endgroup$
1
$\begingroup$

For categorical attributes, we need some coding scheme to convert data frame to data matrix. Here is a good reference on coding schemes.

R LIBRARY CONTRAST CODING SYSTEMS FOR CATEGORICAL VARIABLES

In R, we can easily do it by model.matrix function. Here is an example on IRIS data

> head(model.matrix(~.,iris))
  (Intercept) Sepal.Length Sepal.Width Petal.Length Petal.Width Speciesversicolor Speciesvirginica
1           1          5.1         3.5          1.4         0.2                 0                0
2           1          4.9         3.0          1.4         0.2                 0                0
3           1          4.7         3.2          1.3         0.2                 0                0
4           1          4.6         3.1          1.5         0.2                 0                0
5           1          5.0         3.6          1.4         0.2                 0                0
6           1          5.4         3.9          1.7         0.4                 0                0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.