these codes are get from book "the machine learning in action"