homebrew-core/Formula/vowpal-wabbit.rb

98 lines
3.8 KiB
Ruby

class VowpalWabbit < Formula
desc "Online learning algorithm"
homepage "https://github.com/VowpalWabbit/vowpal_wabbit"
# pull from git tag to get submodules
url "https://github.com/VowpalWabbit/vowpal_wabbit.git",
tag: "8.11.0",
revision: "96ed8316de4391b77f4f29af69f885552a644769"
license "BSD-3-Clause"
revision 1
head "https://github.com/VowpalWabbit/vowpal_wabbit.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_monterey: "12d34acaa90b6dad0f9424623131ab9cc17afb22ac4ca3c2cfc78cd3bb87f444"
sha256 cellar: :any, arm64_big_sur: "b409d89003bcdf98e7ed731a30ebb197e06f151b75ac4f6f3906572a431eeb1f"
sha256 cellar: :any, monterey: "76f0db5043b1538fd89d46feb993a874859a438d59f2ea9725bc7dc4551fbe10"
sha256 cellar: :any, big_sur: "aa088ed972a626863ef2535ce3f2929ddaf7d5e64d8a7944cbff8d7d03714804"
sha256 cellar: :any, catalina: "6340e02d379e0381d079cf8b5c6ae64bce24fbd6d808a0d5ecc0734d08094893"
sha256 cellar: :any, mojave: "d9bcb3816f6e0cb53dad0ceb692fcd44c277471f500ea443ef4af25f733e2e48"
sha256 cellar: :any_skip_relocation, x86_64_linux: "c906f6f596bbc7e075ab1e192458dddf0bc5370d315d93e5d7f02aedbd36bbb2"
end
depends_on "cmake" => :build
depends_on "flatbuffers" => :build
depends_on "rapidjson" => :build
depends_on "spdlog" => :build
depends_on "boost"
depends_on "fmt"
depends_on "zlib"
def install
ENV.cxx11
# The project provides a Makefile, but it is a basic wrapper around cmake
# that does not accept *std_cmake_args.
# The following should be equivalent, while supporting Homebrew's standard args.
mkdir "build" do
system "cmake", "..", *std_cmake_args,
"-DBUILD_TESTS=OFF",
"-DRAPIDJSON_SYS_DEP=ON",
"-DFMT_SYS_DEP=ON",
"-DSPDLOG_SYS_DEP=ON",
"-DBUILD_FLATBUFFERS=ON"
system "make", "install"
end
bin.install Dir["utl/*"]
rm bin/"active_interactor.py"
rm bin/"vw-validate.html"
rm bin/"clang-format"
rm_r bin/"flatbuffer"
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