Skip to content

Commit

Permalink
Merge branch 'lanyue_work' of https://github.com/dynamicslab/pysindy
Browse files Browse the repository at this point in the history
…into lanyue_work
  • Loading branch information
Alan Kaptanoglu committed Jan 16, 2023
2 parents 759ca2b + b55d717 commit 6447ca4
Show file tree
Hide file tree
Showing 11 changed files with 646 additions and 637 deletions.
140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_Lasso_noise0.00_weakformTrue

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_Lasso_noise0.10_weakformTrue

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_Lasso_noise1.00_weakformTrue

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_SR3_noise0.00_weakformTrue

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_SR3_noise0.10_weakformTrue

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions examples/16_noise_robustness/data/errors_SR3_noise1.00_weakformTrue

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions examples/16_noise_robustness/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from utils import normalized_RMSE
from utils import Pareto_scan_ensembling
from utils import total_coefficient_error_normalized
from utils import weakform_reorder_coefficients

import pysindy as ps

Expand Down Expand Up @@ -319,16 +318,16 @@
# a Gurobipy license (free license available via pip), and the academic
# license (free, but requires making an account on Gurobi) is required
# for doing the large-scale runs here.
algorithms = ["STLSQ"] # , "SR3", r"SR3 ($\nu = 0.1$)", "Lasso"]
#algorithms = ["STLSQ"]
algorithms = ["SR3", r"SR3 ($\nu = 0.1$)", "Lasso"]
# algorithms = ["STLSQ"]
noise_levels = [0.0, 0.1, 1.0]
weak_form_flags = [True]

for weak_form in weak_form_flags:
# if weak_form = True, need to reorder the coefficients because the
# weak form uses a library with different term ordering
#if weak_form:

# if weak_form:
# true_coefficients = weakform_reorder_coefficients(
# systems_list, dimension_list, true_coefficients
# )
Expand Down Expand Up @@ -384,7 +383,12 @@
true_coefficients[i],
np.array(predicted_coefficients[attractor_name])[0, j, :, :],
)
print(i, attractor_name, true_coefficients[i], np.array(predicted_coefficients[attractor_name])[0, 0, :, :])
print(
i,
attractor_name,
true_coefficients[i],
np.array(predicted_coefficients[attractor_name])[0, 0, :, :],
)
print(coef_avg_error[i, :])
avg_rmse_error[i] = np.mean(
np.ravel(abs(np.array(xdot_rmse_errors[attractor_name])))
Expand Down
7 changes: 6 additions & 1 deletion examples/16_noise_robustness/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def Pareto_scan_ensembling(
weak_form=False,
algorithm="STLSQ",
strong_rmse=False,
K=200,
):
"""
Very general function for performing hyperparameter scans. This
Expand Down Expand Up @@ -418,6 +419,10 @@ def Pareto_scan_ensembling(
calculated without the weak form, for determining the
hyperparameter scan. If weak_form = True and strong_rmse = False, use the weak
form of the RMSE error for determining the hyperparameter scan.
K : int, optional (default 200)
If weak_form = False, this parameter does nothing.
If weak_form = True, this determines the number of points in the weak form
version of the regression problem, so K increasing improves the performance.
Returns
-------
Expand Down Expand Up @@ -557,7 +562,7 @@ def Pareto_scan_ensembling(
spatiotemporal_grid=all_t_train[attractor_name][0],
is_uniform=True,
include_bias=True,
K=200,
K=K,
)

# pre-calculate the test trajectory derivatives and library matrices
Expand Down

0 comments on commit 6447ca4

Please sign in to comment.