Regression with wrapper3

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Regression with wrapper3

bujarra
Hi all,

I'm trying to use Alternating Model Tree as regression with wrapper3 using
Spyder (Python). I've followed the example in here
https://fracpete.github.io/python-weka-wrapper/examples.html

This is my code:

from weka.classifiers import PredictionOutput, KernelClassifier, Kernel
from weka.core.converters import Loader
from weka.classifiers import Evaluation
from weka.core.classes import Random

loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file( "car_vila.arff")
data.class_is_last()

cls = KernelClassifier(classname="weka.classifiers.functions.SMOreg",
options=["-N", "0"])
kernel =
Kernel(classname="weka.classifiers.functions.supportVector.RBFKernel",
options=["-G", "0.1"])
cls.kernel = kernel
pout =
PredictionOutput(classname="weka.classifiers.evaluation.output.prediction.PlainText")
evl = Evaluation(data)
evl.crossvalidate_model(cls, data, 10, Random(1), pout)

print(evl.summary())
print(pout.buffer_content())

import weka.plot.classifiers as plcls  # NB: matplotlib is required
plcls.plot_classifier_errors(evl.predictions, wait=True)

I'm using the attached .arff file (I also tried with bolts.arff). However, I
get this error.


  File "C:\X.py", line 13, in <module>
    loader = Loader(classname="weka.core.converters.ArffLoader")

  File "C:\anaconda3\lib\site-packages\weka\core\converters.py", line 42, in
__init__
    jobject = Loader.new_instance(classname)

  File "C:\anaconda3\lib\site-packages\weka\core\classes.py", line 669, in
new_instance
    javabridge.class_for_name("java.lang.Object"), classname, [])

  File "C:\anaconda3\lib\site-packages\javabridge\jutil.py", line 1743, in
