Product Flavours have been around for quite some time now. I feel Product flavours are one of the coolest things about android and android studio. I am so smitten by product flavour that I decided to write a post about it :p. What follows will be introduction, application, grouping, filtering and configuration of product flavours in android. If you have already applied these and have any questions, shoot in comments below or mail me directly (details at the end of the post). Continue reading

## Hash based ECMP load balancing algorithm

**Context**

Data center networks every so often use compactly interconnected topologies to deliver high bandwidth for internal data exchange. In such network, it is precarious to employ effective load balancing schemes so that all the available bandwidth resources can be utilized. In order to utilize all the available bandwidth traffic need to be routed across the network instead of overloading a single path. Equal Cost Multipath (ECMP) enable the usage of multiple equal cost paths from the source node to the destination node in the network. The advantage of using this algorithm is that the traffic can be split more uniformly to the whole network avoiding congestion and increasing bandwidth consumption. Continue reading

## Docker? It’s Easy If You Do It Smart

**Context**

We all must have heard of docker but why and where exactly we need to use it, is still confusing. Also this question arises why we need to adopt this new technology if virtual machines already do the job.

Well, first of all we need to understand that, docker containers are not replacement of virtual machines. Both have got their own use case. In reality, both are complementary technologies—as hardware virtualization and containerization each have their distinct qualities and can be used in tandem for combinatoric benefits. Continue reading

## Learning Machine Learning – Part 1

What is Machine Learning(ML)? As per a definition given by Tom Mitchell, Machine Learning is the ability of a computer program to improve its Performance(P) at a given task(T) using prior experience(E).

ML problems can be broadly classified into Supervised and Unsupervised learning. These categories have further sub-categories.

- Supervised – You are given a data set and there is a known relation between input and output. The computer program uses that test data and to learn the relation and use it to predict the output for any given input.
- Regression – In these set of problems, the output is a continuous function of input, eg. Given a picture of a person, we have to predict their age.
- Classification – Here, the output is discrete. eg. Given a picture of a person, we have to identify their race/gender etc.

- Unsupervised – The computer program is not fed with test instances. It first identifies all different groups/classes that the data can be ‘classified’ into. And then use that knowledge to predict where a particular data instance will fit best into.
- Clustering
- Non-clustering

Now that we are done with definitions, lets take up a simple regression problem and dive into the mathematics involved to arrive at an algorithm(Gradient Descent).

Problem – Given the age(x) of a house, predict its price(y).

Lets assume we are given a data set of 10,000 houses with their age and current market price. So test data for our ML program will be of the form (x_{i}, y_{i}) where i ∈ [1,10000]. Now we will feed these data instances to our learning algorithm and come out with a predictor function, h(x) = y = θ_{0} + θ_{1}x, where θ_{0}, θ_{1} are variables that we need to find such that the predicted value of y is closest to the actual y.

h(x) is known as hypothesis function.

A diagram will make things easier…

This is a plot of y against x for all the test instances. Our objective is to find a straight line such that average distance of each data point from the line is minimized. That line can be represented by the equation, y = θ_{0} + θ_{1}x, where θ_{0 }and θ_{1 }are respectively, the y-intercept and the slope.

To find such line, we will use the mean squared error method.

where Y hat is the predicted value for the i^{th } instance and Y is the actual value.

Lets call this function, our cost function J(θ_{0}, θ_{1}).

## Android local networking using NSD

In this post we will see how data can be transferred between two android devices in the same network. What follows is a bit of theory and implementation in android studio. There is a source code link at the bottom of the page for reference. Continue reading