Sudeep's Blog

Disorganized Thoughts in Organized Manner

Here is how you can add banner ad to Android app.
  • Create an account on AdMob: Provide your bank details etc etc.
  • Create an ad campaign: AdMob makes it extremely easy to create a campaign. After walking through the process you will end up with an ad id of the form: ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY
  • Finally, add this code to your MainActivity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow(); RelativeLayout adsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); adsLayout.setGravity(Gravity.BOTTOM); AdView adView = new AdView(this, AdSize.SMART_BANNER, "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY"); adsLayout.addView(adView); AdRequest newAdReq = new AdRequest(); adView.loadAd(newAdReq); window.addContentView(adsLayout, lp2); }
Sat Jan 04 2014
...and happy coding 2014
Here is a step-by-step method to create an processing sketch using Android SDK in Eclipse (instead of processing IDE): http://niltoid.com/blog/processing-eclipse-android-proclipsoid/
Here is a set of notes maintained by me and some others on concepts related to event-sriven reactive programming in Scala: https://github.com/sjuvekar/reactive-programming-scala/blob/master/ReactiveCheatSheet.md. The notes originated from a Coursera's class with same title: https://class.coursera.org/reactive-001/class
Kaggle just concluded their Personalized Ranking Competition hosted by Expedia. Here is a link to the competition This competition is a standout because the dataset provided is considerably bigger than their earlier competitions (about 10M X 30) and the target classes are unbalanced with about 90% of provided data consisting of single class. Any straightforward learning algorithm has many issues:
  • Every new feature increases the size of train data significantly, and soon, with a few number of features, the data becomes too big to fit in main memory
  • A simple cross-validation produces a very high validation score because of unbalanced classes and fails to generalize
Of course, these problems are solvable, and the approach the we tried had few components.
  • Carefully choose train-validation data to keep roughly the same proportion of all classes. More importantly, keep all data-points from same user either completely in train or cross validation set
  • One-vs-all classification approach was found to do better than a multiclass classification. Even there, multiple ordinal classification seemed to perform better. Here is a paper discussing this approach
We used standard gradient boosting for training and obtained an nDCG score od about 0.506. Not a terribly good score, but easily better than benchmark and within top 16% of all contenders. So, no complaints!
Thu Oct 24 2013
Sorry for being inactive for a month. Was busy with some family matters. Here I am again, with, well not much to add except this paper . This title of the paper is the title of this post. The paper talks about automatically adapting learning rate in Stochastic Gradient Descent (SGD) using curvature of error surface. Enjoy!
Kaggle's CauseEffect Pair Competition has ended and I got a rank of 19 out of 269 teams --- my second top 10% finish. Here is a link to the competition http://www.kaggle.com/c/cause-effect-pairs. Here is a brief description of the contest: You are given a large number of A-B observation pairs, each pair itself contains a list (a_i, b_i). Each pair has an indicator assigned to it A->B (meaning A is a cause of B), B->A (meaning B is a cause of A) and A-B (meaning neither, they could be independent or could be affected by a third common cause etc). The aim of the contest was to predict similar indications - A->B, B->A, A-B on new unknown pairs. The competition involved a lot of feature engineering. The learning part was mostly handled by off-the-shelf learning algorithm --- I used Gradient Boosting Forest. But the one with better feature was the winner. (For example, one of the winners developed thousands of features out of the pair). Here is a discussion of everyone's approaches: http://www.kaggle.com/c/cause-effect-pairs/forums/t/5643/sharing-methods. Finally, here is a comprehensive list of what worked and what not: http://clopinet.com/causality/FactSheetv1.pdf , compiled by the hosts.
Passport.js is a beautiful authentication middleware for node.js, but getting it right is hard for the first time. I am going to point to my own repo: https://github.com/sjuvekar/3Dthon/tree/master/auth to refer to how I did it the last time. Basic stages are simple:
  1. Include appropriate strategies (local/Facebook/Google oauth etc)
  2. Define a callback function under each strategy to create appropriate mongoDB user object, insert it into database or flash an appropriate error msg ( connect-flash is useful here) and redirect to appropriate route.
  3. Finally, define appropriate route like /auth/google/callback and call passport.authenticate("google") etc inside it.
Here's a link to passport js just in case.
Creating social logins with passport.js is super-easy. Remember three steps:
  • Configure session middleware (app.use(express.session({ secret: 'keyboard cat' })); etc...)
  • Configure authentication strategies ( passport.use(new TwitterStrategy({ ... }) etc...)
  • Add authentication routes ( app.get('/auth/twitter', passport.authenticate('twitter')); etc.)
Here is a handy tutorial: http://blog.nodeknockout.com/post/34765538605/getting-started-with-passport. I found it much better and simpler than passport.js docs. Happy node.jsing!!!
Here are some of the resources for selecting attractive fonts/icons and designs for bootstrapping for your website
  • Fonts: Font Awesome is the industry standard for creating beautiful fonts for Bootstapped website
  • Icons: IconFinder is the best free (or extremely cheap in case not free) resource for brilliant colorful icons. The icons are available in all standard sizes (I have used all sizes from 32 X 32 to 512 X 512).
  • Photos: iStockPhoto is a set of slightly expensive photo collection to use along with icons. The photos can be bought by using points and points can be earned either by paying or by uploading pictures.
  • Lauching soon placeholder: LaunchRock is a set of 'Launching Soon' web templates. I haven't used them yet, will get to it soon though!
  • Social Buttons: Here is a set of beautifully created social buttons for bootstrap. Works best with Font Awesome Library