#!/usr/bin/bash -f
echo $#
if [ $# -ne 4 ]; then
  echo "Usage: inddemo file_stem train_set_size tree_type seed"
  echo ""
  echo "For example, to train a C4 decision tree on 100 cases"
  echo "drawn from the glass data set using random seed 123:"
  echo ""
  echo "inddemo glass 100 c4 123 | more"
  exit
fi

export stem=$1
export train=$2
export prog=$3
export seed=$4

export test=`echo $train | dm "x1 + 1"`
export total=`wc -l < ${stem}.dta`

/bin/rm -f ${stem}.bld ${stem}.tst
perm -s $seed < ${stem}.dta | linex 1-$train     > ${stem}.bld
#perm -s $seed < ${stem}.dta | linex $test-$total > ${stem}.tst
perm -s $seed < ${stem}.dta | linex $test-`echo $total` > ${stem}.tst

mktree -v -e -s $prog $stem
echo ""

tprint -cdi ${stem}.attr ${stem}.treec
echo ""

#tprint -pdi ${stem}
#echo ""

/bin/rm -f targets
colex 1 < ${stem}.tst > targets
tclass -e -p ${stem}.attr ${stem}.tree ${stem}.tst | tr "+" "\t" | abut targets - | colex -it 25a1 8.4n2-10
