nnlim

来自「it is the Data Mining Algorithm source c」· 代码 · 共 127 行

TXT
127
字号
#!/bin/bashsel=${1:-all}limit=${2:-1e-6}cnt=${3:-20}off=${4:-1}inc=${5:-7}add=$6explist="1.05 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0"mmtlist="0.05 0.1 0.15 0.2 0.25 0.3 0.4 0.5 0.6 0.7 0.8 0.9"#-----------------------------------------------------------------------function run (){                               # --- run one clustering trial  mode=${1:-none}               # get the training mode  for (( i = 0; i < cnt; i++ )); do    cli -S$(( (inc*i)+1 )) -A$mode $2 $args 2> $data.2    e=`sed -n "s/.*\[\([0-9]*\) epoch(s)\].*/\1/p" $data.2`    echo $e >> $data.1    if (( e > 1000 )); then break; fi;  done  gawk -v data=$data -v ncls=$ncls -v mode=$mode -v opts="($2)" '    BEGIN { e = s = n = 0; }    { e += $1; s += $1*$1; n++; }    END {      printf("%-7s %1d %-9s %-8s ", data, ncls, mode, opts);      if (n <= 0) n = 1;      s = sqrt((s -e*e/n)/n); e /= n;       printf(": %6.1f (~%6.1f)\n", e, s);    }' $data.1 | tee -a nnlim.res  rm -f $data.cls $data.1 $data.2}  # run ()#-----------------------------------------------------------------------function modes (){                               # --- try different training modes  data=${1:-iris}               # get the data name  ncls=${2:-2}                  # get the number of clusters  args="-$3c$ncls -e5000 -T$limit $add $data.dom $data.tab $data.cls"  run none                      # start with a normal run  if [[ $4 != "" ]]; then explist="$4"; fi  for x in $explist; do         # try different expansion factors    run expand   -g$x; done  if [[ $5 != "" ]]; then mmtlist="$5"; fi  for x in $mmtlist; do         # try different momentum terms    run momentum -m$x; done  run adaptive                  # adaptive expansion factor  run resilient                 # resilient backpropagation  run quick -g2                 # quick backpropagation}  # modes ()#-----------------------------------------------------------------------function all (){  echo shape: $1 | tee -a nnlim.res  modes iris    3 $1  modes wsel    3 $1  modes wsel    6 $1  modes wine    3 $1  modes wine    6 $1  modes breast  2 $1  modes abalone 3 $1  modes abalone 6 $1}  # all ()#-----------------------------------------------------------------------echo limit: $limit > nnlim.resif [[ $sel == "all" ]]; then  all           # fuzzy c-means algorithm  all v         # axes-parallel Gustafson-Kessel algorithm  all V         # normal        Gustafson-Kessel algorithmfiif [[ $sel == "best" || $sel == "iris" || $sel == "iris3" ]]; then  modes iris 3 "" 1.4 0.25  modes iris 3 v  1.4 0.3  modes iris 3 V  1.8 0.5fiif [[ $sel == "best" || $sel == "wsel3" ]]; then  modes wsel 3 "" 1.6 0.3  modes wsel 3 v  1.5 0.2  modes wsel 3 V  1.6 0.3fiif [[ $sel == "best" || $sel == "wsel6" ]]; then  modes wsel 6 "" 1.8 0.6  modes wsel 6 v  1.9 0.7  modes wsel 6 V  2.0 0.9fiif [[ $sel == "best" || $sel == "wine3" ]]; then  modes wine 3 "" 1.4 0.2  modes wine 3 v  1.5 0.2  modes wine 3 V  1.9 0.7fiif [[ $sel == "best" || $sel == "wine6" ]]; then  modes wine 6 "" 1.9 0.6  modes wine 6 v  1.9 0.7  modes wine 6 V  1.9 0.6fiif [[ $sel == "best" || $sel == "breast" || $sel == "breast2" ]]; then  modes breast 2 "" 1.2 0.05  modes breast 2 v  1.5 0.2  modes breast 2 V  1.8 0.5fiif [[ $sel == "best" || $sel == "abalone3" ]]; then  modes abalone 3 "" 1.6 0.3  modes abalone 3 v  1.6 0.3  modes abalone 3 V  1.9 0.6fiif [[ $sel == "best" || $sel == "abalone6" ]]; then  modes abalone 6 "" 1.9 0.9  modes abalone 6 v  1.8 0.5  modes abalone 6 V  1.9 0.5fi

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?