Skip to content

Commit

Permalink
fix #62
Browse files Browse the repository at this point in the history
  • Loading branch information
louisabraham committed Sep 4, 2024
1 parent c431f3e commit 881ce6f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/cox_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion examples/diabetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion examples/friedman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion examples/friedman/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion examples/generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
27 changes: 13 additions & 14 deletions examples/miceprotein.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 881ce6f

Please sign in to comment.