If all the notes and code are your original expression of ideas, that would not be copyright infringement.
You should consider writing your own book on machine learning, and selling that. Copyright protects the particular expression of concepts, but not the concepts themselves. If you have a better way of expressing the challenging concepts of machine learning, that is clearer than the prior text, and your own expression rather than the author's, that's a separate work.
If the original text says something in English like "you randomly determine clustering start points, then assign data points to the closest cluster, then re-estimate cluster centers by the average of the data points assigned to the cluster, and repeat those last two steps until the cluster centers don't change by more than a small epsilon between iterations, and repeat this process several times with different random starting points, using xyz measure to assess the quality of the finished clustering and take the best," that describes an algorithm but not as clearly as you might do it. If you have source code which implements this, which you completely wrote yourself, that's a different expression of the concept, and you would have choice about how to license it (so long as you're not infringing on somebody's utility patent). In addition to a clearer explanation, your added notes about how to choose the number of clusters, how small epsilon should be, how many random restarts to do, how to watch out for nonconvergence due to periodic oscillation of a cluster center by more than epsilon, etc. might also provide more value beyond the prior text.
Of course, you should credit the original author in your text, and I am not a lawyer.