jacobbien / hiernet Goto Github PK
View Code? Open in Web Editor NEWA Lasso for Hierarchical Interactions
A Lasso for Hierarchical Interactions
I have posted this on stackoverflow, but I realize that there is no extant example code for the variable importance measures. When you wrote varimp, was there a test case you used? I'm not able to get it to work for my data, or for the example given in the Rd file:
> set.seed(12)
> x=matrix(rnorm(100*10),ncol=10)
> x=scale(x,TRUE,TRUE)
> y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
> newx=matrix(rnorm(100*10),ncol=10)
> fit=hierNet(x,y,lam=50)
GG converged in 31 iterations.
> yhat=predict(fit,newx)
>
> fit=hierNet.path(x,y)
i,lam= 1 129.72
GG converged in 1 iterations.
i,lam= 2 101.8
GG converged in 20 iterations.
i,lam= 3 79.89
GG converged in 26 iterations.
i,lam= 4 62.69
GG converged in 26 iterations.
i,lam= 5 49.2
GG converged in 26 iterations.
i,lam= 6 38.61
GG converged in 48 iterations.
i,lam= 7 30.3
GG converged in 57 iterations.
i,lam= 8 23.78
GG converged in 62 iterations.
i,lam= 9 18.66
GG converged in 55 iterations.
i,lam= 10 14.64
GG converged in 63 iterations.
i,lam= 11 11.49
GG converged in 60 iterations.
i,lam= 12 9.02
GG converged in 119 iterations.
i,lam= 13 7.08
GG converged in 122 iterations.
i,lam= 14 5.55
GG converged in 139 iterations.
i,lam= 15 4.36
GG converged in 147 iterations.
i,lam= 16 3.42
GG converged in 200 iterations.
i,lam= 17 2.68
GG converged in 374 iterations.
i,lam= 18 2.11
GG converged in 291 iterations.
i,lam= 19 1.65
GG converged in 602 iterations.
i,lam= 20 1.3
GG converged in 657 iterations.
> yhat=predict(fit,newx)
> hierNet.varimp(fit,x,y)
1Error in fit$th[-j, -j] : incorrect number of dimensions
Suppose all my variables in X are categorical. How do I use hierNet in R to build a sparse two-way interaction model?
I have tried converting all my variables into dummy variables (one-hot encoding). However, during some of my hierNet run in R, it gives me the following error:
Error in compute.interactions.c(x, diagonal = diagonal) :
NA/NaN/Inf in foreign function call (arg 1)
Is it the right approach to convert all variables into dummy variables? Why does the above error occur?
Hi Jacob,
This package is super helpful :-)!
I'm using hiernet(x = model.matrix( ~ -1 + ., as.data.frame(X)), y = y, diagonal = FALSE, strong = TRUE)
without intercept to analyse my proteomics data.
When trying to reconstruct the output y
on my own after fitting the model, I'm getting slightly different results than with predict.hierNet(object = fit, newx = X, newzz = compute.interactions.c(X, diagonal = F))
.
What I'm doing is the following:
theta <- (fit$th + t(fit$th))/2
interact_p <- theta[lower.tri(theta)]
coef_p <- c(fit$bp + (-fit$bn), interact_p)
Y_hat <- cbind(X, compute.interaction.c(X, diagonal = F)) %*% coef_p
Do you have any idea what the difference is?
(The compute_yhat_zz
function did not help me figure out the difference.)
Thanks a lot!
Best,
Mara
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.