简体   繁体   中英

Python-Weka-Wrapper3 removing attributes from arff file error

I have an arff file and I need to remove the first 5 attributes from it (without manually deleting them). I tried to use the Python-Weka-Wrapper3 as it is explained here which enables the filtering options of Weka, however I get an error while using the following code:

import weka.filters as Filter
remove = Filter(classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "1,2,3,4,5"])

The error that I receive is the following:

Traceback (most recent call last):
  File "/home/user/Desktop/file_loading.py", line 16, in <module>
    removing = Filter(classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "last"])
TypeError: 'module' object is not callable

What could be the reason for this error? Also I would appreciate if anyone knows an alternative way to remove attributes from an arff file using Python.

You are attempting to call the module object instead of the class object.

Try using:

from weka.filters import Filter
remove = Filter(classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "1,2,3,4,5"])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM