Machine learning work on creating harmony to a given melody. The model was trained on Nottingham Music Database. Modified Markov decision process algorithm was used to compose chord progressions to harmonize melody. Measure of dissonance was introduced to verify the model and choose the best result.