-
Notifications
You must be signed in to change notification settings - Fork 31
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
Improve documentation #79
Comments
In the meantime maybe try both and see which one fails due to a shape mismatch? |
Surely I tried. But the result is not aligned with my expectation: julia> using Lasso
julia> x = rand(5, 1); y = rand(5);
julia> m = fit(GammaLassoPath, x, y);
julia> coef(m)
2×50 SparseArrays.SparseMatrixCSC{Float64, Int64} with 100 stored entries:
⎡⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⎤
⎣⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⎦ I expect a |
Classically for regression purposes, if you have |
I think I got my answer. So, in my example, I should use julia> m = fit(GammaLassoPath, x, y)
┌ Warning: One of the predicators (columns of X) is a constant, so it can not be standardized.
│ To include a constant predicator set standardize = false and intercept = false So, I should follow the instructions: julia> m = fit(GammaLassoPath, x, y, standardize=false, intercept=false);
julia> coef(m)
5×76 SparseArrays.SparseMatrixCSC{Float64, Int64} with 75 stored entries:
⎡⠠⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⎤
⎣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⎦ That is aligned with what I expect. Now, how can I choose one of the coefficient series in the returned sparse matrix? julia> coef(m)[:, 1]
5-element SparseArrays.SparseVector{Float64, Int64} with 0 stored entries
julia> coef(m)[:, 2]
5-element SparseArrays.SparseVector{Float64, Int64} with 1 stored entry:
[2] = 0.0231384 I expect a vector of length |
I think I got it: julia> coef(m) |> Matrix
5×76 Matrix{Float64}:
0.0 0.0 0.0 0.0 … 0.0 0.0 0.0
0.0 0.0231384 0.0452252 0.0663081 0.492017 0.492793 0.493533
0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 |
This is not a scalar, it is a sparse vector with only one nonzero entry. The reason for this behavior is that Lasso parameters are meant to be sparse, aka have few nonzero entries |
Thank you. It seems that I reached the answer to my question. Thank you for your help and elaboration. |
In the Lasso.md, a method of
fit
is introduced as follows:Is it possible to provide an example in the documentation or mention the acceptable shape of$n\times m$ , and $m$ . I have a problem using the method since I don't know what is the acceptable size of these two arguments. I believe they should have something in common for example the length of
X
andy
? I.e.,X
should be in size ofy
should be a vector of lengthy
should be equal to thenrows(X)
orncols(X)
.P.S.: In my case study, I have a$d\times w$ , and a $d$ . I don't know if I should pass $n\times d$ or $d\times n$ .
X
of sizey
of lengthX
orX'
as the second argument. I expect to get a matrix of coefficients of sizeThe text was updated successfully, but these errors were encountered: