Google Cloud Instance

In this article I will be discussing about creating a Google cloud instance.

While participating in kaggle Santander recommendation competition, I used to wonder how to deal with 2.3GB training dataset rather than how to solve problem, GOOGLE CLOUD came to my rescue in this situation.

Google will be giving you $300 free usage for the first two months. Maximum of 8 core instance can be created during free usage period. You just need to follow following steps to create an instance.

Creating Instance:

You need to sign up here and provide Debit or Credit card details before creating instance. Google will charge 67 rupees initially after you sign up but don’t worry Google will again credit it into your account and will not charge you until $300 worth usage is completed.

You need to first create a project. Here I have created a project with testing as project name. Project ID will be testing-153211.Screenshot from 2016-12-21 17-19-19.png


After creating project it will be available in projects folder on top right position of the projects section as shown below.

Screenshot from 2016-12-21 17-22-27.png

Select testing project or any other project where you need to create your instance. Here I have chosen testing as my project.

Now go to Compute Engine.


Click on Create instance to create your first instance. IT will be directed to the page as shown below.

Screenshot from 2016-12-21 17-28-55.png

Give a name to your instance. Here I have given Santander as its name. Select a zone, the cost will be differed with zone, machine type and storage selection. Here I have selected us-west1-a, 8 core 30gb memory standard machine.

In Boot disk select the type of OS you want. Here I have selected Ubuntu 16.04 LTS OS and 30gb SSD hard disk. Following images will give you idea about these things.

Screenshot from 2016-12-21 17-33-19.png

Select Compute Engine Default service account and allow default API access.

Screenshot from 2016-12-21 17-40-53.png

Click on create button to create your instance.

Congratulations!!! you have finally created Google cloud instance. Click on SSH to connect to your instance where you will be directed to the terminal of your instance.

Screenshot from 2016-12-21 17-50-38.png

Feels thrilling right. Now go and explore your instance. In the next post I will be discussing about how to setup R server in your instance.

Stay tuned!!


Lasso And Ridge Regression

In this article I will be demystifying why some of the co-efficients of the predictor variables in Lasso regression will be equal to zero while in Ridge regression none of the co-efficients of the predictor variables will approach  zero(but will not be equal to zero).

If you are new to Ridge and Lasso Linear regression concepts you can check out this article about regression on Analytics Vidhya.

In short Lasso and Ridge regression are used in case there is multicollinearity and to reduce overfitting , so that some of the co-efficients will die down to zero(Lasso) or will approach zero(Ridge).

But after checking out the cost functions for Lasso and Ridge Regression you may get doubt why one cost function reduces the co-efficients to zero and other approaches to zero.

Cost Function for Lasso Regression:-


Let’s say minimising term as A and constraint term as B.

Cost Function for Ridge Regression:-

Screen Shot 2016-12-18 at 6.53.01 pm.png

Let’s say constraint term as C and as said earlier minimising term as A.

So we need to minimise least squares subject to some constraints in Lasso and Ridge Regression. Let us solve this using some graphs.

Let us use two predictor variables, beta1 and beta2 are their co-efficients in regression.

B follows a diamond shaped graph and C follows a circle shaped graph, minimising term A follows a ellipse.

Screen Shot 2016-12-18 at 7.04.39 pm.pngGraph of cost function for Lasso Regression(Figure1)

Screen Shot 2016-12-18 at 7.04.49 pm.png

Graph of cost function for Ridge Regression(Figure2)

As you can see in Lasso the minimising function and constraint can intersect on any one of the axes making their co-efficient values zero while in Ridge the minimising function and constraint cannot intersect on any one of the axes so the co-efficient values will approach zero but will not be equal to zero.