Simple, module wise implementation of Decision Trees using Gini index

Photo by on

I’ve talked quite a bit about decision trees. This is the article that we actually implement one. For the very basics, decision trees are a class of supervised learning algorithms in ML that relies on repeatedly splitting the dataset with respect to the “most plausible feature” to construct a graphical structure that has decisions at the level of roots. Since this is implementation-focused writing, there won’t be much of theoretical discussions.

Inner mechanisms

For this article, I’ll refer to the target column of the dataset as Y and the rest as X. …


The door to Epiphenomenalism

Photo by on

Think of a brilliant scientist called Mary made to live in a dark room unable to connect to the external world except via a screen through which she monitors the world and unfortunately the screen is only capable of displaying grayscale images. Mary, a neurophysiologist by profession, excels in the field of human vision, visual perception, and the science of colors. One fine sunny morning, she is released into the wide world that so far existed beyond her physical knowledge. Now the question that arises is whether Mary will learn anything new after being released into the wilderness.

This is…


The data itself is redundant, all that is needed to know is if it was greater than a threshold.

Photo by on

Activation functions are the driving forces of artificial neural networks, as they sit on top of any neuron and administer its behavior such as if it should fire upon a certain input, if it does, to what degree, and so on. Technically speaking, the activation function of a certain node takes as input the data from its predecessors in the network and spits out a certain value that in turn indicates to its successor nodes how “turned on” it was in response to the particular input signal. …


“Computer vision is the science of programming a computer to gain a high-level understanding of digital imagery.”

Photo by on

ConvNets are at the heart of image recognition and computer vision. One of the most fascinating things about this is how a sequence of raw mathematical operations like multiplication and addition goes all the way to process and recognize complex visuals. In this episode, we talk about a few fundamental concepts of computer vision, define and illustrate the working procedure of ConvNets and jot down some technical terms associated with that. First, let's talk of the idea since they are bulletproof(!)

The idea

The idea is simple, detect what’s inside an image, playback video, or a live recording (since all videos are…


Can you beat what you just created?

Photo by on

Wonder why it is virtually impossible for an average person to beat a computer in strategic board games like chess, go, or tic tac toe? That’s because computers can literally see into the future (or futures, to be precise) of the game and decide the upcoming move accordingly. The class of algorithms exploited in this context is known as Adversarial Search. The core motive of such algorithms is to play defensively and resist the opponent from winning at any cost. …


Photo by on

In the previous episodes, we’ve discussed a few clustering strategies like centroid based and hierarchy based (, if interested); in this episode, we talk of yet another family of clustering algorithms. Density based clustering algorithms are ones that proceed by finding the areas with a higher concentration of data points and merge those with similar concentration into a single cluster. Now, I know this might seem a little vague, like what’s concentration? How can it be similar? And so on. So without further adieu, let’s dive into the matter.

The intuition

One of the best ways to…


Photo by on

So you’re reading this, but how confident are you that this is the same text from the author stated above and hasn’t been compromised to something else on the way (like I was writing on Data Science and the adversary altered it to a text on cryptography)? Well, networks are quite precarious in nature and such an incidence shouldn’t be surprising at all. In network communications, the integrity of the message to be delivered is just as important as secrecy and other privacy requirements are.

By integrity, we mean that a message (like this article is a message from me…


Photo by on

Over the years, we’ve all grown up and so have Alice and Bob. Now they need more sophisticated and reliable cryptographic standards. That’s where the idea of public key encryption pops in. Public key encryption, in the generic sense, is a scheme that employs one globally shareable public key and an individual private key from each side. The message can be decrypted via a proper combination of the keys on each side. A classic instance of such a scheme is the ElGamal cryptosystem, which we dissect in this episode.

Okay, to study the ElGamal algorithm, we need to have a…


Photo by on

Say you’ve got a bunch of points (or objects, suppose, with reasonable similarity among each) and now you want to arrange them into nice little buckets, but the problem is you don’t know how many different sets to partition them into. So you can’t use k means or any related ones (obviously because the value of k is not known or cant feasibly be guessed). What can you do now? We go HIERARCHICAL then!

Okay, funs aside😉. The idea of hierarchical clustering is to build clusters that have predominant ordering from top to bottom (


Photo by on

Being a data science enthusiast (which you are since you’re reading this), you must have come across quite a number of K prefixed phrases like k means, k modes, k nearest neighbors, and so on and while they might seem a little baffling at first glance, with a little thorough reading you’ll find though they might seem similar, they make perfect sense. Okay, in this lesson we’re gonna take a little closer look at one of there siblings, the K Medoid Clustering. So let’s get going.

Here’s a summary of what we’ll be doing over here, first why K…

Hussain Safwan

Developer, writer, artist. Total blend. Visit me at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store