Improvisation is a skill that requires the musician to take melodic ideas that they've learned and to then spontaneously and artistically construct the melodic lines in a way the expresses a mood or feeling. Often, musicians will find a favorite solo from a song to transcribe and then transpose into different keys. The process of doing this serves to enhance a musician's "melodic vocabulary". By learning someone else's solo, such John Coltrane or Michael Brecker, the musician can now dissect the melodic ideas and re-arrange the ideas in a way they can best express themselves.
When first learning to improvise, most musicians begin with learning both the major and minor pentatonic scales. Lets begin with the major pentatonic scale. The C major pentatonic scale, for example, is obtained from playing specific notes from the C major diatonic scale. Simply remove the 4th and 7th note of any Major diatonic scale and then you have the Major pentatonic scale.
C Major Scale C D E F G A B C 1 2 3 4 5 6 7 8(1)
C Pentatoic Scale C D E
F G A B C 1 2 3 4 5 6 7 8(1)
As well, the Minor pentatonic scale is constructed from eliminating notes from the Minor diatonic scale. For example, the C Minor pentatoic scale is created by removing the 2nd and 6th note of the C Minor diatonic scale
C Minor diatonic scale C D Eb F G A Bb C 1 2 3 4 5 6 7 8(1)
C Minor pentatonic scale C
D Eb F G Ab Bb C 1 2 3 4 5 6 7 8(1)