Weka has a highly sophisticated command line usage. This wrapper simplifies to run weka from command line
-
Run from command line, use
--help
to get all optionspython run_weka.py --train-file train.arff --test-file test.arff --model-file model.pmml
-
IMPORTANT per default,
weka
is not called, unless explicitly specified with--run
optionpython run_weka.py <options> --run python run_weka.py --settings-input-file pig.json --run
-
Install weka and locate the
weka.jar
file. This path needs be specified with argument--weka-jar
-
Train classifier
zeroR
with attribute configurationauto
on training setmy_train.arff
(also used for testing) and save trained model insaved_model.pmml
python run_weka.py -e train -c zeroR --attribute-config=auto --train-file my_train.arff --test-file my_train.arff --model-file saved_model.pmml --run
-
Predict the samples in
my_predict.arff
using the previously saved modelsaved_model.pmml
and store the prediction output inprediction.csv
python run_weka.py -e predict --test-file my_predict.arff --model-file saved_model.pmml --prediction-output-file prediction.csv --run
-
Settings can be saved with
python run_weka.py --settings-output-file settings.json
-
Settings can be loaded with
python run_weka.py --settings-input-file settings.json
-
It is also possible, to overwrite settings from file on command line, e.g. change
sub-sample-seed
to 10, independent from value specified in file- Defaults defined in
DEFAULT_SETTINGS
in source code (lowest precedence) - Settings loaded from settings file
- Settings specified on command line (highest precedence)
python run_weka.py --settings-input-file settings.json --sub-sample-seed 10
- Defaults defined in
-
Settings file rewriting
python run_weka.py --settings-input-file in.json --settings-output-file out.json --classifier j48