diff --git a/examples/cox_regression.py b/examples/cox_regression.py index 2660b45..c14e68d 100644 --- a/examples/cox_regression.py +++ b/examples/cox_regression.py @@ -23,7 +23,7 @@ tie_approximation="breslow", ) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("cox_regression.png") diff --git a/examples/diabetes.py b/examples/diabetes.py index cae0580..7705432 100644 --- a/examples/diabetes.py +++ b/examples/diabetes.py @@ -27,7 +27,7 @@ hidden_dims=(10,), verbose=True, ) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) diff --git a/examples/friedman.py b/examples/friedman.py index a07115d..260b99e 100644 --- a/examples/friedman.py +++ b/examples/friedman.py @@ -45,7 +45,7 @@ def rrmse(y, y_pred): path_multiplier=path_multiplier, M=M, ) - path = model.path(X_train, y_train) + path = model.path(X_train, y_train, return_state_dicts=True) print( "rrmse:", min(rrmse(y_test, model.load(save).predict(X_test)) for save in path), diff --git a/examples/friedman/main.py b/examples/friedman/main.py index 50209d0..833a1ff 100644 --- a/examples/friedman/main.py +++ b/examples/friedman/main.py @@ -42,7 +42,9 @@ def rrmse(y, y_pred): hidden_dims=(10, 10), torch_seed=0, ) - path = model.path(X_train, y_train, X_val=X_val, y_val=y_val) + path = model.path( + X_train, y_train, X_val=X_val, y_val=y_val, return_state_dicts=True + ) print( "rrmse:", min(rrmse(y_test, model.load(save).predict(X_test)) for save in path), diff --git a/examples/generated.py b/examples/generated.py index 1024b56..e590820 100644 --- a/examples/generated.py +++ b/examples/generated.py @@ -57,7 +57,7 @@ def friedman_lockout(): model = LassoNetRegressor(verbose=True, path_multiplier=1.01, hidden_dims=(10, 10)) - path = model.path(X_train, y_train) + path = model.path(X_train, y_train, return_state_dicts=True) import matplotlib.pyplot as plt def score(self, X, y, sample_weight=None): diff --git a/examples/miceprotein.py b/examples/miceprotein.py index d306b92..af45db0 100755 --- a/examples/miceprotein.py +++ b/examples/miceprotein.py @@ -30,69 +30,68 @@ model = LassoNetClassifierCV() -model.path(X_train, y_train) +model.path(X_train, y_train, return_state_dicts=True) print("Best model scored", model.score(X_test, y_test)) print("Lambda =", model.best_lambda_) plot_cv(model, X_test, y_test) plt.savefig("miceprotein-cv.png") -1 / 0 model = LassoNetClassifier() -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein.png") model = LassoNetClassifier(dropout=0.5) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_dropout.png") model = LassoNetClassifier(hidden_dims=(100, 100)) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep.png") model = LassoNetClassifier(hidden_dims=(100, 100), gamma=0.01) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep_l2_weak.png") model = LassoNetClassifier(hidden_dims=(100, 100), gamma=0.1) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep_l2_strong.png") model = LassoNetClassifier(hidden_dims=(100, 100), gamma=1) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep_l2_super_strong.png") model = LassoNetClassifier(hidden_dims=(100, 100), dropout=0.5) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep_dropout.png") model = LassoNetClassifier(hidden_dims=(100, 100), backtrack=True, dropout=0.5) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_deep_dropout_backtrack.png") model = LassoNetClassifier(batch_size=64) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_64.png") model = LassoNetClassifier(backtrack=True) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_backtrack.png") model = LassoNetClassifier(batch_size=64, backtrack=True) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_backtrack_64.png") model = LassoNetClassifier(class_weight=[0.1, 0.2, 0.3, 0.1, 0.3, 0, 0, 0]) -path = model.path(X_train, y_train) +path = model.path(X_train, y_train, return_state_dicts=True) plot_path(model, path, X_test, y_test) plt.savefig("miceprotein_weighted.png")