code for generate traning set