class_for_name
    ldr = static_call('java/lang/ClassLoader', 'getSystemClassLoader',

  File "C:\anaconda3\lib\site-packages\javabridge\jutil.py", line 939, in
static_call
    fn = make_static_call(class_name, method_name, sig)

  File "C:\anaconda3\lib\site-packages\javabridge\jutil.py", line 910, in
make_static_call
    klass = env.find_class(class_name)

AttributeError: 'NoneType' object has no attribute 'find_class'

Which is the cause of the error? It looks the ArffLoader.

car_vila.arff <https://weka.8497.n7.nabble.com/file/t7341/car_vila.arff>  

Thanks in advance.



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> I'm trying to use Alternating Model Tree as regression with wrapper3 using
> Spyder (Python). I've followed the example in here
> https://fracpete.github.io/python-weka-wrapper/examples.html
>
> This is my code:
>
> from weka.classifiers import PredictionOutput, KernelClassifier, Kernel
> from weka.core.converters import Loader
> from weka.classifiers import Evaluation
> from weka.core.classes import Random
>
> loader = Loader(classname="weka.core.converters.ArffLoader")

[...]

You forgot the start the JVM, hence the error. Before you can use any
Weka classes, you to need to start up the JVM like this (see start of
the examples page that you referenced):

import weka.core.jvm as jvm
jvm.start(packages=True)

And, once you are finished, stop the JVM again (see at the end of the
examples page):
jvm.stop()

Furthermore, you are using SMOreg and not alternating model trees. For
that you'd need to install the package "alternatingModelTrees", see
examples page:
https://fracpete.github.io/python-weka-wrapper/examples.html#packages

And then switch over the classifier. Information on the alternating
model trees package:
https://weka.sourceforge.io/packageMetaData/alternatingModelTrees/
https://weka.sourceforge.io/doc.packages/alternatingModelTrees/

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
Thanks Peter,

I got this error log (attached) when executing the code (following your
steps).  log.txt <https://weka.8497.n7.nabble.com/file/t7341/log.txt>  

This is my code. I guess that for AMT, I don't need the kernel. I already
have installed the package from Weka GUI (Package Manager) and use it over
there.

import weka.core.jvm as jvm
jvm.start(packages=True)

from weka.classifiers import PredictionOutput, KernelClassifier, Kernel
from weka.core.converters import Loader
from weka.classifiers import Evaluation
from weka.core.classes import Random

loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file( "car_vila.arff")
data.class_is_last()

cls =
KernelClassifier(classname="weka.classifiers.trees.AlternatingModelTree",
options=["-I", "10", "-H", "1"])
kernel =
Kernel(classname="weka.classifiers.functions.supportVector.RBFKernel",
options=["-G", "0.1"])
cls.kernel = kernel
pout =
PredictionOutput(classname="weka.classifiers.evaluation.output.prediction.PlainText")
evl = Evaluation(data)
evl.crossvalidate_model(cls, data, 10, Random(1), pout)

print(evl.summary())
print(pout.buffer_content())

import weka.plot.classifiers as plcls  # NB: matplotlib is required
plcls.plot_classifier_errors(evl.predictions, wait=True)

jvm.stop()

Any clue what is causing this error? I cannot run it properly

Thanks again




--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Eibe Frank-2
Administrator
It looks like the code is being run in a headless environment, where a graphical display is not available, and this appears to be causing issues with the scatterPlot3D package for WEKA. Try uninstalling that package using the WEKA package manager.

Cheers,
Eibe

On Thu, Apr 15, 2021 at 10:00 PM bujarra <[hidden email]> wrote:
Thanks Peter,

I got this error log (attached) when executing the code (following your
steps).  log.txt <https://weka.8497.n7.nabble.com/file/t7341/log.txt

This is my code. I guess that for AMT, I don't need the kernel. I already
have installed the package from Weka GUI (Package Manager) and use it over
there.

import weka.core.jvm as jvm
jvm.start(packages=True)

from weka.classifiers import PredictionOutput, KernelClassifier, Kernel
from weka.core.converters import Loader
from weka.classifiers import Evaluation
from weka.core.classes import Random

loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file( "car_vila.arff")
data.class_is_last()

cls =
KernelClassifier(classname="weka.classifiers.trees.AlternatingModelTree",
options=["-I", "10", "-H", "1"])
kernel =
Kernel(classname="weka.classifiers.functions.supportVector.RBFKernel",
options=["-G", "0.1"])
cls.kernel = kernel
pout =
PredictionOutput(classname="weka.classifiers.evaluation.output.prediction.PlainText")
evl = Evaluation(data)
evl.crossvalidate_model(cls, data, 10, Random(1), pout)

print(evl.summary())
print(pout.buffer_content())

import weka.plot.classifiers as plcls  # NB: matplotlib is required
plcls.plot_classifier_errors(evl.predictions, wait=True)

jvm.stop()

Any clue what is causing this error? I cannot run it properly

Thanks again




--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
I've uninstall the ScatterPlot3D and running the code I get the following
error and the Python environment crashes. I don't need to visualize the
results only print them.

[WekaPackageManager] associationRulesVisualizer can't be loaded because the
following packages are missing:
scatterPlot3D (>=1.0.6)



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> I've uninstall the ScatterPlot3D and running the code I get the following
> error and the Python environment crashes. I don't need to visualize the
> results only print them.
>
> [WekaPackageManager] associationRulesVisualizer can't be loaded because the
> following packages are missing:
> scatterPlot3D (>=1.0.6)

You might want to uninstall the package as well.

Once you've built an associator model, you can just do:
- Java
  System.out.println(associator);
- Python
  print(associator)

To output the model as plain text.

If you're using Apriori, you have a bit more control. See the following example:
https://github.com/fracpete/python-weka-wrapper3-examples/blob/master/src/wekaexamples/associations/apriori_output.py

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
I've uninstalled the associationRulesVisualizer package too. Now, I get this
error:


  File "C:\Users\Desktop\wrapper.py", line 22, in <module>
    cls =
KernelClassifier(classname="weka.classifiers.trees.AlternatingModelTree",
options=["-I", "10", "-H", "1"])

  File "C:\Users\anaconda3\lib\site-packages\weka\classifiers.py", line 843,
in __init__
    raise Exception("Does not handle a kernel: " +
classes.get_classname(jobject))

Exception: Does not handle a kernel:
weka.classifiers.trees.AlternatingModelTree

What is wrong with my code? I just want to:
1- load an arff file
2- target two of the attributes (as it is possible with Forecasting)
3- Predict multiple steps using AMT
4- Tune the dataset length and I and H





--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> I've uninstalled the associationRulesVisualizer package too. Now, I get this
> error:
>
>
>   File "C:\Users\Desktop\wrapper.py", line 22, in <module>
>     cls =
> KernelClassifier(classname="weka.classifiers.trees.AlternatingModelTree",
> options=["-I", "10", "-H", "1"])
>
>   File "C:\Users\anaconda3\lib\site-packages\weka\classifiers.py", line 843,
> in __init__
>     raise Exception("Does not handle a kernel: " +
> classes.get_classname(jobject))
>
> Exception: Does not handle a kernel:
> weka.classifiers.trees.AlternatingModelTree
>
> What is wrong with my code?

AMT is not a classifier that handles a kernel, hence you can't wrap it
as KernelClassifier (which the error message is telling you).
Simply import/instantiate a Classifier object, not a KernelClassifier.

> I just want to:
> 1- load an arff file
> 2- target two of the attributes (as it is possible with Forecasting)
> 3- Predict multiple steps using AMT
> 4- Tune the dataset length and I and H

If you want to do forecasting, then you have to use a different
approach. Have a look at the timeseries example code (it allows you to
do what the Forecast tab does in the Weka Explorer):
https://github.com/fracpete/python-weka-wrapper3-examples/blob/master/src/wekaexamples/timeseries/timeseries.py

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
I've followed the example and adapted to my case. This is the code:


import weka.core.jvm as jvm
from weka.core.converters import Loader
from weka.classifiers import Classifier
from weka.timeseries import WekaForecaster
from weka.core.dataset import Instances
import traceback


def main():


    loader = Loader("weka.core.converters.ArffLoader")
    dat = loader.load_file("car_vila.arff")
    dat.class_is_last()    
    dat_train, dat_test = dat.train_test_split(90.0)
    forecaster = WekaForecaster()

    forecaster.base_forecaster =
Classifier(classname="weka.classifiers.trees.AlternatingModelTree",
options=["-I", "10", "-H", "1"])
    forecaster.fields_to_forecast = "lat"
    forecaster.build_forecaster(dat_train)
    num_prime_instances = 5    
    dat_prime = Instances.copy_instances(dat_train, dat_train.num_instances
- num_prime_instances, num_prime_instances)
    forecaster.prime_forecaster(dat_prime)
    num_future_forecasts = dat_test.num_instances
    preds = forecaster.forecast(num_future_forecasts)
    print("Actual,Predicted,Error")
    for i in range(num_future_forecasts):
         actual = dat_test.get_instance(i).get_value(0)
         predicted = preds[i][0].predicted
         error = actual - predicted
         print("%f,%f,%f" % (actual, predicted, error))


if __name__ == '__main__':  
    try:
        jvm.start(packages=True)
        main()
    except Exception as e:
        print(traceback.format_exc())
    finally:
        jvm.stop()

However, I get this error and I don't know what is the cause. I moved to
Pycharm because of the lack of response from Spyder. I have correctly
installed javabridge and python-weka-wrapper. I'm using Python 3.8 (I don't
know if the wrapper is another)

