Blog Archive

Friday, September 21, 2012

Failure of update the tool of WEKA


Failure of update the tool of WEKA

Question: How to solve the following question:


java.io.IOException: Server returned HTTP response code: 500 for URL: http://weka.sourceforge.net/packageMetaData/WekaODF/versions.txt



Answer:

create a file called "PackageRepository.props" in $HOME/wekafiles/props 
and add the following line to it:

weka.core.wekaPackageRepositoryURL=http://www.cs.waikato.ac.nz/ml/weka/packageMe








Source:
https://list.scms.waikato.ac.nz/pipermail/wekalist/2012-February.txt

Thursday, September 20, 2012

Perl script to covert libsvm data format into WEKA ARFF format


#!/usr/bin/perl
# perl lsvm2arff.pl inputLibSVMData.lsvm outputWeka.arff
$attNum=`head -n1 $ARGV[0] | wc -w`;
$attNum=$attNum-1;

$cmd_str="cat $ARGV[0] | perl -lane 'print \$F[0]' | sort | uniq | sort -n";
chomp($IDs=`$cmd_str`);
@classIDs=split(' ',$IDs);
#print "IDS=@classIDs, $classIDs[0]\n";
print "In this convertion code, your original class 'label' will be converted into 'class_label'; \nFor example, if class IDs are:\t1,\t\t2; \nthey will be converted into:\tclass_1,\tclass_2\n";


open(OUT, ">$ARGV[1]") || die "$!";
print OUT "\@relation libSVM2ARFF_DATA\n";
print OUT "\n";

for($i=1;$i<=$attNum;$i++){
print OUT "\@attribute attribute_${i} real\n";
}
$tmp_str="";
for($j=0;$j<@classIDs-1;$j++){
$ID=$classIDs[$j];
$tmp_str=$tmp_str."class_$ID,";
}
print OUT "\@attribute class {${tmp_str}class_$classIDs[-1]}\n";

print OUT "\n";

print OUT "\@data\n";

#print "$cmd_str\n";
#$cmd_str="cat ~/Dropbox/tmp/tst_data_D50.lsvm |  perl -lane 's|\d+:||g; print \$_' | perl -lane '\$str="";for(\$i=1;\$i<\@F;\$i++){\$str=\$str."\$F[\$i],"};print "${str}class$F[0]"'"
$cmd_str="cat $ARGV[0] |  perl -lane 's|\\d+:||g; print \$_' | perl -lane '\$len=\@F; \$str=\"\";for(\$i=1;\$i<\$len;\$i++){\$str=\$str.\"\$F[\$i],\"};print \"\${str}class_\$F[0]\"'";
#print "$cmd_str\n";
#`echo $cmd_str`;
chomp(@data=`$cmd_str`);

foreach(@data){
print OUT "$_\n";
}

close(OUT);

Tuesday, September 4, 2012

Question: `require': no such file to load -- peach



sudo jruby -S gem list --local

*** LOCAL GEMS ***

sources (0.0.1)

$ which jruby
/usr/bin/jruby
$ ll /usr/bin/jruby
lrwxrwxrwx 1 root root 23 2012-06-29 21:30 /usr/bin/jruby -> /etc/alternatives/jruby*
$ ruby helloWorld.rb
helloWorld.rb:3:in `require': no such file to load -- java (LoadError)
from helloWorld.rb:3
$ jruby helloWorld.rb
helloWorld.rb:4:in `require': no such file to load -- peach (LoadError)
from helloWorld.rb:4

$ gem query

*** LOCAL GEMS ***


#helloWorld.rb
require 'yaml'
require 'java'
require 'peach'

puts 'hello world'

#dataset = ENV['DATASET'] 
#puts "dataset " + dataset