2
$\begingroup$

I have two hundred and fifty images, and extracted the features from them and put them in an Excel file, how to use the weka program so that the first 200 images for training and the remaining fifty images for testing.

Do I put the data for two hundred images in a separate file and the data for fifty images in another file? Or do I put the data for two hundred and fifty images in the same file?. Please help me.

$\endgroup$

migrated from ai.stackexchange.com Sep 18 at 21:30

This question came from our site for people interested in conceptual questions about life and challenges in a world where "cognitive" functions can be mimicked in purely digital environment.

  • $\begingroup$ I'm voting to close this question as off-topic because this is better asked on DataScience.SE $\endgroup$ – John Doucette Sep 17 at 22:39
0
$\begingroup$

The answer to your question is to use Weka's "Explorer" mode, and then select "training/test split" with a 20% size for the test set.

$\endgroup$
  • $\begingroup$ Do you mean to divide the 250-cell data file to 20% for testing? Or separate 20% of the data in a separate file and use it for testing? $\endgroup$ – Ahmad Sarairah Sep 18 at 6:02
  • $\begingroup$ Weka's "Explorer" mode should have an option to select "training/test split" if you want to perform a classification task (at least, if did last time I used it). You can load a single file into the "Explorer" mode under the classification tab, and then tell Weka that you want the file to be split into training and test pieces. $\endgroup$ – John Doucette Sep 18 at 21:38
0
$\begingroup$

Data Preparation

Weka uses the arff file type.

A modified example arff file content from the previous link:

% 1. Title: Iris Plants Database
% 2. Creator: R.A. Fisher, Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
@RELATION iris
@ATTRIBUTE petallength  NUMERIC
@ATTRIBUTE petalwidth   NUMERIC
@ATTRIBUTE class        {Iris-setosa,Iris-versicolor,Iris-virginica}
@DATA
1.4,0.2,Iris-setosa
1.4,0.2,Iris-virginica
1.3,0.2,Iris-setosa
1.5,0.2,Iris-versicolor
1.4,0.2,Iris-setosa
1.7,0.4,Iris-setosa

The above example can be broken down into sections:

  1. Comments
    • Lines beginning with "%" are comments and are not read by the WEKA data readers
  2. @RELATION
    • dataset name (use quotes around the name if there are spaces)
  3. @ATTRIBUTE
    • each attribute defines a feature of one of the following types:
      • NUMERIC: real number
      • NOMINAL: discrete value from a predefined list (see example @ATTRIBUTE class feature)
      • STRING: a string where quotes must be used if spaces are included
      • DATE: @ATTRIBUTE `name` date [`date-format`] where the default date-format is "yyyy-MM-dd'T'HH:mm:ss"
  4. @DATA
    • Delimiter specifying the start of the CSV data


Weka Explorer

After creating your arff file, you have a few options when using the Weka explorer:

  1. Load entire dataset into Weka explorer and use the built-in k-fold cross validation option which randomly partitions your dataset and automatically performs CV for your given a classifier
  2. Load entire dataset into Weka explorer and use the built-in train/test split option with a user-specified percentage to randomly partition your dataset.
  3. Manually partition your arff file into a train file and test file and use the supplied test-set option in the Weka explorer. To manually partition your arff file, simply copy your original arff file and and keep non-intersecting sets of CSV rows (i.e. delete instances from one file and retain those instances in the other).

If this is for educational purposes, it might be easiest to manually partition your dataset so that you know which images are in training and which are testing. If this is for research, of course k-fold CV is preferred.


If you are using the Weka Java library rather than the desktop application, there are plenty of online resources that explain the library architecture: Waikato Github io site

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.