Skip to content

Commit e05ca4f

Browse files
committed
Merge branch 'main' into 1.2.X
2 parents 01847ed + aeabb24 commit e05ca4f

24 files changed

+334
-212
lines changed

.github/workflows/build.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, windows-latest, macos-latest]
10+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
11+
runs-on: ${{ matrix.os }}
812

913
steps:
1014
- uses: actions/checkout@v4
1115

12-
- name: Set up Python 3.12
13-
uses: actions/setup-python@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
1418
with:
15-
python-version: '3.12'
19+
python-version: ${{ matrix.python-version }}
1620
cache: 'pip'
1721
cache-dependency-path: pyproject.toml
1822

@@ -25,13 +29,13 @@ jobs:
2529
2630
- name: Check formatting with black
2731
run: |
28-
black --line-length 100 --diff --color .
29-
black --line-length=100 --check .
32+
black --line-length 99 --diff --color .
33+
black --line-length=99 --check .
3034
3135
- name: Linting with flake8
3236
run: |
3337
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || exit 1
34-
flake8 . --count --exit-zero --max-line-length=100 --ignore=E402,W503 --statistics
38+
flake8 . --count --exit-zero --max-line-length=99 --ignore=E402,W503 --statistics
3539
3640
- name: Test with pytest
3741
run: |

.github/workflows/draft-pdf.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
paper-path: paper/paper.md
2020

2121
- name: Upload
22-
uses: actions/upload-artifact@v3
22+
uses: actions/upload-artifact@v4
2323
with:
2424
name: paper
2525
# This is the output path where Pandoc will write the compiled

.github/workflows/github-pages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414

1515
- name: Set up Python 3.12
16-
uses: actions/setup-python@v4
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: '3.12'
1919

.github/workflows/publish.yml

+42-51
Original file line numberDiff line numberDiff line change
@@ -13,73 +13,64 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macOS-latest]
16+
os: [ubuntu-latest, windows-latest, macos-latest]
1717

1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- uses: actions/setup-python@v4
22-
with:
23-
python-version: '3.12'
24-
25-
- name: Install cibuildwheel
26-
run: python -m pip install cibuildwheel==2.16.2
27-
28-
- name: Build wheels for Linux
29-
if: matrix.os == 'ubuntu-latest'
30-
run: |
31-
python -m cibuildwheel --output-dir wheelhouse
32-
env:
33-
CIBW_SKIP: "pp* *i686* *musllinux*"
34-
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
35-
CIBW_BEFORE_BUILD: pip install --verbose --editable .
36-
37-
- name: Build wheels for Windows
38-
if: matrix.os == 'windows-latest'
39-
run: |
40-
python -m cibuildwheel --output-dir wheelhouse
41-
env:
42-
CIBW_SKIP: "pp* *i686* *win32"
43-
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
44-
CIBW_BEFORE_BUILD: pip install --verbose --editable .
45-
46-
- name: Build wheels for macOS
47-
if: matrix.os == 'macos-latest'
48-
run: |
49-
python -m cibuildwheel --output-dir wheelhouse
21+
- name: Build wheels
22+
uses: pypa/[email protected]
5023
env:
51-
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
52-
CIBW_SKIP: "pp* *i686*"
24+
CIBW_BUILD: cp3*-*
25+
CIBW_SKIP: pp* *i686* *win32 *musllinux*
5326
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
5427
CIBW_BEFORE_BUILD: pip install --verbose --editable .
28+
CIBW_ARCHS_LINUX: auto64
29+
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
30+
CIBW_ARCHS_WINDOWS: auto64
5531

