Skip to content

Commit

Permalink
Update example plots
Browse files Browse the repository at this point in the history
  • Loading branch information
reidjohnson committed Aug 30, 2024
1 parent 666dd81 commit c525822
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/plot_quantile_extrapolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
qrf_params = {"min_samples_leaf": 4, "max_samples_leaf": None, "random_state": random_state}


def make_func_Xy(func, bounds, n_samples, add_noise=True, random_state=0):
def make_func_Xy(func, n_samples, bounds, add_noise=True, random_state=0):
"""Make a dataset from a specified function."""
random_state = check_random_state(random_state)

Expand Down Expand Up @@ -146,7 +146,7 @@ def _get_tree_weight_matrix(X, Y, X_eval=None, n_trees=100, rng=None, **kwargs):
tree.fit(X[split1, :], Y[split1].flatten())

# Extract tree weight matrix.
y_train_leaves = tree._get_y_train_leaves(X[split2, :], Y)
y_train_leaves = tree._get_y_train_leaves(X[split2, :], Y.reshape(-1, 1))
nrows = X[split2, :].shape[0]
matrix = np.zeros((nrows, nrows))
for leaf in y_train_leaves[0]:
Expand Down Expand Up @@ -368,7 +368,7 @@ def get_coverage_xtr(bounds_list, train_indices, test_indices, y_train, level, *


# Create a dataset that requires extrapolation.
X, y = make_func_Xy(func, bounds, n_samples, add_noise=True, random_state=0)
X, y = make_func_Xy(func, n_samples, bounds, add_noise=True, random_state=0)

# Fit and extrapolate based on train-test split (depending on X).
extrap_min_idx = int(n_samples * (extrap_frac / 2))
Expand Down
6 changes: 3 additions & 3 deletions examples/plot_quantile_multioutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
legend = {k: v for f in funcs for k, v in f["legend"].items()}


def make_func_Xy(funcs, bounds, n_samples):
"""Make a dataset from specified function(s)."""
def make_funcs_Xy(funcs, bounds, n_samples):
"""Make a dataset from specified function(s) with signal and noise."""
x = np.linspace(*bounds, n_samples)
y = np.empty((len(x), len(funcs)))
for i, func in enumerate(funcs):
Expand All @@ -49,7 +49,7 @@ def make_func_Xy(funcs, bounds, n_samples):


# Create a dataset with multiple target variables.
X, y = make_func_Xy(funcs, bounds, n_samples)
X, y = make_funcs_Xy(funcs, bounds, n_samples)

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=random_state)

Expand Down
4 changes: 2 additions & 2 deletions examples/plot_quantile_vs_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
quantiles = np.linspace(0, 1, num=101, endpoint=True).round(2).tolist()


def make_skewed_dataset(a=7, loc=-1, scale=1, random_state=0):
def make_skewed_dataset(n_samples, a=7, loc=-1, scale=1, random_state=0):
"""Make a skewed dataset."""
random_state = check_random_state(random_state)
skewnorm_rv = sp.stats.skewnorm(a, loc, scale)
Expand All @@ -37,7 +37,7 @@ def make_skewed_dataset(a=7, loc=-1, scale=1, random_state=0):


# Create a right-skewed toy dataset.
X, y = make_skewed_dataset(a=7, loc=-1, scale=1, random_state=0)
X, y = make_skewed_dataset(n_samples, a=7, loc=-1, scale=1, random_state=0)

regr_rf = RandomForestRegressor(random_state=random_state)
regr_qrf = RandomForestQuantileRegressor(random_state=random_state)
Expand Down

0 comments on commit c525822

Please sign in to comment.