homebrew-core/Formula/vowpal-wabbit.rb

95 lines
3.2 KiB
Ruby

class VowpalWabbit < Formula
desc "Online learning algorithm"
homepage "https://github.com/JohnLangford/vowpal_wabbit"
url "https://github.com/JohnLangford/vowpal_wabbit/archive/8.4.0.tar.gz"
sha256 "8624c33fd516e8b738fbbc6fc49f62ac03f97af183dbecff298162b4bf5736d5"
revision 2
bottle do
cellar :any
sha256 "1c75a20fd7b7c0ce685f1a56e4c9c79349bc26943b3cd4bcd906764b757017be" => :high_sierra
sha256 "7ef502ea64c6c0eaafe328037354ff317cd4432dff8b68d2669c85688b2dd145" => :sierra
sha256 "689048beda8fffbe1a7bb888bfef4cdccaf36e5f03eb6bed172efe82ebbc58e8" => :el_capitan
sha256 "2e7c5709faf8fe35f65c676cf994e9d6e3928b9f609d6820f78224b0276278d0" => :yosemite
end
if MacOS.version < :mavericks
depends_on "boost" => "c++11"
else
depends_on "boost"
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
needs :cxx11
# Remove for > 8.4.0
# Fix "error: no member named 'codecvt_utf8_utf16' in namespace 'std'"
# Upstream commit from 22 Jul 2017 "make codecvt a universal include"
patch do
url "https://github.com/JohnLangford/vowpal_wabbit/commit/c632a1e09.patch?full_index=1"
sha256 "d7b7b3e594ad5ed4ee8c2a664ab98ec650df271d821b93842c1763c220459fe7"
end
def install
ENV.cxx11
ENV["AC_PATH"] = "#{HOMEBREW_PREFIX}/share"
system "./autogen.sh", "--prefix=#{prefix}",
"--with-boost=#{Formula["boost"].opt_prefix}"
system "make"
system "make", "install"
bin.install Dir["utl/*"]
rm bin/"active_interactor.py"
rm bin/"new_version"
rm bin/"vw-validate.html"
rm bin/"release.ps1"
end
test do
(testpath/"house_dataset").write <<~EOS
0 | price:.23 sqft:.25 age:.05 2006
1 2 'second_house | price:.18 sqft:.15 age:.35 1976
0 1 0.5 'third_house | price:.53 sqft:.32 age:.87 1924
EOS
system bin/"vw", "house_dataset", "-l", "10", "-c", "--passes", "25", "--holdout_off", "--audit", "-f", "house.model", "--nn", "5"
system bin/"vw", "-t", "-i", "house.model", "-d", "house_dataset", "-p", "house.predict"
(testpath/"csoaa.dat").write <<~EOS
1:1.0 a1_expect_1| a
2:1.0 b1_expect_2| b
3:1.0 c1_expect_3| c
1:2.0 2:1.0 ab1_expect_2| a b
2:1.0 3:3.0 bc1_expect_2| b c
1:3.0 3:1.0 ac1_expect_3| a c
2:3.0 d1_expect_2| d
EOS
system bin/"vw", "--csoaa", "3", "csoaa.dat", "-f", "csoaa.model"
system bin/"vw", "-t", "-i", "csoaa.model", "-d", "csoaa.dat", "-p", "csoaa.predict"
(testpath/"ect.dat").write <<~EOS
1 ex1| a
2 ex2| a b
3 ex3| c d e
2 ex4| b a
1 ex5| f g
EOS
system bin/"vw", "--ect", "3", "-d", "ect.dat", "-f", "ect.model"
system bin/"vw", "-t", "-i", "ect.model", "-d", "ect.dat", "-p", "ect.predict"
(testpath/"train.dat").write <<~EOS
1:2:0.4 | a c
3:0.5:0.2 | b d
4:1.2:0.5 | a b c
2:1:0.3 | b c
3:1.5:0.7 | a d
EOS
(testpath/"test.dat").write <<~EOS
1:2 3:5 4:1:0.6 | a c d
1:0.5 2:1:0.4 3:2 4:1.5 | c d
EOS
system bin/"vw", "-d", "train.dat", "--cb", "4", "-f", "cb.model"
system bin/"vw", "-t", "-i", "cb.model", "-d", "test.dat", "-p", "cb.predict"
end
end