56-
- uses: actions/upload-artifact@v3
32+
- uses: actions/upload-artifact@v4
5733
with:
34+
name: artifact-wheels-${{ matrix.os }}
5835
path: ./wheelhouse/*.whl
5936

37+
build_sdist:
38+
name: Build source distribution
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- uses: actions/setup-python@v5
44+
name: Install Python
45+
with:
46+
python-version: '3.12'
47+
48+
- run: pip install build
49+
50+
- name: Build sdist
51+
run: python -m build --sdist
52+
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: artifact-source
56+
path: dist/*.tar.gz
57+
6058
upload_pypi:
61-
needs: build_wheels
59+
needs: [build_wheels, build_sdist]
6260
runs-on: ubuntu-latest
6361

6462
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
6563
steps:
66-
- uses: actions/checkout@v4
67-
68-
- uses: actions/download-artifact@v3
64+
- uses: actions/download-artifact@v4
6965
with:
70-
name: artifact
7166
path: dist
67+
pattern: artifact-*
68+
merge-multiple: true
7269

73-
- name: Install dependencies
74-
run: |
75-
python -m pip install --upgrade pip
76-
pip install build
77-
pip install twine
78-
79-
- name: Publish
80-
env:
81-
TWINE_USERNAME: __token__
82-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
83-
run: |
84-
python -m build --sdist
85-
twine upload dist/*
70+
- uses: pypa/[email protected]
71+
with:
72+
user: __token__
73+
password: ${{ secrets.PYPI_PASSWORD }}
74+
# To test, uncomment the following:
75+
# password: ${{ secrets.TEST_PYPI_PASSWORD }}
76+
# repository-url: https://test.pypi.org/legacy/

CONTRIBUTING

-30
This file was deleted.

CONTRIBUTING.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Contributions
2+
3+
Contributions are welcome, encouraged, and appreciated!
4+
5+
If you encounter any bugs while using the project, or believe there's a feature that would prove useful, feel free to [submit a new issue](https://github.com/zillow/quantile-forest/issues/new/choose).
6+
7+
All contributions, suggestions, and feedback you submitted are accepted under the [project's license](https://github.com/zillow/quantile-forest/blob/main/LICENSE).
8+
9+
## Submitting an Issue
10+
11+
[Issues](https://github.com/zillow/quantile-forest/issues) should be used to report problems with the package or any of its dependencies, request a new feature, or to discuss potential changes before a PR is created.
12+
13+
When reporting bugs, please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), the version of the package, and the environment (e.g., Python version).
14+
15+
If you find an existing Issue that addresses the problem you're having, please add your own reproducible example to the existing issue rather than creating a new one.
16+
17+
## Submitting a Pull Request
18+
19+
[PRs](https://github.com/zillow/quantile-forest/pulls) are always welcome and can be a quick way to get your fix or improvement merged. In general, PRs should:
20+
21+
- Only fix/add the functionality in question.
22+
- Address a single concern in the fewest number of changes possible.
23+
- Include updated documentation.
24+
25+
For changes that address core functionality or would require breaking changes (e.g., a major release), it's generally best to first open an Issue to discuss your proposed changes.
26+
27+
In general, we follow the ["fork-and-pull" Git workflow](https://gist.github.com/Chaser324/ce0505fbed06b947d962)
28+
29+
- [Fork](https://github.com/zillow/quantile-forest/fork) the repository to your own GitHub account
30+
- Clone the project to your machine
31+
- Create a branch locally with a succinct but descriptive name
32+
- Commit changes to the branch
33+
- Following any formatting and testing guidelines specific to this repo
34+
- Push changes to your fork
35+
- Open a PR in our repository
36+
37+
## Setting Up Your Environment
38+
39+
To contribute to the `quantile-forest` source code, start by forking and then cloning the repository (i.e. `git clone [email protected]:YourUsername/quantile-forest.git`)
40+
41+
Once inside the repository, to build and install the package, run:
42+
43+
```cmd
44+
python setup.py build_ext --inplace
45+
python setup.py install
46+
```
47+
48+
## Testing Your Changes
49+
50+
To execute unit tests from the `quantile-forest` repository, run:
51+
52+
```cmd
53+
pytest quantile_forest -v
54+
```
55+
56+
## Troubleshooting
57+
58+
If the build fails because SciPy is not installed, ensure OpenBLAS and LAPACK are available and accessible.
59+
60+
On macOS, run:
61+
62+
```cmd
63+
brew install openblas
64+
brew install lapack
65+
export SYSTEM_VERSION_COMPAT=1
66+
```
67+
68+
Then try rebuilding.

docs/conf.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,13 @@
184184

185185
# One entry per manual page. List of tuples
186186
# (source start file, name, description, authors, manual section).
187-
man_pages = [
188-
(
189-
"index",
190-
"quantile-forest",
191-
"quantile-forest Documentation",
192-
["Zillow Group"],
193-
1,
194-
)
195-
]
187+
man_pages = [(
188+
"index",
189+
"quantile-forest",
190+
"quantile-forest Documentation",
191+
["Zillow Group"],
192+
1,
193+
)]
196194

197195
# If true, show URL addresses after external links.
198196
# man_show_urls = False

docs/references.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
:orphan:
2+
3+
.. title:: References
4+
5+
.. _references:
6+
7+
==========
8+
References
9+
==========
10+
11+
.. bibliography::

docs/user_guide.rst

+2-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ Quantile Regression Forests
2222

2323
A standard decision tree can be extended in a straightforward way to estimate conditional quantiles. When a decision tree is fit, rather than storing only the sufficient statistics of the response variable at the leaf node, such as the mean and variance, all of the response values can be stored with the leaf node. At prediction time, these values can then be used to calculate empirical quantile estimates.
2424

25-
The quantile-based approach can be extended to random forests. To estimate :math:`F(Y=y|x) = q`, each response value in `y_train` is given a weight or frequency. Formally, the weight or frequency given to the :math:`j`\th sample of `y_train`, :math:`y_j`, while estimating the quantile is
25+
The quantile-based approach can be extended to random forests. To estimate :math:`F(Y=y|x) = q`, each response value in the training set is given a weight or frequency. Formally, the weight or frequency given to the :math:`j`\th training sample, :math:`y_j`, while estimating the quantile is
2626

2727
.. math::
2828
2929
\frac{1}{T} \sum_{t=1}^{T} \frac{\mathbb{1}(y_j \in L(x))}{\sum_{i=1}^N \mathbb{1}(y_i \in L(x))},
3030
3131
where :math:`L(x)` denotes the leaf that :math:`x` falls into.
3232

33-
Informally, this means that given a new unknown sample, we first find the leaf that it falls into at each tree. Then for each `(X, y)` pair in the training data, a weight or frequency is given to `y` for each tree based on the number of times each training sample falls into the same leaf as the new sample. This information can then be used to calculate the empirical quantile estimates.
33+
Informally, this means that given a new unknown sample, we first find the leaf that it falls into for each tree in the ensemble. Each training sample :math:`y_j` that falls into the same leaf as the new sample is given a weight that equals the fraction of samples in the leaf. Each :math:`y_j` that does not fall into the same leaf as the new sample is given a weight or frequency of zero. The weights or frequencies for each :math:`y_j` are then summed or aggregated across all of the trees in the ensemble. This information can then be used to calculate the empirical quantile estimates.
3434

3535
This approach was first proposed by :cite:t:`2006:meinshausen`.
3636

@@ -163,7 +163,3 @@ The maximum number of proximity counts output per test sample can be limited by
163163
Out-of-bag (OOB) proximity counts can be returned by specifying `oob_score = True`::
164164

165165
>>> proximities = reg.proximity_counts(X_train, oob_score=True)
166-
167-
References
168-
----------
169-
.. bibliography::

examples/plot_quantile_conformalized.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
while QRF may require additional calibration for reliable interval estimates.
1010
This example uses MAPIE to construct the CQR interval estimates with a QRF.
1111
"""
12+
1213
print(__doc__)
1314

1415
import warnings
@@ -187,7 +188,7 @@ def plot_prediction_intervals(
187188

188189
coords = [axs[0], axs[1]]
189190
num_plots = rng.choice(len(y_test), int(len(y_test)), replace=False)
190-
usd_formatter = FuncFormatter(lambda x, p: f"${format(int(x) * 100, ',')}k")
191+
usd_formatter = FuncFormatter(lambda x, p: f"${format(int(x * 100), ',')}k")
191192

192193
for strategy, coord in zip(strategies.keys(), coords):
193194
plot_prediction_intervals(

examples/plot_quantile_extrapolation_problem.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
approach.
1010
1111
"""
12+
1213
print(__doc__)
1314

1415
import matplotlib.pyplot as plt

examples/plot_quantile_interpolation.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
prediction when the desired quantile lies between two data points.
88
99
"""
10+
1011
print(__doc__)
1112

1213
import matplotlib.pyplot as plt

examples/plot_quantile_regression_intervals.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
intervals on the California Housing dataset.
88
99
"""
10+
1011
print(__doc__)
1112

1213
import matplotlib.pyplot as plt
@@ -106,7 +107,7 @@ def plot_intervals(ax, y_true, y_pred_low, y_pred_upp, price_formatter):
106107

107108
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(10, 4))
108109

109-
usd_formatter = FuncFormatter(lambda x, p: f"${format(int(x) * 100, ',')}k")
110+
usd_formatter = FuncFormatter(lambda x, p: f"${format(int(x * 100), ',')}k")
110111

111112
y_pred_interval = y_pred_upp - y_pred_low
112113
sort_idx = np.argsort(y_pred)

examples/plot_quantile_toy_example.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
the predictions to a ground truth function used to generate noisy samples.
99
1010
"""
11+
1112
print(__doc__)
1213

1314
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)