Friday, March 15, 2019

Contour Plots of Loss Functions in R

In machine learning, loss functions are used to estimate how well learning algorithms perform. It is often written as loss = L(y, y_hat) where y is the true label and y_hat is predicted. Commonly used loss functions include Squared, Absolute or Laplace, Huber, Hinge, Logistic and others.

Using the Iris data set from UCIrvine,  I demonstrate how contour plots of loss functions can be obtained using R.

Background Information: The Iris data after being downloaded, was pre-processed in the following manner: Only two classes (100 examples) were selected to ensure the problem remained that of binary classification. Furthermore, two attributes were selected to enable visualizations via contour plots. The glmnet package was used to build a lasso model as shown below:



The filled contour plot generated from this is shown below:
Add in your favorite loss function -- Huber or Hinge and see some nice contour plots with the Iris data!

Friday, January 25, 2019

Story Telling at Country Parkway Elementary School


Reading a story entitled "A Little World of Mud" from Ruskin Bond's Children's Omnibus -- showcasing the work of a great Indian author of British descent -- on the occasion of International Night at my son's school. Here's the first part of the recording for my friends who missed it.Video Courtesy: Agneya Dutta Pooleery



Thursday, January 24, 2019

Tindora in poppy seed sauce


When you live in a foreign land, you try and learn to adapt to the environment. Darwinism, I think. So if you live in a place where pointed gourd is not a native, you make do with close relatives of it. I like to think that the ivy gourd is a relative of the pointed gourd. Entirely "my opinion" and may/may not be true. I did not go to the length of checking facts. Well, at least they are both gourds -- so in some sense that may be true.

People from my native place drool over pointed gourd (also known as parval or potol) in poppy seed sauce. Why not try the adaption, ivy gourd (also known as tindora) with the same sauce? Simply logic -- lead to a really yummy preparation.

Simply slit the tindora in half along the longer side, sprinkle turmeric powder and salt and keep aside for about five minutes. Grid poppy seeds and make a thick paste using as little water as possible. Heat oil in a pan, add green chillies (if you like some heat) and throw in the tindora. Stir fry until slightly (but not overly) browned. Add in the poppy seed mix and let it boil until the tindora cooks and is well done. The poppy seed paste should dry up making a thick coating on the tindora.

And there you go folks -- tindora in poppy seed sauce to be had with roti, naan or rice! Enjoy!

Sunday, March 18, 2018

SVM Loss Functions, Gradients and Hessians

Two popular loss functions used in the primal SVM formulation are: (a) Squared Loss and (b) Hinge Loss. The following note(s) show how the first and second derivatives of these losses are computed based on the assumptions of the model - a.k.a. linear model (with or without bias). Clearly, these can be extended to the non-linear kernel, however, those are left as an exercise for the reader.

Squared Loss and its first and second derivatives.

Hinge Loss and its first and second derivatives

Baby arugula and spinach salad

Baby arugula and spinach salad tossed with olive oil, pear balsamic vinegar,
dried cranberries, chopped walnuts, and dried apricots. 

Saturday, February 17, 2018

From the French patisserie

Baguette toasted with olive oil and pistachio macarons at tea time.
Heavenly, I promise.

Wednesday, January 17, 2018

Quinoa - the ancient grain.

Gluten-free blueberry quinoa pancakes

Quinoa salad with dried fruit (cranberry, apricot, currants, pecans) and herbs