Code Snippets

The best Python 3 Machine Learning code snippets for your favourite Data Science tasks.

Find quick, concise, and clearly commented code snippets for your day to day Machine Learning tasks. Parameters are well defined and explained, and examples are given so you know just how to use them!

The Confusion Matrix

A fully explained code to get an aesthetically pleasing visualisation of the confusion matrix in Python to address the performance of classification algorithms. Find more about this evaluation method here: The Confusion Matrix in Python.

python confusion matrix

The ROC Curve

Learn to plot the ROC curve in Python and calculate the Area under the curve or AUC score with this code snippet in Python with all the needed parameters explained. You can learn about the ROC Curve with this article: The ROC Machine Learning evaluation method.

roc curve python

The Lift Curve

A unique Machine Learning code snippet: The fully detailed code to get an aesthetically pleasing visualisation of the Lift Curve in Python to address the performance of classification algorithms. Find more about this evaluation method here: The Lift Curve in Machine Learning.

lift curve code

We hope you found this section on Python Machine learning code snippets useful. In case you are looking for further material to learn Python check out ourĀ Python Books section, where you will find intro to Python books as well as advanced Python Material to cover all your needs and learn to code Python. Enjoy!

advanced python fundamentals

Thanks for reading How to Learn Machine learning, and have a fantastic day!