Created
May 16, 2017 18:20
-
-
Save jongbinjung/34e225663b453c6bec4ea509f9baf2a5 to your computer and use it in GitHub Desktop.
Select-regress-and-round
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming a (logistic) model with k features fit in R with the variable name "model", | |
# generate a simple rule that uses integers in the range [-M, M]: | |
# (note that M is set to 3 in this example) | |
M <- 3 | |
model_coefs <- coef(model) | |
scaled_coefs <- (model_coefs / max(model_coefs)) * M | |
rounded_coefs <- round(scaled_coefs) | |
# The k features to be included in the initial model is best determined by domain expertise, | |
# i.e., what are the minimal features that expert(s) in the field believes to be predictive | |
# of whatever you are trying to predict? | |
# Although, in the absence of domain expertise, you could use step-wise variable selection methods | |
# e.g., leaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment