Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
cp310-manylinux_x86_64 cp310-manylinux_aarch64 cp310-macosx_x86_64 cp310-win_amd64
cp311-manylinux_x86_64 cp311-manylinux_aarch64 cp311-macosx_x86_64 cp311-win_amd64
cp312-manylinux_x86_64 cp312-manylinux_aarch64 cp312-macosx_x86_64 cp312-win_amd64
cp313-manylinux_x86_64 cp313-manylinux_aarch64 cp313-macosx_x86_64 cp313-win_amd64
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 20.8b1
rev: 24.8.0
hooks:
- id: black
language_version: python3
Expand Down
4 changes: 2 additions & 2 deletions build_tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-r ../requirements.txt
pytest
pre-commit
black==20.8b1
black==24.8.0
click==8.0.3
flake8==3.8.4
pytest-cov
lightgbm
xgboost
cython>=0.28.5
cython>=3.0,<3.1
1 change: 0 additions & 1 deletion deepforest/_binner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/ensemble/_hist_gradient_boosting/binning.py
"""


__all__ = ["Binner"]

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion deepforest/_estimator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""A wrapper on the base estimator for the naming consistency."""


__all__ = ["Estimator"]

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion deepforest/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
class is designed to support the partial mode in deep forest.
"""


__all__ = ["Buffer"]

import os
Expand Down
1 change: 0 additions & 1 deletion deepforest/_layer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implementation of the cascade layer in deep forest."""


__all__ = [
"BaseCascadeLayer",
"ClassificationCascadeLayer",
Expand Down
1 change: 0 additions & 1 deletion deepforest/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implement utilities used in deep forest."""


import numpy as np
from datetime import datetime

Expand Down
31 changes: 18 additions & 13 deletions deepforest/cascade.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implementation of Deep Forest."""


__all__ = ["CascadeForestClassifier", "CascadeForestRegressor"]

import numbers
Expand Down Expand Up @@ -770,10 +769,12 @@ def fit(self, X, y, sample_weight=None):
X, y = check_X_y(
X,
y,
multi_output=True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False,
multi_output=(
True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False
),
)

self._check_input(X, y)
Expand Down Expand Up @@ -1427,10 +1428,12 @@ def fit(self, X, y, sample_weight=None):
X, y = check_X_y(
X,
y,
multi_output=True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False,
multi_output=(
True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False
),
)
# Check the input for classification
y = self._encode_class_labels(y)
Expand Down Expand Up @@ -1639,10 +1642,12 @@ def fit(self, X, y, sample_weight=None):
X, y = check_X_y(
X,
y,
multi_output=True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False,
multi_output=(
True
if type_of_target(y)
in ("continuous-multioutput", "multiclass-multioutput")
else False
),
)

# Check the input for regression
Expand Down
13 changes: 10 additions & 3 deletions deepforest/forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/ensemble/_forest.py
"""


__all__ = [
"RandomForestClassifier",
"RandomForestRegressor",
Expand Down Expand Up @@ -618,7 +617,11 @@ def predict_proba(self, X):
for j in np.atleast_1d(self.n_classes_)
]
lock = threading.Lock()
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem",)(
Parallel(
n_jobs=n_jobs,
verbose=self.verbose,
require="sharedmem",
)(
delayed(_accumulate_prediction)(
self.features[i],
self.thresholds[i],
Expand Down Expand Up @@ -801,7 +804,11 @@ def predict(self, X):

# Parallel loop
lock = threading.Lock()
Parallel(n_jobs=n_jobs, verbose=self.verbose, require="sharedmem",)(
Parallel(
n_jobs=n_jobs,
verbose=self.verbose,
require="sharedmem",
)(
delayed(_accumulate_prediction)(
self.features[i],
self.thresholds[i],
Expand Down
2 changes: 1 addition & 1 deletion deepforest/tree/_splitter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ cdef class BaseSparseSplitter(Splitter):
end_negative, start_positive)


cdef int compare_SIZE_t(const void* a, const void* b) nogil:
cdef int compare_SIZE_t(const void* a, const void* b) noexcept nogil:
"""Comparison function for sort."""
return <int>((<SIZE_t*>a)[0] - (<SIZE_t*>b)[0])

Expand Down
11 changes: 6 additions & 5 deletions deepforest/tree/_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cdef extern from "numpy/arrayobject.h":
int nd, np.npy_intp* dims,
np.npy_intp* strides,
void* data, int flags, object obj)
int PyArray_SetBaseObject(np.ndarray arr, PyObject* obj)

# =============================================================================
# Types and constants
Expand Down Expand Up @@ -137,8 +138,8 @@ cdef class DepthFirstTreeBuilder(TreeBuilder):
cdef int init_leaf_capacity

if tree.max_depth <= 10:
init_internal_capacity = (2 ** (tree.max_depth + 1)) - 1
init_leaf_capacity = (2 ** (tree.max_depth + 1)) - 1
init_internal_capacity = (1 << (tree.max_depth + 1)) - 1
init_leaf_capacity = (1 << (tree.max_depth + 1)) - 1
else:
init_internal_capacity = 2047
init_leaf_capacity = 2047
Expand Down Expand Up @@ -905,7 +906,7 @@ cdef class Tree:
cdef np.ndarray arr
arr = np.PyArray_SimpleNewFromData(3, shape, np.NPY_DOUBLE, self.value)
Py_INCREF(self)
arr.base = <PyObject*> self
PyArray_SetBaseObject(arr, <PyObject*> self)
return arr

cdef np.ndarray _get_node_ndarray(self):
Expand All @@ -924,7 +925,7 @@ cdef class Tree:
arr = PyArray_NewFromDescr(<PyTypeObject *> np.ndarray,
<np.dtype> NODE_DTYPE, 1, shape,
strides, <void*> self.nodes,
np.NPY_DEFAULT, None)
0, None)
Py_INCREF(self)
arr.base = <PyObject*> self
PyArray_SetBaseObject(arr, <PyObject*> self)
return arr
1 change: 0 additions & 1 deletion deepforest/tree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/tree/_classes.py
"""


__all__ = [
"DecisionTreeClassifier",
"DecisionTreeRegressor",
Expand Down
1 change: 0 additions & 1 deletion deepforest/utils/kfoldwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Implementation of the estimator wrapper to support customized base estimators.
"""


__all__ = ["KFoldWrapper"]

import copy
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
requires = [
"setuptools>=61,<70",
"wheel",
"numpy==1.26.4",
"Cython>=0.28.5,<3.0",
"numpy>=2.1.1,<3",
"Cython>=3.0,<3.1",
"oldest-supported-numpy",
"scipy>=1.3.2",
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.14.6
numpy>=1.21,<3
scipy>=1.1.0
joblib>=0.11
scikit-learn>=1.0
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
],
python_requires=">=3.10",
python_requires=">=3.10,<3.14",
install_requires=[
"numpy>=1.14.6,<2.0",
"numpy>=1.21,<3",
"scipy>=1.1.0",
"joblib>=0.11",
"scikit-learn>=1.0,<1.6",
],
setup_requires=["cython", "numpy>=1.21,<2.0"],
setup_requires=["Cython>=3.0,<3.1", "numpy>=1.21,<3"],
)
Loading