Machine Learning

Machine LearningThe most difficult part for me was the code required to compute the partial derivatives.

Eventually using Octave I was able to vectorize the code and compress into a line.

Several years of Java programming experience didn’t prepare me for this type of code dealing with matrix transpositions and calculations.

Cost function I was asked to minimize is

J(\theta_0,\theta_1) = (\partial/\partial \theta_0 )1/m \sum_{i=1}^{m} ( h_\theta(x^{(i)}) - y^{(i)}) x^{(i)}

Plots showing the result of computing the gradient descent

3D Plot

3D

Contour Plot

Contour

I also learnt single and multi-variate Linear Regression which will help me with my Capacity Planning calculations.

Selenium WebDriver and Play

big-logo
I have advocated tests using Selenium WebDriver in the past many times. Will it become a de facto standard now that frameworks like Play make it very easy ?

It is not even evident below that Selenium WebDriver is being used. It is HTMLUNIT that is imported statically.

A test server is started, a test application is setup and a browser is simulated, all in a few lines of code. Very economical.


import static org.fest.assertions.Assertions.assertThat;
import static play.test.Helpers.*;

import org.junit.Test;

import controllers.routes;
import play.Logger;
import play.libs.F.Callback;
import play.test.TestBrowser;
import static helpers.TestSetup.*;

public class ProposalSubmissionTest {

	@Test
	public void proposalTest(){
		running(testServer(3333,fakeApplication(testDbSettings())),HTMLUNIT, new Callback<TestBrowser>(){

			@Override
			public void invoke(TestBrowser browser) throws Throwable {
				browser.goTo("http://localhost:3333" + routes.MainController.newProposal().url());
				assertThat(browser.title()).isEqualTo("New Proposal");
				Logger.debug(browser.title());
			}
			
		});
	}
}

OAuth flow

I have tried to draw the flow of Twitter OAuth as well as possible. The signatures are yet to be investigated.

This is the best picture quality I could get.

OAuth

OAuth

I have not fully analyzed the OAuth flow yet. Another post will deal with that. So for now I am able to use OAuth to call the Twitter API and redirect to my callback URL.

I have registered this callback URL when I created the Twitter Application.

Create a Twitter App

OAuth1

Obtain the Consumer key and Consumer Secret

Configured these to be used by the Play application.

Authorize

OAuth

Reactive application

I really cannot believe that the firms in Chennai do not have any need for newer technology. On the one hand requirements are clear about scalability, resilience etc. On the other hand the developers do not show interest in new ideas. We had a requirement to notify users when reports are generated in the background thread.

Why don’t we read books and learn to use newer ideas ?

Play has an event handling mechanism that publishes events that refresh the browser with new data.

When I submit new data in the browser on the right, it shows up immediately in the other browser.

Events