Requirement already satisfied: python-weka-wrapper3 in
c:\users\anaconda3\lib\site-packages (0.1.16)
Requirement already satisfied: javabridge>=1.0.14 in
c:\users\anaconda3\lib\site-packages (from python-weka-wrapper3) (1.0.19)
Requirement already satisfied: numpy in c:\users\anaconda3\lib\site-packages
(from python-weka-wrapper3) (1.20.1+mkl)


Traceback (most recent call last):
  File "C:/Users/PycharmProjects/pythonProject/main.py", line 6, in <module>
    from weka.core.converters import Loader
  File "C:\Users\anaconda3\lib\site-packages\weka\core\converters.py", line
18, in <module>
    from weka.core.classes import OptionHandler
  File "C:\Users\anaconda3\lib\site-packages\weka\core\classes.py", line
2085
    except Exception, e:
                    ^
SyntaxError: invalid syntax

Process finished with exit code 1




--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
[...]

> However, I get this error and I don't know what is the cause. I moved to
> Pycharm because of the lack of response from Spyder. I have correctly
> installed javabridge and python-weka-wrapper. I'm using Python 3.8 (I don't
> know if the wrapper is another)
>
> Requirement already satisfied: python-weka-wrapper3 in
> c:\users\anaconda3\lib\site-packages (0.1.16)
> Requirement already satisfied: javabridge>=1.0.14 in
> c:\users\anaconda3\lib\site-packages (from python-weka-wrapper3) (1.0.19)
> Requirement already satisfied: numpy in c:\users\anaconda3\lib\site-packages
> (from python-weka-wrapper3) (1.20.1+mkl)
>
>
> Traceback (most recent call last):
>   File "C:/Users/PycharmProjects/pythonProject/main.py", line 6, in <module>
>     from weka.core.converters import Loader
>   File "C:\Users\anaconda3\lib\site-packages\weka\core\converters.py", line
> 18, in <module>
>     from weka.core.classes import OptionHandler
>   File "C:\Users\anaconda3\lib\site-packages\weka\core\classes.py", line
> 2085
>     except Exception, e:
>                     ^
> SyntaxError: invalid syntax
>
> Process finished with exit code 1

