[note] Launch AWS EC2 instance for Kaggle competition

I had been using one single laptop - mid-2012 MBP for participating kaggle competitions for a while.

In the last few days of BNP Paribas competition on Kaggle, I was limited by the computation speed (each XGBoost or RF took nearly one hour) to try out my ideas. Therefore, I went for AWS EC2 in order to acquire more firepower, and I was satisfied with the final result - my first Top 10% in the competition. It really helped me a lot.

Let me take a note here about how I configured a ubuntu-based m4.2xlarge instance with 8-core, 32 GB memory and installed required python libraries including sklearn, pandas, scipy, numpy.

TODO

Read More

[note] MySQL: reverse version of LIKE

Task

We all know that LIKE help us to find all the rows with certain fields contains specific keywords.

1
SELECT * FROM my_table WHERE name LIKE '%KEYWORD%'

What if we need to do the opposite? i.e., to find rows that are CONTAINED in our query text
Yeah, it’s my first time running into this kind of use case…

Solution

1
SELECT name FROM my_table 
WHERE 'John Smith and Peter Johnson are best friends' LIKE
  CONCAT('%', name, '%')

and then you will get all rows contain John, Peter.

Another option is to use REGEX:

1
SELECT  name 
FROM    my_table 
WHERE   'John Smith and Peter Johnson are best friends' REGEXP name;

Reference

Stackoverflow - MySQL: What is a reverse version of LIKE?