Jacob-Stevens-Haas / Kalman-SINDy-Paper

1 stars 0 forks source link

GridPoints with diff_params.diffcls = SmoothedFiniteDifference do not contain diff_params.kind #17

Closed yb6599 closed 5 months ago

yb6599 commented 5 months ago

I'm trying to plot the test and train data for the experiments and the points corresponding with Savitsy Golay SmoothedFiniteDifference do not have a diff_params.kind. It throws off an error when using plot_summarry_test_train, which fails at line 636 in gridsearch.__init__.py,

for point in filter(lambda p: p["pind"] in partial_match, where):
        logger.debug(f"Checking whether {point['pind']} matches param query")
        for params_match in params_or:
            if all(
                check_values(value, point["params"][param])
                for param, value in params_match.items()
            ):
                results.append(point)
                break

The code fails at check_values line, which gives the error KeyError : diff_params.kind where the point is

'params': {'sim_params.n_trajectories': 10, 'sim_params.t_end': 0.25, 'sim_params.noise_rel': 0.1, 'feat_params.degree': 3, 'feat_params.featcls': 'Polynomial', 'opt_params.opt': MIOSR(target_sparsity=4, unbias=True), 'opt_params.bagging': True, 'opt_params.n_models': 20, 'opt_params.optcls': 'ensemble', 'group': 'cubic_ho', 'diff_params.smoother_kws.window_length': 5, 'diff_params.smoother_kws.polyorder': 3, 'diff_params.smoother_kws.axis': 0, 'diff_params.diffcls': 'SmoothedFiniteDifference'}

How do we introduce diff_params.kind and should it be None?

Jacob-Stevens-Haas commented 5 months ago

what rev of pysindy-experiments are you on? Line 636 in gridsearch/__init__.py in the current main branch is

        def _normalize_keep_axes(
            keep_axes: KeepAxisSpec, scan_grid: dict[str, Sequence[Any]]
        ) -> tuple[tuple[int, tuple[int, ...]], ...]:
            ax_sizes = {ax_name: len(vals) for ax_name, vals in scan_grid.items()}
636 -->     if ... in keep_axes:
                keep_axes = _expand_ellipsis_axis(keep_axes, ax_sizes)  # type: ignore
            else:
                keep_axes = cast(Collection[tuple[str, tuple[int, ...]]], keep_axes)
            scan_axes = tuple(ax_sizes.keys())
            return tuple((scan_axes.index(keep_ax[0]), keep_ax[1]) for keep_ax in keep_axes)

Also, the relevant line in current branch is:

            if all(
                param in point["params"] and check_values(value, point["params"][param])
                for param, value in params_match.items()
            ):

You may need to reinstall from current master

yb6599 commented 5 months ago

Got it. this problem does not occur anymore.