Created
April 23, 2012 19:35
-
-
Save pyetras/2473290 to your computer and use it in GitHub Desktop.
Zad9.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat in40 | awk '{$1=""; print $0}' > in0 | |
name=`echo -n $1 | sed s/' '//g` | |
echo $name | |
mkdir models${name} | |
for file in labels/*; do | |
echo $file | |
i=`echo -n $file | sed s/labels.//` | |
paste $file in0 -d " " > "in${i}" | |
../svmlight/svm_perf_learn "$1" "in${i}" "models${name}/model${i}" | |
rm "in${i}"; | |
done | |
mkdir predictions${name} | |
for file in models${name}/*; do | |
echo $file | |
i=`echo -n $file | sed s/models${name}.model//` | |
../svmlight/svm_perf_classify intest $file "predictions${name}/${i}" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sink('in40') | |
sapply(1:nrow(train), function(i) { | |
row <- train[i, ]; | |
cat(ifelse(labels[i, 40], '+1 ', '-1 ')); | |
cat(mapply(function(name, v) paste(name, v, sep=':'), which(row != 0) -> w, round(row[w], 3))); | |
cat('\n') | |
}) -> foo | |
sink() | |
sink('intest') | |
sapply(1:nrow(test), function(i) { | |
row <- test[i, ]; | |
cat('0 ') | |
cat(mapply(function(name, v) paste(name, v, sep=':'), which(row != 0) -> w, round(row[w], 3))); | |
cat('\n') | |
}) -> foo | |
sink() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
labels <- read.csv('./data/raw/trainingLabels.txt', header=T) | |
as.vector(as.matrix(t(labels))) -> l | |
d <- cbind(rep(1:nrow(labels), each=ncol(labels)), l) | |
d[!is.na(d[,2]),] -> d | |
tapply(1:nrow(d), list(d[,1], d[,2]), function(ii) T) -> dd | |
dd[is.na(dd)] <- F | |
labels <- dd | |
rownames(labels) <- c() | |
# data <- data / max(data) | |
save(labels, file="data/labels.RD") | |
which.max(colSums(labels)) # 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment