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

A novel design, but a little tedious? #6

Open
kangning-97 opened this issue Mar 28, 2022 · 0 comments
Open

A novel design, but a little tedious? #6

kangning-97 opened this issue Mar 28, 2022 · 0 comments

Comments

@kangning-97
Copy link

kangning-97 commented Mar 28, 2022

Thanks for your perfect design. I'm verry sorry for bring some questions. Just as follows, is my code according with your design?

define original X and Y

Y <- df_pm25$PM2.5
X <- df_pm25 %>% select(-PM2.5,-DID,-sitename)
base_model <- SuperLearner(Y = Y, X = X,
SL.library = c("SL.glm","SL.glmnet"),# The first cluster models.
cvControl = list(V=2))

update new X according to the first cluster model

X_1 <- cbind(base_model$Z,X)
names(X_1)[1:2] <- paste0("X",1:2)
meta_model <- SuperLearner(Y = Y, X = X_1,
SL.library = c("SL.ranger","SL.glm"),# The second cluster models.
cvControl = list(V=2))

final

X_2 <- meta_model$Z %>% as.data.frame()
final_model <- SuperLearner(Y = Y, X = X_2,
SL.library = c("SL.nnls"),# The final cluster models.
cvControl = list(V=2))
pre <-final_model$SL.predict # prediction

@kangning-97 kangning-97 changed the title A novel design, but a little Reva? A novel design, but a little tedious? Mar 28, 2022
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

1 participant