Skip to content

fix type error in queue.hpp, improve distributability and documentation #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
713e25b
add simple test notebook
csinva Oct 14, 2021
42db987
remove platform-specific wheel
keyan3 Oct 14, 2021
22b396b
add wheel building setup
keyan3 Oct 14, 2021
7cd192a
fix value-allocator mismatch for clang
keyan3 Nov 2, 2021
df04eac
remove wheels from github
keyan3 Nov 2, 2021
4026fec
update readme
keyan3 Nov 2, 2021
96bf347
note requirements for python extension
keyan3 Nov 2, 2021
c1a3d5c
test installation in build-wheels.sh
keyan3 Nov 3, 2021
bcad3bb
update install test nb
keyan3 Nov 3, 2021
515c8d9
first draft based on examples
keyan3 Nov 5, 2021
eda65de
Merge pull request #1 from keyan3/cibuildwheel
keyan3 Nov 5, 2021
14a739a
3.10->3.10.0
keyan3 Nov 5, 2021
e02ae7f
add package eps
keyan3 Nov 5, 2021
c20fd01
make apt-get sudo
keyan3 Nov 5, 2021
8cd300e
use before_all correctly
keyan3 Nov 5, 2021
2ed7c58
before_all_macos
keyan3 Nov 5, 2021
86e0a80
proper multi-line yaml syntax
keyan3 Nov 5, 2021
6721523
no sudo inside docker
keyan3 Nov 5, 2021
48cc925
wiredtiger autogen
keyan3 Nov 5, 2021
f63768b
install rsync before building wiredtiger
keyan3 Nov 5, 2021
f14b90d
don't attempt aarch64
keyan3 Nov 5, 2021
86f9927
don't attempt i686
keyan3 Nov 5, 2021
628b51d
increment version number for new wheels
keyan3 Nov 5, 2021
76f2d58
don't attempt musllinux
keyan3 Nov 5, 2021
44fa0fc
Merge pull request #2 from keyan3/cibuildwheel-1
keyan3 Nov 5, 2021
2acf4fa
add new python options to readme
keyan3 Nov 5, 2021
cc63408
add ds store to gitignore
keyan3 Nov 5, 2021
8adfb1a
add metadata for pypi
keyan3 Nov 7, 2021
1ab8ccf
train test split in demo notebook
keyan3 Nov 8, 2021
4a00bc1
build-wheels replaced by cibuildwheel
keyan3 Nov 8, 2021
0c7b380
update author info
keyan3 Nov 8, 2021
9ca31f9
fix email
keyan3 Nov 8, 2021
9d1fde0
change package name
keyan3 Feb 5, 2022
cd1a6ae
make name importable
keyan3 Feb 5, 2022
9d80930
0.2
keyan3 Feb 5, 2022
a640eca
remove dash in name
keyan3 Feb 7, 2022
91da764
extension name matching file name
keyan3 Feb 7, 2022
f3d9475
file name reuse issue
keyan3 Feb 7, 2022
19b0067
update readme for new package name
keyan3 Feb 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
66 changes: 66 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

# Run manually
on: workflow_dispatch

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Get deps (macOS)
if: matrix.os == 'macos-10.15'
run: |
brew install boost
brew install gmp
brew install tbb
brew install wiredtiger

