Skip to content

Commit

Permalink
Merge pull request #8 from Yashwants19/travis-mac
Browse files Browse the repository at this point in the history
Remove boost-program-options and fix macOS support.
  • Loading branch information
rcurtin authored Sep 7, 2020
2 parents 9b65589 + fce3705 commit d2b4890
Show file tree
Hide file tree
Showing 112 changed files with 3,019 additions and 1,147 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.so
*.so.*
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
sudo: required
dist: xenial

language: go
go:
- "1.14"
go_import_path: mlpack.org/v1/mlpack

before_install:
- go get -u gonum.org/v1/gonum/...
- make deps setup_armadillo download build sudo_install clean
matrix :
include :
- os : linux
dist : xenial
before_install:
- go get -u gonum.org/v1/gonum/...
- make deps setup_armadillo download build sudo_install clean

- os : osx
dist : xcode9.4
before_install:
- go get -u gonum.org/v1/gonum/...
- HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake curl git unzip openblas armadillo boost
- make download build sudo_install clean
script:
- go test -v . ./tests
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ RUN apt-get update -qq && \
apt-get install -y --no-install-recommends sudo \
unzip build-essential cmake git pkg-config \
curl ca-certificates libcurl4-openssl-dev libssl-dev \
libboost-math-dev libboost-program-options-dev \
libboost-test-dev libboost-serialization-dev libarmadillo-dev && \
libboost-math-dev libboost-test-dev libboost-serialization-dev libarmadillo-dev && \
apt-get clean && rm -rf /usr/share/man/?? && rm -rf /usr/share/man/??_* && \
rm -rf /var/lib/apt/lists/* && rm -rf /usr/share/locale/* && \
rm -rf /var/cache/debconf/*-old && rm -rf /usr/share/doc/*
Expand Down
62 changes: 20 additions & 42 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,26 @@
BSD 3-Clause License
Copyright (c) 2007-2020 mlpack contributors. All rights reserved.

mlpack is provided without any warranty of fitness for any purpose. You
can redistribute the library and/or modify it under the terms of the 3-clause
BSD license. The text of the 3-clause BSD license is contained below.

mlpack contains some reproductions of the source code of Armadillo, which is
licensed under the Mozilla Public License v2.0 (MPL2). This code is found in
src/mlpack/core/arma_extend/ and more details on the licensing are available
there.

mlpack also contains some reproductions of the source code of Boost, which is
licensed under the Boost Software License, version 1.0. This code is found in
src/mlpack/core/boost_backport/ and more details on the licensing are available
there.

mlpack may contain some usage of the source code of stb, which is licensed
under the MIT License and the Public Domain (www.unlicense.org). This code
is used in src/mlpack/core/data/load_image.hpp.

----
Copyright (c) 2007-2020, mlpack contributors (see COPYRIGHT.txt)
All rights reserved.

Redistribution and use of mlpack in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 changes: 23 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.PHONY: test deps download build clean docker

# mlpack version to use.
MLPACK_VERSION?=3.3.2
MLPACK_VERSION?=3.4.0

# armadillo version to use.
ARMA_VERSION?=8.400.0
Expand All @@ -14,11 +14,9 @@ GOVERSION?=1.13.1
TMP_DIR?=/tmp/

# Package list for each well-known Linux distribution
RPMS = cmake curl git unzip boost-devel boost-test boost-program-options \
boost-math armadillo-devel
RPMS = cmake curl git unzip boost-devel boost-test boost-math armadillo-devel
DEBS = unzip build-essential cmake curl git pkg-config libboost-math-dev \
libboost-program-options-dev libboost-test-dev libboost-serialization-dev \
libarmadillo-dev
libboost-test-dev libboost-serialization-dev libarmadillo-dev

# Detect Linux distribution
UNAME_S := $(shell uname -s)
Expand Down Expand Up @@ -57,59 +55,50 @@ deps_debian:

# Download and install Armadillo.
setup_armadillo:
rm -rf $(TMP_DIR)armadillo
mkdir $(TMP_DIR)armadillo
cd $(TMP_DIR)armadillo
rm -rf $(TMP_DIR)armadillo && mkdir $(TMP_DIR)armadillo && cd $(TMP_DIR)armadillo && \
curl https://ftp.fau.de/macports/distfiles/armadillo/armadillo-$(ARMA_VERSION).tar.xz \
| tar -xvJ && cd armadillo* && \
cmake . && make && sudo make install && cd .. && rm -rf armadillo*
| tar -xvJ && cd armadillo* && \
cmake . && make && sudo make install && cd .. && rm -rf armadillo*

# Download mlpack source.
download:
rm -rf $(TMP_DIR)mlpack
mkdir $(TMP_DIR)mlpack
cd $(TMP_DIR)mlpack
curl -Lo mlpack.zip https://www.mlpack.org/files/mlpack-$(MLPACK_VERSION).tar.gz
tar -xvzpf mlpack.zip
rm mlpack.zip
cd -
rm -rf $(TMP_DIR)mlpack && mkdir $(TMP_DIR)mlpack && cd $(TMP_DIR)mlpack && \
curl -Lo mlpack.zip https://www.mlpack.org/files/mlpack-$(MLPACK_VERSION).tar.gz && \
tar -xvzpf mlpack.zip && rm mlpack.zip && cd -

# Build mlpack(go shared libraries).
build:
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION)
mkdir build
cd build
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION) && mkdir build && cd build && \
cmake -D BUILD_TESTS=OFF \
-D BUILD_JULIA_BINDINGS=OFF \
-D BUILD_PYTHON_BINDINGS=OFF \
-D BUILD_CLI_EXECUTABLES=OFF \
-D BUILD_GO_BINDINGS=OFF \
-D BUILD_GO_SHLIB=ON ..
$(MAKE) -j $(shell nproc --all)
$(MAKE) preinstall
cd -
-D BUILD_GO_SHLIB=ON .. && \
$(MAKE) -j $(shell nproc --all) && $(MAKE) preinstall && cd -

# Cleanup temporary build files.
clean:
go clean --cache
rm -rf $(TMP_DIR)armadillo
rm -rf $(TMP_DIR)mlpack
go clean --cache && rm -rf $(TMP_DIR)armadillo && rm -rf $(TMP_DIR)mlpack

# Do everything.
install:
@make deps
ifneq ($(UNAME_S),Darwin)
@make deps
ifneq ($(UNAME_S),Darwin)
@make setup_armadillo
endif
endif
@make download build sudo_install clean test


# Install system wide.
sudo_install:
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION)/build
sudo $(MAKE) install
sudo ldconfig
cd -
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION)/build && sudo $(MAKE) install && cd -
ifneq ($(UNAME_S),Darwin)
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION)/build && sudo ldconfig && cd -
else
cd $(TMP_DIR)mlpack/mlpack-$(MLPACK_VERSION)/build && \
sudo update_dyld_shared_cache && cd -
endif
# Runs tests.
test:
go test -v . ./tests
Expand Down
26 changes: 2 additions & 24 deletions adaboost.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ package mlpack
*/
import "C"

