📄 clrn
字号:
#!/bin/bashsel=${1:-all}cnt=${2:-20}off=${3:-0}add=$4#-----------------------------------------------------------------------function run (){ # --- run one clustering trial echo tuples: $2 >> $data.tmp # do the clustering cli -a$1 -k$2 $args 2> /dev/null rm -f $data.tmp # traverse the training epochs for (( i = 0; i <= nepo; i += step )); do clc -x $data.$i $best $data.tab 2> /dev/null >> $data.tmp done # compare clustering results gawk -v step=$step 'BEGIN { n = 0 } ($0 ~ "^mean squared") { printf("%d %s\n", n, $NF); n += step; } ' $data.tmp >> $data.tmp # collect the comparison results rm -f $data.[0-9]* # remove the result files} # run ()#-----------------------------------------------------------------------function modes (){ # --- try different training modes data=${1:-iris} # get the data name ncls=${2:-2} # get the number of clusters nepo=${3:-20} # get the number of epochs if (( nepo >= 600 )); then inc=50; elif (( nepo >= 480 )); then inc=40; elif (( nepo >= 240 )); then inc=20; elif (( nepo >= 120 )); then inc=10; elif (( nepo >= 60 )); then inc=5; elif (( nepo >= 48 )); then inc=4; elif (( nepo >= 24 )); then inc=2; else inc=1; fi echo shape: $4 >> $data.tmp # record the cluster shape for (( k = 0; k < cnt; k++ )); do seed=$(( (7*k)+1+off )) # compute the seed value args="-S$seed -$4c$ncls -e1000 $add $data.dom $data.tab $data.ref" cli $args 2> /dev/null # create the reference result args="-S$seed -$4c$ncls $5 -Pe$nepo $add $data.dom $data.tab $data." list=`gawk 'END { printf("%d", n = NR-1); \ for (i = 1; ++i <= 6; ) printf(" %d", n/i); printf("\n"); }' $data.tab` run altopt 0 # start with standard clustering for n in $list; do # compute list of tuple numbers run complrn $n; done # do one rune with each number of tuples done rm -f $data.ref # delete the reference result} # modes ()#-----------------------------------------------------------------------function average (){ # --- average data over trials gawk ' BEGIN { max = -1; n = 0; } { if ($1 == "shape:") # if cluster shape specification shape = $2; # note the cluster shape else if ($1 == "tuples:") { # if number of tuples m = shape $2; # construct the mode name for (i = n; --i >= 0; ) # add mode to the list if necessary if (tuples[i] == m) break; if (i < 0) tuples[i = n++] = m; } else { # if result line if ($1 > max) max = $1; # update the maximum epoch sums[m,$1] += ($2 > 0) ? log($2)/log(10) : -16; cnts[m,$1]++; # store the trial value and count it totals[$1]++; # count the trial for the epoch } } END { # output collected data for (i = 0; i <= max; i++) { if (totals[i] <= 0) continue; printf("> %10d diff\n", i); for (k = 0; k < n; k++) { m = tuples[k]; if (cnts[m,i] <= 0) continue; printf("%-12s %g\n", m, sums[m,i]/cnts[m,i]); } } }' $1.tmp >> ${2:-$1}.res} # average ()#-----------------------------------------------------------------------if [[ $sel == "all" || $sel == "iris" ]]; then rm -f iris.tmp modes iris 3 30 modes iris 3 30 v modes iris 3 80 V rm -f iriscl.res average iris iriscl rm -f iris.tmpfiif [[ $sel == "all" || $sel == "wsel3" ]]; then rm -f wsel.tmp modes wsel 3 20 modes wsel 3 20 v modes wsel 3 30 V rm -f wselcl3.res average wsel wselcl3 rm -f wsel.tmpfiif [[ $sel == "all" || $sel == "wsel6" ]]; then rm -f wsel.tmp modes wsel 6 40 modes wsel 6 80 v modes wsel 6 120 V rm -f wselcl6.res average wsel wselcl6 rm -f wsel.tmpfiif [[ $sel == "all" || $sel == "wine3" ]]; then rm -f wine.tmp modes wine 3 20 modes wine 3 20 v modes wine 3 30 V rm -f winecl3.res average wine winecl3 rm -f wine.tmpfiif [[ $sel == "all" || $sel == "wine6" ]]; then rm -f wine.tmp modes wine 6 40 modes wine 6 80 v modes wine 6 120 V rm -f winecl6.res average wine winecl6 rm -f wine.tmpfiif [[ $sel == "all" || $sel == "breast" ]]; then rm -f breast.tmp modes breast 2 10 modes breast 2 20 v modes breast 2 100 V rm -f brstcl.res average breast brstcl rm -f breast.tmpfiif [[ $sel == "all" || $sel == "abalone3" ]]; then rm -f abalone.tmp modes abalone 3 30 modes abalone 3 30 v modes abalone 3 160 V rm -f abacl3.res average abalone abacl3 rm -f abalone.tmpfiif [[ $sel == "all" || $sel == "abalone6" ]]; then rm -f abalone.tmp modes abalone 6 80 modes abalone 6 80 v modes abalone 6 200 V rm -f abacl6.res average abalone abacl6 rm -f abalone.tmpfi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -