Month: February 2019

Static and Dynamic Attributes in Python – What’s the Difference?

Let’s play with some code first to answer this question: You can also watch my explainer video while you read through the remaining article: By studying this question, you will improve your understanding of not only the fine details but also of the whole picture “object-oriented programming”. So, let’s start by answering the two questions: …

Static and Dynamic Attributes in Python – What’s the Difference? Read More »

NumPy Diff Simply Explained [Bonus Video]

The NumPy diff function np.diff() calculates the difference between subsequent values in a NumPy array. For example, calling np.diff() on the NumPy array [1 2 4] would result in the difference array [1 2]. Here is a detailed example: This code snippet shows the most simple form of the np.diff() method: how to use it …

NumPy Diff Simply Explained [Bonus Video] Read More »

Machine Learning Linear Regression Python

Python Linear Regression in One Line [A Helpful Illustrated Guide]

This one-liner uses two Python libraries: NumPy and scikit-learn. The former is the de-facto standard library for numerical computations (e.g. matrix operations). The latter is the most comprehensive library for machine learning which implements hundreds of machine learning algorithms and techniques. You may ask: “why are you using libraries in a Python one-liner? Isn’t this …

Python Linear Regression in One Line [A Helpful Illustrated Guide] Read More »

The Ultimate Guide to Python Sets – with Harry Potter Examples

This article gives you everything you need to know about sets in Python. To make it a bit more fun, I have used Harry Potter examples throughout the article. ​Table of Contents What is a Set in Python?How to ​Create a Set?Can a ​Set ​Have ​Multiple ​Data ​Types?What ​Are ​Real-​World Examples of ​Sets?[Overview] What ​Are the …

The Ultimate Guide to Python Sets – with Harry Potter Examples Read More »