Skip to content

Commit

Permalink
Fixed a bug affecting fictional confidence regions, added smoothing o…
Browse files Browse the repository at this point in the history
…ption to baseline, improved visualization
  • Loading branch information
fjwillemsen committed Nov 7, 2023
1 parent 331762c commit 401dd3c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
5 changes: 0 additions & 5 deletions experiment_files/example_visualizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@
]
},
"strategies": [
{
"name": "greedy_mls",
"strategy": "greedy_mls",
"display_name": "Greedy Multi-Start Local Search"
},
{
"name": "greedy_ils",
"strategy": "greedy_ils",
Expand Down
10 changes: 8 additions & 2 deletions src/autotuning_methodology/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from scipy.interpolate import PchipInterpolator

from autotuning_methodology.curves import CurveBasis, get_indices_in_array
from autotuning_methodology.curves import CurveBasis, get_indices_in_array, moving_average
from autotuning_methodology.searchspace_statistics import SearchspaceStatistics


Expand Down Expand Up @@ -170,7 +170,13 @@ def get_curve_over_fevals( # noqa: D102

def get_curve_over_time(self, time_range: np.ndarray, dist=None, confidence_level=None) -> np.ndarray: # noqa: D102
fevals_range = self.time_to_fevals(time_range)
return self.get_curve_over_fevals(fevals_range, dist, confidence_level)
curve_over_time = self.get_curve_over_fevals(fevals_range, dist, confidence_level)
smoothing_factor = 0.0
if smoothing_factor > 0.0:
window_size = min(time_range.size, ceil(time_range.size * smoothing_factor))
if time_range.size > 1 and window_size < 1:
curve_over_time = moving_average(curve_over_time, window_size)
return curve_over_time

def get_standardised_curve( # noqa: D102
self, range: np.ndarray, strategy_curve: np.ndarray, x_type: str
Expand Down
2 changes: 1 addition & 1 deletion src/autotuning_methodology/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _get_curve_split_real_fictional_parts(
curve: np.ndarray,
curve_lower_err: np.ndarray,
curve_upper_err: np.ndarray,
smoothing_factor=0.005,
smoothing_factor=0.0,
) -> tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
"""Split the provided curves based on the real_stopping_point_index.
Expand Down
9 changes: 5 additions & 4 deletions src/autotuning_methodology/visualize_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def normalize_multiple(curves: list) -> tuple:
color=color,
ls="dashed",
)
ax.plot(x_axis_range_fictional, curve_fictional, color=color, ls="dashed")
ax.plot(x_axis_range_fictional, curve_fictional, color=color, alpha=0.8, ls="dashed")

# # plot cutoff point
# def plot_cutoff_point(cutoff_percentiles: np.ndarray, show_label=True):
Expand Down Expand Up @@ -904,12 +904,12 @@ def plot_strategies_aggregated(
)
if (
real_stopping_point_index < time_range.shape[0]
and real_stopping_point_index < len(strategies_lower_err) - 1
and real_stopping_point_index < len(strategy_lower_err) - 1
):
ax.fill_between(
time_range[real_stopping_point_index:],
strategies_lower_err[real_stopping_point_index:],
strategies_upper_err[real_stopping_point_index:],
strategy_lower_err[real_stopping_point_index:],
strategy_upper_err[real_stopping_point_index:],
alpha=0.15,
antialiased=True,
color=color,
Expand All @@ -928,6 +928,7 @@ def plot_strategies_aggregated(
time_range[real_stopping_point_index:],
strategy_performance[real_stopping_point_index:],
color=color,
alpha=0.8,
ls="dashed",
)
print(f" | performance of {displayname}: {round(np.mean(strategy_performance), 3)}")
Expand Down

0 comments on commit 401dd3c

Please sign in to comment.