Wednesday, May 13, 2020

Backyard Birds 05/13/2020

House Finch far away on a tree branch

A close-up

Robin hopping in the front yard

Thursday, May 7, 2020

Fish Stew (Machher Jhol)

Being a Bong (a native of West Bengal, India), I am often asked about various fish recipes. I never cared much for writing those down -- but I remembered them exactly like my mom and her mother made them. Personally, I am not a fish aficionado, and I do love some preparations more than others.

Machher Jhol, fish stewed with vegetables (raw banana, papaya, potatoes, beans) is a staple diet of people from West Bengal, India. The easy availability of fish (mostly fresh water) and home grown vegetables provides the inspiration.

I am usually not the kind who wants to write long recipes -- so here is a basic outline of how this can be made. Marinate fish (salmon, tilapia, catfish all work well) with turmeric, salt and optionally lemon. Pressure cook raw banana, papaya, potatoes, beans and other vegetables you have handy. In a wok, heat oil. Add cumin, chopped tomatoes, ginger garlic paste, green chilies, turmeric, cumin powder, salt to taste, a pinch of sugar (to taste) and let it fry with all of the above ingredients until the oil oozes out of them. Add the vegetables, and allow the mixture to boil for a few more minutes. Add in the marinated fish and cook, keeping covered until fish is done. Sprinkle garam masala and squeeze lemon. Your maccher jhol is ready to serve.

A few notes:
a. Kids usually like this with a lot of lemon -- the tanginess helps to keep the odor off and also adds to the flavor.
b. You can easily use cauliflower florets, green peas, and brinjals.
c. You can also put a little ghee as a topping and garnish with coriander leaves.
d. The gravy can be thick or thin depending on your taste.
e. Additionally, you can add bori (https://food.ndtv.com/recipe-bengali-dal-bori-902821) after frying and it really enhances the taste.


Sunday, May 3, 2020

Homemade cream cheese and spinach ravioli without a pasta maker

Being a non-Italian, trying to make ravioli at home from scratch made me somewhat apprehensive. The process is elaborate at best -- but something told me, it'd be worth the effort.  Examining a few youtube videos made me feel more comfortable, but I did not have a pasta maker at hand. So my skills in making Indian recipes (chappatis) came handy, except they needed to be ultra thin -- almost like roomali roti (for those unfamiliar with this term -- it means a chappati as soft as a handkerchief).

So here are some visuals from first experiment.



Cream cheese and spinach filling

Ravioli rolled without a pasta maker and cut using a simple kitchen knife. I have to work on the shapes -- that will be the focus next time.

                                 Thankful they did not disintegrate when boiled.


Nice and soft.

The final product. Had a sauce made from onions, tomatoes and peanuts -- an Indian touch to the whole dish. Also some green onions and coriander leaves to spruce it up.

Since my family is willing to be guinea pigs again, I assume it was a successful experiment. 

Saturday, May 2, 2020

Grilling, salmon and butternut squash

The preparation



                     Smoked Salmon and Butter nut squash


                            Thai inspired pineapple fried rice


                      Smoked salmon and butternut squash



Wednesday, March 4, 2020

Creating 3D Surface Plots in R -- Examples Using Iris Data


I downloaded the Iris data set from the UCI Machine Learning Repository and pre-processed it as follows: I just took the first two classes (I wanted a binary classification dataset) which had 100 instances and changed the class labels to 0/1. I retained all four of the attributes -- Sepal Length, Sepal Width, Petal Length and Petal Width.

Next, I took two attributes at a time, built a linear model (lm) in R and fitted the data. I wanted to visualize the surface of the loss functions using Absolute Loss and Squared Loss. Here is the code I used to generate my plots.


I present below a summary of my results:

Model 1a. Absolute Loss – Sepal Length, Sepal Width



Model 1b. Absolute Loss – Sepal Length, Petal Length



Model 1c. Absolute Loss – Sepal Length, Petall Width



Model 1d. Absolute Loss – Sepal Width, Petal Length



Model 1e. Absolute Loss – Sepal Width, Petal Width



Width

Model 1f. Absolute Loss Petal Length, Petall Width





I found that the model with Sepal Width and Petal Length has the highest Adjusted R Squared (0.9574).

What did you discover? Please do let me know! Also, if you want to play around with colors in R -- here is a nice reference. Enjoy coding in R!

Wednesday, March 27, 2019

R code for Gradient Descent

Assume that we have one dimensional data and y=1.2*(x-2)^2+3.2. This implies that y has a closed form solution, known apriori. Then it is straight forward to obtain the first derivative and perform a gradient descent. Here is the R code for the above.



Now suppose, we still have one dimensional data but the functional form of y is unknown. How would we do Gradient Descent in that case? Below is the R code to do just that.



Now here are some variants of these to experiment with:
a. Replace the squared loss with a differentiable loss function of your choice and observe the impact on your favorite data set.
b. How does the parameters of the algorithm (alpha, # of iterations, choice of starting point) affect the convergence time of the algorithm?
c. How will you modify this code to implement the stochastic gradient descent algorithm?
d. Suppose we added a bias term to your hypothesis and asked you to repeat the experiments. What do you observe -- is the bias term beneficial?
e. Suppose we changed the hypothesis to be nonlinear for e.g. h(x) = w^2 x+ wx + b. Is the solution you find any better?
f. How will you modify the code above to implement Newton's algorithm (Clue: You need to use Taylor expansion for representing the function with higher order terms).

If you can report the above results on your favorite data set, I'd like to hear from you!

Also, feel free to ask questions in the comments if you are wondering about something.

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!