How to use Weka for predict for predict values in data stream from a limited range

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

How to use Weka for predict for predict values in data stream from a limited range

Tarantsoff
Hello everyone!
I'm new user of weka and trying to use it in one of my projects.
I have a data stream that consists of integer values from small limited
range. For example: 1, 2, 3.
I would like to use WekaForecaster for recognize pattern and predict next
values in this stream.
But when I tried to build model with "nominal" attributes and then build
forecaster I got an exception:

weka.core.expressionlanguage.core.SemanticException: Multiplication is only
applicable to doubles!

If I replace 'nominal' attributes with usual doubles it works but can
predict values out of range like 4.

Please give me an idea how I can use weka for predict values from a limited
range.
Thank you.

My code:
            ArrayList<Attribute> attrs = new ArrayList<>(1);
            ArrayList<String> values = new ArrayList<String>(){{add("1");
add("2"); add("3");}};
            attrs.add(new Attribute("val", values));

            Instances game = new Instances("game", attrs, 100);
            String[] history = new String[]{"1", "2", "3"};

            // --- build model -----
            ArrayList<Instance> instances = new ArrayList<>();
            for (String h : history) {

                Instance inst = new DenseInstance(1);
                inst.setDataset(game);
                inst.setValue(0, h);
                instances.add(inst);
            }
            game.addAll(instances);
            //
            WekaForecaster forecaster = new WekaForecaster();
            forecaster.setFieldsToForecast("val");
            forecaster.getTSLagMaker().setMinLag(1);
            forecaster.getTSLagMaker().setMaxLag(100);
            forecaster.buildForecaster(game, System.out);





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

Re: How to use Weka for predict for predict values in data stream from a limited range

Eibe Frank-2
Administrator
There are some regression methods that cannot predict values outside the
range of the target values in the training data. Examples are RandomForest,
REPTree, RandomTree, DecisionStump, and ZeroR.

Cheers,
Eibe



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