RWeka filter ReplaceMissingValues not working

134 Views Asked by At

i'm currently trying some exploration with Weka from R using RWeka. I'm trying to replace some missing values (that i intentionally added) with the ReplaceMissingValues unsupervised filter, but when i apply it only a portion of the dataframe comes back, in this case, only 27 records.

This is the code i'm using

data<-select(iris,Species,everything())

#ADDING THE MISSING VALUES
miss<-make_Weka_filter("weka.filters.unsupervised.attribute.ReplaceWithMissingValue")
data.miss<-miss(data,control=Weka_control(P=.3)) %>% select(Species,everything())

#REPLACING BY MEAN
found<-make_Weka_filter("weka.filters.unsupervised.attribute.ReplaceMissingValues")
data.found<-found(data.miss)

nrow(data)
nrow(data.miss)
nrow(data.found)

Any ideas here?

1

There are 1 best solutions below

0
On

I checked with the package maintainer on this.

It is a bug, but there is a workaround, the filter is ignoring the missing values (something strange for this particular filter), for it to get the full dataframe you can do the following

found<-make_Weka_filter("weka.filters.unsupervised.attribute.ReplaceMissingValues")
data.found<-found(data.miss,na.action=na.pass)