From 60d9b092a025ca474810507e245e82809969f852 Mon Sep 17 00:00:00 2001 From: Reid Johnson Date: Wed, 4 Sep 2024 23:34:57 -0700 Subject: [PATCH] Update example plots --- docs/user_guide/fit_predict.rst | 2 +- ...malized.py => plot_qrf_conformalized_intervals.py} | 0 ...predict_custom.py => plot_qrf_custom_functions.py} | 0 ...ile_extrapolation.py => plot_qrf_extrapolation.py} | 0 ...ace_model.py => plot_qrf_huggingface_inference.py} | 0 ...rpolation.py => plot_qrf_interpolation_methods.py} | 2 +- ...uantile_multioutput.py => plot_qrf_multitarget.py} | 0 ..._intervals.py => plot_qrf_prediction_intervals.py} | 0 ...ot_quantile_example.py => plot_qrf_predictions.py} | 0 ...oximity_counts.py => plot_qrf_proximity_counts.py} | 11 +++++++++-- ...t_quantile_ranks.py => plot_qrf_quantile_ranks.py} | 0 ...p_example.py => plot_qrf_treeshap_explanations.py} | 0 ...e_vs_standard.py => plot_qrf_vs_rf_predictions.py} | 0 13 files changed, 11 insertions(+), 4 deletions(-) rename examples/{plot_quantile_conformalized.py => plot_qrf_conformalized_intervals.py} (100%) rename examples/{plot_predict_custom.py => plot_qrf_custom_functions.py} (100%) rename examples/{plot_quantile_extrapolation.py => plot_qrf_extrapolation.py} (100%) rename examples/{plot_huggingface_model.py => plot_qrf_huggingface_inference.py} (100%) rename examples/{plot_quantile_interpolation.py => plot_qrf_interpolation_methods.py} (98%) rename examples/{plot_quantile_multioutput.py => plot_qrf_multitarget.py} (100%) rename examples/{plot_quantile_intervals.py => plot_qrf_prediction_intervals.py} (100%) rename examples/{plot_quantile_example.py => plot_qrf_predictions.py} (100%) rename examples/{plot_proximity_counts.py => plot_qrf_proximity_counts.py} (97%) rename examples/{plot_quantile_ranks.py => plot_qrf_quantile_ranks.py} (100%) rename examples/{plot_treeshap_example.py => plot_qrf_treeshap_explanations.py} (100%) rename examples/{plot_quantile_vs_standard.py => plot_qrf_vs_rf_predictions.py} (100%) diff --git a/docs/user_guide/fit_predict.rst b/docs/user_guide/fit_predict.rst index 72546c7..9ce0b43 100755 --- a/docs/user_guide/fit_predict.rst +++ b/docs/user_guide/fit_predict.rst @@ -144,4 +144,4 @@ The predictions of a standard random forest can also be recovered from a quantil User-Specified Functions ~~~~~~~~~~~~~~~~~~~~~~~~ -While a QRF is designed to estimate quantiles from the empirical distribution calculated for each sample, in many cases it may be useful to use the empirical distribution to calculate other quantities of interest. For more details, see :ref:`gallery_plot_predict_custom`. +While a QRF is designed to estimate quantiles from the empirical distribution calculated for each sample, in many cases it may be useful to use the empirical distribution to calculate other quantities of interest. For more details, see :ref:`gallery_plot_custom_functions`. diff --git a/examples/plot_quantile_conformalized.py b/examples/plot_qrf_conformalized_intervals.py similarity index 100% rename from examples/plot_quantile_conformalized.py rename to examples/plot_qrf_conformalized_intervals.py diff --git a/examples/plot_predict_custom.py b/examples/plot_qrf_custom_functions.py similarity index 100% rename from examples/plot_predict_custom.py rename to examples/plot_qrf_custom_functions.py diff --git a/examples/plot_quantile_extrapolation.py b/examples/plot_qrf_extrapolation.py similarity index 100% rename from examples/plot_quantile_extrapolation.py rename to examples/plot_qrf_extrapolation.py diff --git a/examples/plot_huggingface_model.py b/examples/plot_qrf_huggingface_inference.py similarity index 100% rename from examples/plot_huggingface_model.py rename to examples/plot_qrf_huggingface_inference.py diff --git a/examples/plot_quantile_interpolation.py b/examples/plot_qrf_interpolation_methods.py similarity index 98% rename from examples/plot_quantile_interpolation.py rename to examples/plot_qrf_interpolation_methods.py index 2ae4e4e..3120d37 100755 --- a/examples/plot_quantile_interpolation.py +++ b/examples/plot_qrf_interpolation_methods.py @@ -84,7 +84,7 @@ def plot_interpolation_predictions(df, legend): """Plot predictions by quantile interpolation methods.""" # Slider for varying the prediction interval that determines the quantiles being interpolated. slider = alt.binding_range(name="Prediction Interval: ", min=0, max=1, step=0.01) - interval_val = alt.param(name="interval", value=0.9, bind=slider) + interval_val = alt.param(name="interval", value=0.8, bind=slider) click = alt.selection_point(bind="legend", fields=["method"], on="click") diff --git a/examples/plot_quantile_multioutput.py b/examples/plot_qrf_multitarget.py similarity index 100% rename from examples/plot_quantile_multioutput.py rename to examples/plot_qrf_multitarget.py diff --git a/examples/plot_quantile_intervals.py b/examples/plot_qrf_prediction_intervals.py similarity index 100% rename from examples/plot_quantile_intervals.py rename to examples/plot_qrf_prediction_intervals.py diff --git a/examples/plot_quantile_example.py b/examples/plot_qrf_predictions.py similarity index 100% rename from examples/plot_quantile_example.py rename to examples/plot_qrf_predictions.py diff --git a/examples/plot_proximity_counts.py b/examples/plot_qrf_proximity_counts.py similarity index 97% rename from examples/plot_proximity_counts.py rename to examples/plot_qrf_proximity_counts.py index c47121e..9d3358a 100644 --- a/examples/plot_proximity_counts.py +++ b/examples/plot_qrf_proximity_counts.py @@ -24,7 +24,7 @@ from quantile_forest import RandomForestQuantileRegressor random_state = np.random.RandomState(0) -n_test_samples = 25 +n_test_samples = 50 noise_std = 0.1 pixel_dim = (8, 8) # pixel dimensions (width and height) @@ -76,7 +76,12 @@ def extract_floats(combined_df, scale=1000): # We set `max_samples_leaf=None` to ensure that every sample in the training # data is stored in the leaf nodes. By doing this, we allow the model to # consider all samples as potential candidates for proximity calculations. -qrf = RandomForestQuantileRegressor(max_samples_leaf=None, random_state=random_state) +qrf = RandomForestQuantileRegressor( + n_estimators=500, + max_features=1 / 3, + max_samples_leaf=None, + random_state=random_state, +) # Fit the model to predict the non-noisy pixels from noisy pixels (i.e., to denoise). # We fit a single multi-target model, with each pixel treated as a distinct target. @@ -126,6 +131,8 @@ def plot_digits_proximities( width=225, ): """Plot Digits dataset proximities for test samples.""" + df = df[df["prox_idx"] < n_prox].copy() + dim_x, dim_y = pixel_dim[0], pixel_dim[1] dgt_x, dgt_y = len(str(dim_x)), len(str(dim_y)) diff --git a/examples/plot_quantile_ranks.py b/examples/plot_qrf_quantile_ranks.py similarity index 100% rename from examples/plot_quantile_ranks.py rename to examples/plot_qrf_quantile_ranks.py diff --git a/examples/plot_treeshap_example.py b/examples/plot_qrf_treeshap_explanations.py similarity index 100% rename from examples/plot_treeshap_example.py rename to examples/plot_qrf_treeshap_explanations.py diff --git a/examples/plot_quantile_vs_standard.py b/examples/plot_qrf_vs_rf_predictions.py similarity index 100% rename from examples/plot_quantile_vs_standard.py rename to examples/plot_qrf_vs_rf_predictions.py