我希望有人可以澄清这个关于使用我拥有的宝石工具的问题。
我正在尝试运行一些使用rb-libsvm
的代码,并使用gem install
成功安装了此代码;当我使用gem list
时,会列出rb-libsvm
。但是,在代码中,命令./svm-predict
会引发以下错误:
sh: ./svm-train: No such file or directory
sh: ./svm-predict: No such file or directory
我需要在计算机上运行宝石吗?
答案 0 :(得分:0)
我不确定您是如何在shell上运行它的,您可以通过以下https://github.com/febeling/rb-libsvm
文档中提供的示例代码在irb
中对其进行测试
require 'libsvm'
# This library is namespaced.
problem = Libsvm::Problem.new
parameter = Libsvm::SvmParameter.new
parameter.cache_size = 1 # in megabytes
parameter.eps = 0.001
parameter.c = 10
examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
labels = [1, -1]
problem.set_examples(labels, examples)
model = Libsvm::Model.train(problem, parameter)
pred = model.predict(Libsvm::Node.features(1, 1, 1))
puts "Example [1, 1, 1] - Predicted #{pred}"
答案 1 :(得分:0)
gem不包含命令行工具。请参阅README。
为此,请考虑安装整个包。尽管名称为libsvm,但它实际上是一个包含命令行工具和Python绑定的包,以及适当的库。