Re: simplest of code
Peter Reutemann <[email protected]>
| Newsgroups | gmane.comp.ai.weka |
|---|---|
| Message-ID | <[email protected]> |
A "try" block has to be followed by a "catch" (for exceptions) and/or a "finally" block. Hence the error message. These are basic Java questions and not Weka related. Cheers, Peter On November 9, 2021 6:59:05 PM GMT+13:00, Bob Matthews <[email protected]> wrote: > >OK................ > >I have the following code:- > >********************* > >OSV = ((mid_price_close - PDCC)/PDCC) / btheta; > >//************************************************************************ > // run weka and make a prediction > /** > * Performs a prediction. > * > * @param v the value of the input variable to use for making a >prediction > * @return the predicted value (class index), returns -1 if it fails >to make prediction > * @throws Exception if prediction fails > */ > try { > // [B] create instance > // create the current instance > double[] values = new double[header.numAttributes()]; > for (int i = 0; i < values.length; i++) > values[i] = Utils.missingValue(); > // - numeric > values[0] = OSV; > DenseInstance currentInstance = new DenseInstance(1.0, values); > currentInstance.setDataset(header); > > // [C] classify nominal class > // classifyInstance() just returns the index of the predicted >label (the one with the highest probability) as a double > double prediction = cls.classifyInstance(currentInstance); > System.out.println("prediction: " + prediction); > > return (int) prediction; > } > >******************************* > >Errow message:- > >Syntax error, [on the last line] insert "Finally" to complete try >statement ?? > >Bob M > >On 11/9/2021 4:52 PM, Peter Reutemann wrote: > >_______________________________________________ >Wekalist mailing list -- [email protected] >Send posts to [email protected] >To unsubscribe send an email to [email protected] >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) 858-5174 (office) +64 (7) 577-5304 (home office) http://www.cms.waikato.ac.nz/~fracpete/ http://www.data-mining.co.nz/. _______________________________________________ Wekalist mailing list -- [email protected] Send posts to [email protected] To unsubscribe send an email to [email protected] 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