Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scikit-garden/scikit-garden
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: deephyper/scikit-garden
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 19, 2022

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    d8961c1 View commit details

Commits on Sep 13, 2023

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    f946dac View commit details

Commits on Sep 20, 2023

  1. updating setup format

    Deathn0t committed Sep 20, 2023

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    f400283 View commit details
  2. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    fc8d4d9 View commit details
Showing with 70 additions and 62 deletions.
  1. +1 −0 .gitignore
  2. +51 −44 setup.py
  3. +18 −18 skgarden/forest.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ dist/
*.so
site/
.env/*
.eggs/
95 changes: 51 additions & 44 deletions setup.py
Original file line number Diff line number Diff line change
@@ -6,30 +6,33 @@
from setuptools.command.build_ext import build_ext


DISTNAME = 'scikit-garden'
DISTNAME = "scikit-garden"
DESCRIPTION = "A garden of scikit-learn compatible trees"
URL = 'https://github.com/scikit-garden/scikit-garden'
MAINTAINER = 'Manoj Kumar'
MAINTAINER_EMAIL = 'mks542@nyu.edu'
LICENSE = 'new BSD'
VERSION = '0.1.3'
URL = "https://github.com/scikit-garden/scikit-garden"
MAINTAINER = "Manoj Kumar"
MAINTAINER_EMAIL = "mks542@nyu.edu"
LICENSE = "new BSD"
VERSION = "0.1.3"

libraries = []
if os.name == 'posix':
libraries.append('m')
if os.name == "posix":
libraries.append("m")

extensions = []
for name in ['_tree', '_splitter', '_criterion', '_utils']:
extensions.append(Extension(
'skgarden.mondrian.tree.{}'.format(name),
sources=['skgarden/mondrian/tree/{}.pyx'.format(name)],
libraries=libraries,
extra_compile_args=['-O3'],
))
for name in ["_tree", "_splitter", "_criterion", "_utils"]:
extensions.append(
Extension(
"skgarden.mondrian.tree.{}".format(name),
sources=["skgarden/mondrian/tree/{}.pyx".format(name)],
libraries=libraries,
extra_compile_args=["-O3"],
)
)


class CustomBuildExtCommand(build_ext):
"""build_ext command for use when numpy headers are needed."""

def run(self):
# Import numpy here, only when headers are needed
import numpy
@@ -43,36 +46,40 @@ def finalize_options(self):
# Import Cython here, only when we need to cythonize extensions
if self.distribution.ext_modules:
from Cython.Build.Dependencies import cythonize
self.distribution.ext_modules[:] = cythonize(self.distribution.ext_modules, force=self.force)

self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules, force=self.force
)
super().finalize_options()


if __name__ == "__main__":
setup(name=DISTNAME,
cmdclass={'build_ext': CustomBuildExtCommand},
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
packages=find_packages(),
include_package_data=True,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
zip_safe=False, # the package can run out of an .egg file
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved',
'Programming Language :: C',
'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS'
],
install_requires=["numpy", "scipy", "scikit-learn>=0.22", "six"],
setup_requires=["Cython>=0.23", "numpy", "setuptools>=18"],
ext_modules=extensions,
)
setup(
name=DISTNAME,
cmdclass={"build_ext": CustomBuildExtCommand},
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
packages=find_packages(),
include_package_data=True,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
zip_safe=False, # the package can run out of an .egg file
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: C",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
],
install_requires=["numpy", "scipy", "scikit-learn>=0.22", "six"],
setup_requires=["Cython>=0.23,<3.0.0", "numpy", "setuptools>=18"],
ext_modules=extensions,
)
36 changes: 18 additions & 18 deletions skgarden/forest.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
from sklearn.utils import check_random_state
from sklearn.utils import check_array
from sklearn.utils import compute_sample_weight
from sklearn.utils.fixes import _joblib_parallel_args
from sklearn.utils.multiclass import check_classification_targets
from sklearn.utils.validation import check_is_fitted
from sklearn.utils.validation import _check_sample_weight
@@ -596,10 +595,11 @@ def apply(self, X):
return the index of the leaf x ends up in.
"""
X = self._validate_X_predict(X)
results = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
**_joblib_parallel_args(prefer="threads"))(
delayed(tree.apply)(X, check_input=False)
for tree in self.estimators_)
results = Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
prefer="threads"
)(delayed(tree.apply)(X, check_input=False) for tree in self.estimators_)

return np.array(results).T

@@ -623,10 +623,11 @@ def decision_path(self, X):
gives the indicator value for the i-th estimator.
"""
X = self._validate_X_predict(X)
indicators = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
**_joblib_parallel_args(prefer='threads'))(
delayed(tree.decision_path)(X, check_input=False)
for tree in self.estimators_)
indicators = Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
prefer='threads',
)(delayed(tree.decision_path)(X, check_input=False) for tree in self.estimators_)

n_nodes = [0]
n_nodes.extend([i.shape[1] for i in indicators])
@@ -739,9 +740,11 @@ def fit(self, X, y, sample_weight=None):
# that case. However, for joblib 0.12+ we respect any
# parallel_backend contexts set at a higher level,
# since correctness does not rely on using threads.
trees = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,
**_joblib_parallel_args(prefer='threads'))(
delayed(_parallel_build_trees)(
trees = Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
prefer='threads',
)(delayed(_parallel_build_trees)(
t, self, X, y, sample_weight, i, len(trees),
verbose=self.verbose, class_weight=self.class_weight,
n_samples_bootstrap=n_samples_bootstrap)
@@ -790,8 +793,7 @@ def feature_importances_(self):
"""
check_is_fitted(self)

all_importances = Parallel(n_jobs=self.n_jobs,
**_joblib_parallel_args(prefer='threads'))(
all_importances = Parallel(n_jobs=self.n_jobs, prefer='threads')(
delayed(getattr)(tree, 'feature_importances_')
for tree in self.estimators_ if tree.tree_.node_count > 1)

@@ -1016,8 +1018,7 @@ def predict_proba(self, X):
all_proba = [np.zeros((X.shape[0], j), dtype=np.float64)
for j in np.atleast_1d(self.n_classes_)]
lock = threading.Lock()
Parallel(n_jobs=n_jobs, verbose=self.verbose,
**_joblib_parallel_args(require="sharedmem"))(
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem")(
delayed(_accumulate_prediction)(e.predict_proba, X, all_proba,
lock)
for e in self.estimators_)
@@ -1121,8 +1122,7 @@ def predict(self, X):

# Parallel loop
lock = threading.Lock()
Parallel(n_jobs=n_jobs, verbose=self.verbose,
**_joblib_parallel_args(require="sharedmem"))(
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem")(
delayed(_accumulate_prediction)(e.predict, X, [y_hat], lock)
for e in self.estimators_)