View Post

[Tutorial] Neural Networks Made Easy — A Python One-Liner

Neural Networks have gained massive popularity in the last years. This is not only a result of the improved algorithms and learning techniques in the field but also of the accelerated hardware performance and the rise of General Processing GPU (GPGPU) technology. In this article, you’ll learn about the Multi-Layer Perceptron (MLP) which is one of the most popular neural …

View Post

[Tutorial] How to Get the Row with Minimal Variance in One Line of Python Code

You may have read about the ‘V’s in Big Data: Volume, Velocity, Variety, Veracity, Value, Volatility. Variance is yet another important ‘V’ (it measures Volatility of a data set). In practice, variance is an important measure with important application domains in financial services, weather forecasting, and image processing. Variance measures how much the data spreads around its average in the …

View Post

K-Nearest Neighbors as a Python One-Liner

The popular K-Nearest Neighbors Algorithm is used for regression and classification in many applications such as recommender systems, image classification, and financial data forecasting. It is the basis of many advanced machine learning techniques (e.g. in information retrieval). There is no doubt that understanding KNN is an important building block of your proficient computer science education. Watch the article as …

View Post

[Tutorial] How to Run K-Means Clustering in 1 Line of Python?

If there is one clustering algorithm you need to know – whether you are a computer scientist, data scientist, or machine learning expert – it’s the k-Means algorithm. In this section, you’ll learn the general idea and when and how to use it in a single line of Python code. You may know about supervised learning where the training data …

View Post

[NumPy] How to Calculate Basic Statistics Along an Axis? (avg, var, std)

This article explains how to calculate basic statistics (average, standard deviation, and variance) along an axis. We use the NumPy library for linear algebra computations. These three ways are very similar — if you understand one of them, you’ll understand all of them. Graphical Explanation Here’s what you want to achieve: Extracting basic statistics from matrices (e.g. average, variance, standard …

View Post

Python String Count [A Short Tutorial]

Want to count how often a substring occurs in a string? Or how many lines a mult-line string has? Use the count method on any string object! You can use a single argument (the substring to be counted), and two optional arguments start and end to indicate the first or the last index of the substring. This way, you can …

View Post

Method Overriding vs Overloading in Python [+Video]

Method overloading: allowing different parameters for calling the same method Method overriding: overwriting the functionality of a method defined in a parent class. Here is an example for Method overloading: What’s the output of this code? The class Wizard defines an instance attribute ‘mana’ that represents the energy level of the respective Wizard instance. If the mana level is drained, …

View Post

Inheritance in Python + Harry Potter Example

You have the eyes of your mother. One could say, you “inherited” the eyes of your mother. As you may have guessed, this article is about inheritance in Python. Inheritance is one of the main motivators of using object orientation. It’s a simple and intuitive concept but even advanced coders circumvent using inheritance because they have this latent feeling of …

View Post

The Single and Double Underscore in Python [“_” vs “__”]

The single underscore in Python “_” is used to either make a variable different from a Python keyword (e.g. “float_=8”), or to indicate that it should be used in a private context (e.g. “_var=8”). The double underscore “__” (called “dunder“) is used to make an instance attribute or method private (cannot be accessed from outside the class) — when used …

View Post

A Simple Example for Python Objects and Classes [+Video]

In Python, everything is an object. Even integer values are objects — this is different from programming languages like Java where integers, floats, and booleans are primitive data types. In this way, Python is built on a rigorously consistent object-oriented paradigm. Considering that objects are everywhere in Python, object-oriented programming is comparably little known by Python coders. A huge mistake! …

View Post

Discover Self in Python [+ Video Guide]

Many beginners who just start out with object-oriented programming in Python are confused about the purpose of the keyword “self”. Let’s resolve this confusion once and for all! The first argument of any instance method in Python is reserved for a reference to the calling instance. This argument is by convention called “self”. However, NEVER violate this convention and call …