You must have installed the Python 2.7 version alongside the Python 3
version, as this type of exception handling is invalid Python 3 syntax
(hence the error).
The classes module of pww3 does not use this syntax:
https://github.com/fracpete/python-weka-wrapper3/blob/master/python/weka/core/classes.py

Use the command "pip freeze" to see what libraries you have installed.
Most likely, you will have "python-weka-wrapper" (Python 2.7)
installed and not just "python-weka-wrapper3" (Python 3).

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
In reply to this post by bujarra
Which python version do you recommend? 2.7 or 3.X? I guess 2.7 will be
obsolet soon. Then, I should install only python-weka-wrapper3? The
forecasting example is based on 2.7 or 3.X?





--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann-3
The Python 2.7 version is no longer developed, as Python 2.7 reached end of life last year.

Forecasting example, as you can tell from URL, is from the Python 3 version.

Cheers, Peter

On April 17, 2021 11:22:37 AM GMT+12:00, bujarra <[hidden email]> wrote:

>Which python version do you recommend? 2.7 or 3.X? I guess 2.7 will be
>obsolet soon. Then, I should install only python-weka-wrapper3? The
>forecasting example is based on 2.7 or 3.X?
>
>
>
>
>
>--
>Sent from: https://weka.8497.n7.nabble.com/
>_______________________________________________
>Wekalist mailing list -- [hidden email]
>Send posts to [hidden email]
>To unsubscribe send an email to [hidden email]
>To subscribe, unsubscribe, etc., visit
>https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
>List etiquette:
>http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
I got this error:

TypeError:__init__() got an unexpected keyword argument 'setOptions'

From this line:

forecaster.base_forecaster
=Classifier(classname="weka.classifiers.trees.AlternatingModelTree",
setOptions=["-I 10", "-H 1"])

I've tried multiple ways of adding the parameters. Which is the correct one
to configure the number of iterations and shrinkage?



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> I got this error:
>
> TypeError:__init__() got an unexpected keyword argument 'setOptions'
>
> From this line:
>
> forecaster.base_forecaster
> =Classifier(classname="weka.classifiers.trees.AlternatingModelTree",
> setOptions=["-I 10", "-H 1"])
>
> I've tried multiple ways of adding the parameters. Which is the correct one
> to configure the number of iterations and shrinkage?

Documentation for the Classifier class:
http://fracpete.github.io/python-weka-wrapper3/weka.html#weka.classifiers.Classifier

Various ways of setting options:
http://fracpete.github.io/python-weka-wrapper3/examples.html#option-handling

Each option is separate:
cls = Classifier(classname="weka.classifiers.trees.AlternatingModelTree",
options=["-I", "10", "-H", "1"])
forecaster.base_forecaster = cls

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
In reply to this post by bujarra
I've also used that way and I get:

javabridge.jutil.JavaException: Ileagal options: -I 10 -H 1



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> I've also used that way and I get:
>
> javabridge.jutil.JavaException: Ileagal options: -I 10 -H 1

Looks like there is a bug in the option handling of
AlternatingModelTree and you have to use the Java set-methods to set
the values instead:

cls = Classifier(classname="weka.classifiers.trees.AlternatingModelTree")
cls.jwrapper.setShrinkage(1.0)
cls.jwrapper.setNumberOfIterations(10)

@Eibe/@Mark
The call to super.setOptions(...) in the setOptions method has to be
at the end (as it will call checkForRemainingOptions) and the call to
Utils.checkForRemainingOptions(options) removed.
https://svn.cms.waikato.ac.nz/svn/weka/trunk/packages/internal/alternatingModelTrees/src/main/java/weka/classifiers/trees/AlternatingModelTree.java

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

bujarra
It works!

Another question, how can I forecast two attributes? as target attributes.

My current code has this line

forecaster.fields_to_forecast = "lat"

However, I would like to add "lng" too





--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Regression with wrapper3

Peter Reutemann
> Another question, how can I forecast two attributes? as target attributes.
>
> My current code has this line
>
> forecaster.fields_to_forecast = "lat"
>
> However, I would like to add "lng" too

You can either supply a comma-separated list or a list comprised of strings:

forecaster.fields_to_forecast = "lat,lng"

or

forecaster.fields_to_forecast = ["lat", "lng"]

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 577-5304
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html