On Model Selection for Bayesian Networks and Sparse Logistic Regression