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 31, 2024
1 parent 222c0a0 commit 243f27f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions examples/plot_predict_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def predict(qrf, X, quantiles=0.5, what=None):


# Load the Diabetes dataset.
X, y = datasets.load_diabetes(return_X_y=True)
X, y = datasets.load_diabetes(return_X_y=True, as_frame=True)

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

qrf = RandomForestQuantileRegressor(random_state=random_state).fit(X_train, y_train)
qrf = RandomForestQuantileRegressor(random_state=random_state)
qrf.fit(X_train, y_train)

# Define a user-specified function.
# Here we randomly sample 1,000 values with replacement from the empirical distribution.
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_quantile_conformalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

# Load the California Housing dataset.
X, y = datasets.fetch_california_housing(as_frame=True, return_X_y=True)
X, y = datasets.fetch_california_housing(return_X_y=True, as_frame=True)
perm = random_state.permutation(min(len(X), n_samples))
X = X.iloc[perm]
y = y.iloc[perm]
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_quantile_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
quantiles = [0.025, 0.5, 0.975]


def make_toy_dataset(n_samples, bounds, add_noise=True, random_state=0):
def make_toy_dataset(n_samples, bounds, add_noise=True, random_state=None):
"""Make a toy dataset."""
random_state = check_random_state(random_state)

Expand Down
2 changes: 1 addition & 1 deletion 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, n_samples, bounds, add_noise=True, random_state=0):
def make_func_Xy(func, n_samples, bounds, add_noise=True, random_state=None):
"""Make a dataset from a specified function."""
random_state = check_random_state(random_state)

Expand Down
2 changes: 1 addition & 1 deletion examples/plot_quantile_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
n_samples = 1000

# Load the California Housing dataset.
X, y = datasets.fetch_california_housing(as_frame=True, return_X_y=True)
X, y = datasets.fetch_california_housing(return_X_y=True, as_frame=True)
perm = random_state.permutation(min(len(X), n_samples))
X = X.iloc[perm]
y = y.iloc[perm]
Expand Down
5 changes: 3 additions & 2 deletions examples/plot_quantile_ranks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
bounds = [0, 10]


def make_toy_dataset(n_samples, bounds, random_state=0):
def make_toy_dataset(n_samples, bounds, random_state=None):
"""Make a toy dataset."""
random_state = check_random_state(random_state)
X_1d = np.linspace(*bounds, num=n_samples)
Expand All @@ -40,7 +40,8 @@ def make_toy_dataset(n_samples, bounds, random_state=0):
min_samples_leaf=50,
max_samples_leaf=None,
random_state=random_state,
).fit(X, y)
)
qrf.fit(X, y)

y_pred = qrf.predict(X, quantiles=0.5)

Expand Down
2 changes: 1 addition & 1 deletion 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(n_samples, a=7, loc=-1, scale=1, random_state=0):
def make_skewed_dataset(n_samples, a=7, loc=-1, scale=1, random_state=None):
"""Make a skewed dataset."""
random_state = check_random_state(random_state)
skewnorm_rv = sp.stats.skewnorm(a, loc, scale)
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_treeshap_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_shap_value_by_index(shap_values, index):


# Load the California Housing dataset.
X, y = datasets.fetch_california_housing(as_frame=True, return_X_y=True)
X, y = datasets.fetch_california_housing(return_X_y=True, as_frame=True)
perm = random_state.permutation(min(len(X), n_samples))
X = X.iloc[perm]
y = y.iloc[perm]
Expand Down

0 comments on commit 243f27f

Please sign in to comment.