- name: Build wheels
uses: pypa/[email protected]
# to supply options, put them in 'env', like:
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_24
CIBW_SKIP: "*-musllinux_x86_64"
CIBW_BEFORE_ALL_LINUX: >
apt-get update -y &&
apt-get install -y libboost-all-dev &&
apt-get install -y libgmp-dev &&
apt-get install -y libgmp10 &&
apt-get install -y ocl-icd-opencl-dev &&
apt-get install -y libtbb-dev &&
apt-get install -y wiredtiger

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ m4
libtool
.deps
gosdt
gosdt_test
gosdt_test
*.DS_Store
wheelhouse/*
47 changes: 28 additions & 19 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -264,15 +264,12 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/compile \
$(top_srcdir)/build/config.guess \
$(top_srcdir)/build/config.sub $(top_srcdir)/build/depcomp \
$(top_srcdir)/build/install-sh $(top_srcdir)/build/missing \
build/compile build/config.guess build/config.sub \
README.md build/compile build/config.guess build/config.sub \
build/depcomp build/install-sh build/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
Expand All @@ -287,6 +284,8 @@ am__post_remove_distdir = $(am__remove_distdir)
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
# Exists only to be overridden by the user if desired.
AM_DISTCHECK_DVI_TARGET = dvi
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
Expand All @@ -307,6 +306,8 @@ CL_CFLAGS = @CL_CFLAGS@
CL_LIBS = @CL_LIBS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
Expand All @@ -319,6 +320,7 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
GREP = @GREP@
HAVE_CXX11 = @HAVE_CXX11@
Expand Down Expand Up @@ -395,6 +397,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
Expand Down Expand Up @@ -1248,7 +1251,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files

distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am

Expand Down Expand Up @@ -1307,6 +1309,10 @@ dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)

dist-zstd: distdir
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
$(am__post_remove_distdir)

dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
Expand Down Expand Up @@ -1349,6 +1355,8 @@ distcheck: dist
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
*.tar.zst*) \
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
Expand All @@ -1364,7 +1372,7 @@ distcheck: dist
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
Expand Down Expand Up @@ -1596,17 +1604,18 @@ uninstall-am: uninstall-binPROGRAMS
check-am clean clean-binPROGRAMS clean-cscope clean-generic \
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-compile distclean-generic \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
dist-zstd distcheck distclean distclean-compile \
distclean-generic distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-binPROGRAMS install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-binPROGRAMS

.PRECIOUS: Makefile

Expand Down
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Currently supported as a Python extension.
## Installing Dependencies
Refer to [**Dependency Installation**](/doc/dependencies.md##Installation)

## As a Stand-Alone Command Line Program
## Stand-Alone Command Line Program
### Installation
```
./autobuild --install
Expand All @@ -38,15 +38,19 @@ For examples of dataset files, refer to `experiments/datasets/compas/binned.csv`
For an example configuration file, refer to `experiments/configurations/compas.json`.
For documentation on the configuration file, refer to [**Dependency Installation**](/doc/configuration.md)

## As a Python Library with C++ Extensions
### Build and Installation
## Python-wrapped C++ Extension
### Installation
#### x86 Linux or macOS
```
pip install gosdt-deprecated
```
#### Other platforms
```
./autobuild --install-python
```
_If you have multiple Python installations, please make sure to build and install using the same Python installation as the one intended for interacting with this library._


### Importing the C++ Extension
### C++ extension example usage
```python
import gosdt

Expand All @@ -56,7 +60,6 @@ with open ("data.csv", "r") as data_file:
with open ("config.json", "r") as config_file:
config = config_file.read()


print("Config:", config)
print("Data:", data)

Expand All @@ -69,7 +72,9 @@ print("Iterations: ", gosdt.iterations())
print("Graph Size: ", gosdt.size())
```

### Importing Extension with local Python Wrapper
### With local Python wrapper
This module is local and not packaged; the following example assumes the user is working in the directory `GeneralizedOptimalSparseDecisionTrees/python`.

```python
import pandas as pd
import numpy as np
Expand All @@ -96,6 +101,36 @@ print("Training Accuracy: {}".format(training_accuracy))
print(model.tree)
```

## Scikit-learn-style Python module
This option is currently only supported on x86-running Linux or macOS platforms.

### Installation
```
pip install imodels
```
_[imodels](https://github.com/csinva/imodels) is an interpretable machine learning package containing gosdt among many others ._

### Usage
```python
import pandas as pd
import numpy as np
from imodels import GOSDTClassifier

dataframe = pd.DataFrame(pd.read_csv("experiments/datasets/monk_2/data.csv"))

X = dataframe[dataframe.columns[:-1]]
y = dataframe[dataframe.columns[-1:]]

model = GOSDT(regularization=0.1, time_limit=3600, verbose=True)
model.fit(X, y)
print("Execution Time: {}".format(model.time))

prediction = model.predict(X)
training_accuracy = model.score(X, y)
print("Training Accuracy: {}".format(training_accuracy))
print(model.tree)
```

---

# Development
Expand Down Expand Up @@ -148,6 +183,9 @@ Refer to [**Dependency Installation**](/doc/dependencies.md##Installation)
```
For a full list of build options, run `./autobuild --help`

### Building wheels for distribution (C++ extension)
Invoking `.github/workflows/wheels.yml` via Github Actions will output wheels for x86 Linux and macOS platforms using [cibuildwheel](https://github.com/pypa/cibuildwheel), as well as the source distribution.

---

# Configuration
Expand Down
19 changes: 19 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2018 The Python Packaging Authority

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gmpy2
matplotlib
numpy
pandas
sklearn
sortedcontainers
Loading