Use weka api for Linear Regression

Source: Internet
Author: User
Package linearregression; import WEKA. classifiers. evaluation; import WEKA. classifiers. functions. linearregression; import WEKA. core. instance; import WEKA. core. instances; import WEKA. core. converters. converterutils. datasource; public class legression {/*** @ Param ARGs * @ throws exception */public static void main (string [] ARGs) throws exception {// todo auto-generated method stubdatasource train_data = new datasource ("E: // train. ARFF "); // read the training data datasource test_data = new datasource (" E: // test. ARFF "); // read the test data instances instrain = train_data.getdataset (); instances instest = test_data.getdataset (); instrain. setclassindex (instrain. numattributes ()-1); // sets the indexinstest of the target in the training set. setclassindex (instest. numattributes ()-1); // set the indexlinearregression LR = new linearregression () of the target test set; // define the type LR of the classifier. buildclassifier (instrain); // training classifier evaluation EVAL = new evaluation (instrain); eval. evaluatemodel (LR, instest); // evaluates the effect of system. out. println (eval. meanabsoluteerror (); // calculate Mae }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.