Skip to content

Instantly share code, notes, and snippets.

@filipsPL
Created February 28, 2019 12:06
Show Gist options
  • Save filipsPL/bd5e063133af3b5ec0bfe78252a67871 to your computer and use it in GitHub Desktop.
Save filipsPL/bd5e063133af3b5ec0bfe78252a67871 to your computer and use it in GitHub Desktop.
Quick and dirty way of processing log files from autoweka to extract the best classifier found by the system. Results may still need some tuning before supplying to weka experimenter, but in many cases it works out of the box.
#!/bin/bash
# direcotry with log files from autoweka
autowekadir="./"
# weka.classifiers.meta.FilteredClassifier -F "weka.filters.supervised.attribute.AttributeSelection -E \"$eval\" -S \"$selection\"" -S 1 -W $classifier
# best classifier: weka.classifiers.lazy.IBk
# arguments: [-K, 4, -F]
# attribute search: weka.attributeSelection.GreedyStepwise
# attribute search arguments: [-B, -R]
# attribute evaluation: weka.attributeSelection.CfsSubsetEval
# attribute evaluation arguments: []
for f in $autowekadir/*.log
do
echo "$f"
classifier=$(cat $f | grep -A1 "best classifier: " | sed -e 's/best classifier: //g' -e 's/arguments: //g' -e 's/\[//g' -e 's/\]//g' -e 's/,//g')
# echo "--------"
selection=$(cat $f | grep -A3 "best classifier: " | grep "attribute search: " | sed -e 's/attribute search: //g' -e 's/arguments: //g' -e 's/\[//g' -e 's/\]//g' -e 's/,//g')
selectionParam=$(cat $f | grep -A3 "best classifier: " | grep "attribute search arguments: " | sed -e 's/attribute search arguments: //g' -e 's/arguments: //g' -e 's/\[//g' -e 's/\]//g' -e 's/,//g')
# echo $selection
# echo $selectionParam
# echo "--------"
evaluator=$(cat $f | grep -A5 "best classifier: " | grep "attribute evaluation: " | sed -e 's/attribute evaluation: //g' -e 's/arguments: //g' -e 's/\[//g' -e 's/\]//g' -e 's/,//g')
evaluatorParam=$(cat $f | grep -A5 "best classifier: " | grep "attribute evaluation arguments: " | sed -e 's/attribute evaluation arguments: //g' -e 's/arguments: //g' -e 's/\[//g' -e 's/\]//g' -e 's/,//g')
# echo $evaluator
# echo $evaluatorParam
if [ $evaluator == 'null' ]
then
# echo "*** null"
# weka.classifiers.bayes.NaiveBayes
echo $classifier
else
# echo "*** not null"
echo weka.classifiers.meta.FilteredClassifier -F \"weka.filters.supervised.attribute.AttributeSelection -E \\\"$evaluator $evaluatorParam\\\" -S \\\"$selection $selectionParam\\\"\" -S 1 -W $classifier
fi
echo "--------------------------"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment