简体   繁体   中英

How to use regression in python-weka-wrapper?

I would like to implement regression algorithms using python-weka-wrapper in Jupyter Notebook. However, I couldn't find the correct function in https://fracpete.github.io/python-weka-wrapper/api.html#classifiers

Does someone know how to implement it?

In the olden days, Weka distinguished between classification and regression algorithms, but that got dropped in favor of just a single super class.

The capabilities of a weka.classifiers.Classifier determine what types of attributes and class attributes an algorithm can handle. Some algorithms, like RandomForest can do both, classification and regression.

All regression algorithms implemented the Classifier interface, so just pick a regression algorithm, like LinearRegression or M5P , and use the same Python wrapper which you would use for classification.

The example code that you referenced uses the classify_instance method which you would use for regression schemes to get the numeric prediction. In case of classification algorithms, this method returns the index of the predicted class label.

BTW The Python 2.7-based python-weka-wrapper library is no longer maintained and you should use python-weka-wrapper3 instead. Here is the same link, but for pww3:

https://fracpete.github.io/python-weka-wrapper3/api.html#classifiers

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