Skip to content

Commit 01847ed

Browse files
committedOct 9, 2023
Merge branch 'main' into 1.2.X
2 parents 820d220 + c3f5681 commit 01847ed

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed
 

‎examples/plot_quantile_conformalized.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
========================================================================
3-
Quantile regression forests for conformalized quantile regression (CQR)
4-
========================================================================
2+
=================================================================
3+
Quantile regression forests for conformalized quantile regression
4+
=================================================================
55
6-
An example that demonstrates the use of a quantile regression forest to
6+
An example that demonstrates the use of a quantile regression forest (QRF) to
77
construct reliable prediction intervals using conformalized quantile
88
regression (CQR). CQR offers prediction intervals that attain valid coverage,
99
while QRF may require additional calibration for reliable interval estimates.

‎quantile_forest/_quantile_forest.py

+31-17
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,16 @@ class RandomForestQuantileRegressor(BaseForestQuantileRegressor):
772772
predict. Each quantile must be strictly between 0 and 1. If "mean",
773773
the model predicts the mean.
774774
775-
criterion : {"squared_error", "absolute_error", "poisson"}, \
775+
criterion : {"squared_error", "absolute_error", "friedman_mse", "poisson"}, \
776776
default="squared_error"
777777
The function to measure the quality of a split. Supported criteria
778778
are "squared_error" for the mean squared error, which is equal to
779-
variance reduction as feature selection criterion, "absolute_error"
780-
for the mean absolute error, and "poisson" which uses reduction in
781-
Poisson deviance to find splits.
779+
variance reduction as feature selection criterion and minimizes the L2
780+
loss using the mean of each terminal node, "friedman_mse", which uses
781+
mean squared error with Friedman's improvement score for potential
782+
splits, "absolute_error" for the mean absolute error, which minimizes
783+
the L1 loss using the median of each terminal node, and "poisson" which
784+
uses reduction in Poisson deviance to find splits.
782785
Training using "absolute_error" is significantly slower
783786
than when using "squared_error".
784787
@@ -866,9 +869,11 @@ class RandomForestQuantileRegressor(BaseForestQuantileRegressor):
866869
Whether bootstrap samples are used when building trees. If False, the
867870
whole dataset is used to build each tree.
868871
869-
oob_score : bool, default=False
872+
oob_score : bool or callable, default=False
870873
Whether to use out-of-bag samples to estimate the generalization score.
871-
Only available if bootstrap=True.
874+
By default, :func:`~sklearn.metrics.r2_score` is used.
875+
Provide a callable with signature `metric(y_true, y_pred)` to use a
876+
custom metric. Only available if `bootstrap=True`.
872877
873878
n_jobs : int, default=None
874879
The number of jobs to run in parallel. :meth:`fit`, :meth:`predict`,
@@ -901,12 +906,12 @@ class RandomForestQuantileRegressor(BaseForestQuantileRegressor):
901906
902907
- If None (default), then draw `X.shape[0]` samples.
903908
- If int, then draw `max_samples` samples.
904-
- If float, then draw `max_samples * X.shape[0]` samples. Thus,
905-
`max_samples` should be in the interval `(0.0, 1.0]`.
909+
- If float, then draw `max(round(n_samples * max_samples), 1)` samples.
910+
Thus, `max_samples` should be in the interval `(0.0, 1.0]`.
906911
907912
Attributes
908913
----------
909-
base_estimator_ : DecisionTreeRegressor
914+
estimator_ : DecisionTreeRegressor
910915
The child estimator template used to create the collection of fitted
911916
sub-estimators.
912917
@@ -1054,11 +1059,18 @@ class ExtraTreesQuantileRegressor(BaseForestQuantileRegressor):
10541059
predict. Each quantile must be strictly between 0 and 1. If "mean",
10551060
the model predicts the mean.
10561061
1057-
criterion : {"squared_error", "absolute_error"}, default="squared_error"
1062+
criterion : {"squared_error", "absolute_error", "friedman_mse", "poisson"}, \
1063+
default="squared_error"
10581064
The function to measure the quality of a split. Supported criteria
10591065
are "squared_error" for the mean squared error, which is equal to
1060-
variance reduction as feature selection criterion, and "absolute_error"
1061-
for the mean absolute error.
1066+
variance reduction as feature selection criterion and minimizes the L2
1067+
loss using the mean of each terminal node, "friedman_mse", which uses
1068+
mean squared error with Friedman's improvement score for potential
1069+
splits, "absolute_error" for the mean absolute error, which minimizes
1070+
the L1 loss using the median of each terminal node, and "poisson" which
1071+
uses reduction in Poisson deviance to find splits.
1072+
Training using "absolute_error" is significantly slower
1073+
than when using "squared_error".
10621074
10631075
max_depth : int, default=None
10641076
The maximum depth of the tree. If None, then nodes are expanded until
@@ -1144,9 +1156,11 @@ class ExtraTreesQuantileRegressor(BaseForestQuantileRegressor):
11441156
Whether bootstrap samples are used when building trees. If False, the
11451157
whole dataset is used to build each tree.
11461158
1147-
oob_score : bool, default=False
1159+
oob_score : bool or callable, default=False
11481160
Whether to use out-of-bag samples to estimate the generalization score.
1149-
Only available if bootstrap=True.
1161+
By default, :func:`~sklearn.metrics.accuracy_score` is used.
1162+
Provide a callable with signature `metric(y_true, y_pred)` to use a
1163+
custom metric. Only available if `bootstrap=True`.
11501164
11511165
n_jobs : int, default=None
11521166
The number of jobs to run in parallel. :meth:`fit`, :meth:`predict`,
@@ -1187,18 +1201,18 @@ class ExtraTreesQuantileRegressor(BaseForestQuantileRegressor):
11871201
11881202
Attributes
11891203
----------
1190-
base_estimator_ : ExtraTreeQuantileRegressor
1204+
estimator_ : ExtraTreeRegressor
11911205
The child estimator template used to create the collection of fitted
11921206
sub-estimators.
11931207
1194-
estimators_ : list of ForestRegressor
1208+
estimators_ : list of DecisionTreeRegressor
11951209
The collection of fitted sub-estimators.
11961210
11971211
feature_importances_ : ndarray of shape (n_features,)
11981212
The impurity-based feature importances.
11991213
The higher, the more important the feature.
12001214
The importance of a feature is computed as the (normalized)
1201-
total reduction of the criterion brought by that feature. It is also
1215+
total reduction of the criterion brought by that feature. It is also
12021216
known as the Gini importance.
12031217
12041218
Warning: impurity-based feature importances can be misleading for

0 commit comments

Comments
 (0)