import (
"gonum.org/v1/gonum/mat"
"runtime"
"unsafe"
)
import "gonum.org/v1/gonum/mat"

type AdaboostOptionalParam struct {
InputModel *adaBoostModel
Expand All @@ -38,23 +34,6 @@ func AdaboostOptions() *AdaboostOptionalParam {
}
}

type adaBoostModel struct {
mem unsafe.Pointer
}

func (m *adaBoostModel) allocAdaBoostModel(identifier string) {
m.mem = C.mlpackGetAdaBoostModelPtr(C.CString(identifier))
runtime.KeepAlive(m)
}

func (m *adaBoostModel) getAdaBoostModel(identifier string) {
m.allocAdaBoostModel(identifier)
}

func setAdaBoostModel(identifier string, ptr *adaBoostModel) {
C.mlpackSetAdaBoostModelPtr(C.CString(identifier), (unsafe.Pointer)(ptr.mem))
}

/*
This program implements the AdaBoost (or Adaptive Boosting) algorithm. The
variant of AdaBoost implemented here is AdaBoost.MH. It uses a weak learner,
Expand Down Expand Up @@ -83,7 +62,7 @@ func setAdaBoostModel(identifier string, ptr *adaBoostModel) {
Note: the following parameter is deprecated and will be removed in mlpack
4.0.0: "Output".
Use "Predictions" instead of "Output".
For example, to run AdaBoost on an input dataset data with labels labelsand
perceptrons as the weak learner type, storing the trained model in model, one
could use the following command:
Expand All @@ -107,7 +86,6 @@ func setAdaBoostModel(identifier string, ptr *adaBoostModel) {
_, _, predictions, _ := mlpack.Adaboost(param)
Input parameters:
- InputModel (adaBoostModel): Input AdaBoost model.
Expand Down
26 changes: 2 additions & 24 deletions approx_kfn.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ package mlpack
*/
import "C"

import (
"gonum.org/v1/gonum/mat"
"runtime"
"unsafe"
)
import "gonum.org/v1/gonum/mat"

type ApproxKfnOptionalParam struct {
Algorithm string
Expand Down Expand Up @@ -42,23 +38,6 @@ func ApproxKfnOptions() *ApproxKfnOptionalParam {
}
}

type approxkfnModel struct {
mem unsafe.Pointer
}

func (m *approxkfnModel) allocApproxKFNModel(identifier string) {
m.mem = C.mlpackGetApproxKFNModelPtr(C.CString(identifier))
runtime.KeepAlive(m)
}

func (m *approxkfnModel) getApproxKFNModel(identifier string) {
m.allocApproxKFNModel(identifier)
}

func setApproxKFNModel(identifier string, ptr *approxkfnModel) {
C.mlpackSetApproxKFNModelPtr(C.CString(identifier), (unsafe.Pointer)(ptr.mem))
}

/*
This program implements two strategies for furthest neighbor search. These
strategies are:
Expand Down Expand Up @@ -93,7 +72,7 @@ func setApproxKFNModel(identifier string, ptr *approxkfnModel) {
Results for each query point can be stored with the "Neighbors" and
"Distances" output parameters. Each row of these output matrices holds the k
distances or neighbor indices for each query point.
For example, to find the 5 approximate furthest neighbors with reference_set
as the reference set and query_set as the query set using DrusillaSelect,
storing the furthest neighbor indices to neighbors and the furthest neighbor
Expand Down Expand Up @@ -131,7 +110,6 @@ func setApproxKFNModel(identifier string, ptr *approxkfnModel) {
_, neighbors, _ := mlpack.ApproxKfn(param)
Input parameters:
- Algorithm (string): Algorithm to use: 'ds' or 'qdafn'. Default value
Expand Down
4 changes: 2 additions & 2 deletions arma_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package mlpack

/*
#cgo CFLAGS: -I. -I/capi -g -Wall -Wno-unused-variable
#cgo LDFLAGS: -L. -lgo_util
#cgo LDFLAGS: -L. -lmlpack_go_util
#include <stdlib.h>
#include <stdio.h>
#include <capi/cli_util.h>
#include <capi/io_util.h>
#include <capi/arma_util.h>
*/
import "C"
Expand Down
Loading

0 comments on commit d2b4890

Please sign in to comment.