Weka Development [1]-instances class

Source: Internet
Author: User

First Google , the Weka software download down, after the installation is complete, in the Weka installation directory has a Weka.jar package.

Once you have added the package to the project, you can call the functions in Weka .

       A little bit more aboutweka Basics in weka in the directory, there is a data folder, The data set is stored in the first data set contact-lenses.arff For example, use editplus or another editor opens the dataset, with a% beginning with some comments , @relation represents the name of the dataset, @attribute represents property properties, < Span style= "font-family: ' Times New Roman ';" > @data is the dataset, generally the last column is the category (in LIBSVM The first column in the is a category).

below I have written a trivial weka Entry code:

Package instancetest;

Import Java.io.FileReader;

Import weka.core.Instances;

Public class instancetest

{

Public static Instances getfileinstances (String fileName) throwsException

{

FileReader frdata = new FileReader (fileName);

Instances data = new Instances (frdata);

return data;

}

Public static void main (string[] args) throws Exception

{

Instances Instances = getfileinstances( "F://program Files//weka-3-4//data//contact-lenses.arff");

All the data sets are entered

//system.out.println (instances);

How many samples are available in the data set with Numinstances

for ( int i = 0; i < instances.numinstances (); i++)

{

Instance (i) is to obtain the first sample

System. out . println (Instances.instance (i));

}

}

}

Weka Development [1]-instances class

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.