So I found this amazing blogger Vimarsh Karbhari and he have some amazing stuffs on his blog! So please check him out, also he is the creator of Acing AI. And today, I'll try to answer his Microsoft AI Interview question from this blog. And please note that my solution would be not optimized, and I am always open to learning and growing.
Also, I am not going to answer question in numeric order.
Merge k (in this case k=2) arrays and sort them.
For this I would use Bubble sort, I know that this is not the most efficient sorting algorithm, but it is easy to describe and implement.
What are the different cost function / regularization metrics L1 and L2?
I would say, L1 is absolute difference between predicted value and ground truth value. For L2 I would say it is the Mean Square error difference. I implemented and compared variety of combinations of L1 and L2 cost function with regularization in this post. Also, L1 regularizer is Sum of absolute values in the weight, and L2 is sum of square value of all the weights.
How do you find percentile? Write the code for it.
For this lets just do a simple question from Math is Fun. Given the above table lets get the time when the 30% people have visited the mall.
I would get the 30% percentile first and get the average time value, obviously this is not the most accurate answer as seen below. But we can get the general feel.
What is a difference between good and bad Data Visualization?
Okay for this we can have many different answer, my answer would be something like when we do not properly handle outliers and visualize them.
Lets say we have an array of numbers and we can see there is a huge number (7777) among smaller numbers. When we visualize this array all together it looks something like below.
Right Image - Original Image
Middle Image - Normalized value
Left Image - Standardized value
How to compute an inverse matrix faster by playing around with some computational tricks?
I actually have no idea what the exact answer is, but upon research I found the method called Gauss-Jordan method
, however it is very complex. (to see the implementation in python please click here
.) And I was manage to find a simpler solution as seen below and implemented this method.
In my words, I would describe variance as the sum of square difference of each data point, respect the mean of whole data. In other words, are there a lot of variety in the data. And actually, Math is Fun have an amazing diagram describing this.
For Google Colab, you would need a google account to view the codes, also you can't run read only scripts in Google Colab so make a copy on your play ground. Finally, I will never ask for permission to access your files on Google Drive, just FYI. Happy Coding!