Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuclear norm implementation #33

Open
kanxu526 opened this issue Sep 3, 2022 · 1 comment
Open

Nuclear norm implementation #33

kanxu526 opened this issue Sep 3, 2022 · 1 comment

Comments

@kanxu526
Copy link

kanxu526 commented Sep 3, 2022

(1) I fixed a few issues with the nuclear norm implementation, e.g., the original code won't work in the 1-dim case (because the parameter is passed as a 0-dim vector).
(2) I revised the penalty calculation of nuclear norm and pass a new arg called coefsize to reshape the coef matrix and pass to nuclear norm. This is useful for matrix sensing like Negahban & Wainwright 2011. To my knowledge, it hasn't been applied in any of the scikit-learn related toolkits.
(3) Not sure what data the original nuclear norm can be applied to. Does that work similarly as 'multiclass' in sklearn? I failed to find an arg like that in the codes.

I'm quite new in constructing a module and so far I've been working on it just for my own research use. Let me know if you like this idea or not.

@idc9
Copy link
Collaborator

idc9 commented Sep 12, 2022

Here is an example of using the nuclear norm -- we are working on better documentation. You may want to install the latest version (made some fixes so the below code works!)

import numpy as np
from yaglm.Glm import Glm
from yaglm.GlmTuned import GlmCV
from yaglm.config.penalty import NuclearNorm
from yaglm.config.flavor import NonConvex

n_samples = 100
n_features = 10
n_response = 5

# sample data
np.random.seed(1)
beta_true = np.ones((n_features, n_response))
X = np.random.normal(size=(n_samples, n_features))
noise = np.random.normal(size=(n_samples, n_response))
Y = X @ beta_true +  noise


# some examples
single_pen_val = Glm(penalty=NuclearNorm(pen_val=1.5)).fit(X, Y)
scad_nuc_norm_tuned_with_cv = GlmCV(penalty=NuclearNorm(flavor=NonConvex())).fit(X, Y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants