code to generate feature matrix and impl LR