Weka has a highly sophisticated command line usage. This wrapper simplifies to run weka from command line
-
Run from command line, use
--helpto get all optionspython run_weka.py --train-file train.arff --test-file test.arff --model-file model.pmml
-
IMPORTANT per default,
wekais not called, unless explicitly specified with--runoptionpython run_weka.py <options> --run python run_weka.py --settings-input-file pig.json --run
-
Install weka and locate the
weka.jarfile. This path needs be specified with argument--weka-jar -
Train classifier
zeroRwith attribute configurationautoon training setmy_train.arff(also used for testing) and save trained model insaved_model.pmmlpython 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.arffusing the previously saved modelsaved_model.pmmland store the prediction output inprediction.csvpython 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-seedto 10, independent from value specified in file- Defaults defined in
DEFAULT_SETTINGSin 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