Step 2a. Preparing Input for WEKA

WEKA works with class weka.core.Instances

We are going to read input file line-by-line and convert it into Instances class

Our file is GoldDataset.txt (Who buys gold jewelry. See Lecture 9)

Explanations:

·       how to read and parse files in java

·       how to convert parsed tokens into Instances class

·       how to read native .arff file

 

Try it out:

•      Download file ‘GoldDataset.txt’ into project directory (Lab5). In lab machines: home->workspace->Lab5

•      Create new java class ‘FileToWEKA’ and copy the code from ‘FileToWEKA.java’

•      Run

•      Provide input file name:

Right-click - > Run as -> Run configuration-> Arguments (Program arguments): “GoldDataset.txt”

•      Run

Expected output

Reading .arff:

•      Download file ‘contact-lenses.arff’ into project directory (Lab5)

•      Create new java class ‘LoadArff’

•      Copy content of ‘LoadArff.java’

•      Run

•      Provide input file name:

Right-click - > Run as -> Run configuration-> Arguments (Program arguments): “contact-lenses.arff”

·       Run

Expected output