Tuesday, May 23, 2017

Probabilistic algorithms

https://www.safaribooksonline.com/oriole/probabilistic-data-structures-in-python

Set Cardinality - HyperLogLog
Set Membership - With False positives but no False negatives - Bloom Filter
Set similarity (document similarity) - MinHash with Jaccard
Frequency Summaries (Leaderboards in games) - Count-min sketch
Streaming Quantiles - stream of data where you have to aggregate metrics without stopping - T-Digest (like min/max/percentile)



Friday, May 19, 2017

Java print current stack trace

StringWriter sw = new StringWriter();
new Throwable().printStackTrace(new PrintWriter(sw));

//And to actually print it
Log.e("tag","Current stack trace is:\n" + sw.toString());

Friday, May 12, 2017

Tuesday, April 25, 2017

Java - iterate over a UTF-8 string

Either read the file as UTF-8 or convert it later.


public static void main(String[] args) throws Exception {

String path = "D:\\test.txt";
FileInputStream stream = new FileInputStream(new File(path));
BufferedReader br = new BufferedReader(new InputStreamReader(stream,"UTF-8"));
String str;
while ((str = br.readLine()) != null) {
System.out.println(str.length());
for(int i = 0; i< str.length(); ++i) {
System.out.println(String.format("%04x",(int)str.charAt(i)));
}
}
}

OR

BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String str;
while ((str = br.readLine()) != null) {
byte[] ptext = str.getBytes(ISO_8859_1);
str = new String(ptext, UTF_8);
System.out.println(str.length());
for(int i = 0; i< str.length(); ++i) {
System.out.println(String.format("%04x",(int)str.charAt(i)));
}
}

Java get unicode point of a character

class Main {
  public static void main(String[] args) {
char ch = 'ö';
System.out.println(getUnicodePoint(ch));
ch = 'म';
System.out.println(getUnicodePoint(ch));



  }

  private static String getUnicodePoint(char ch) {
      String hex = String.format("%04x", (int) ch);
       return hex;
  }
}

Tuesday, April 11, 2017

outlook not starting


Start Outlook in safe mode to fix "Processing" screen

If Outlook stops responding at a screen that says "Processing," you can close Outlook, start it in safe mode, then close it and open it normally to fix the problem.

Close Outlook.

Launch Outlook in safe mode by choosing one of the following options.

In Windows 10, choose Start, type Outlook.exe /safe, and press Enter.

In Windows 7, choose Start, and in the Search programs and files box, type Outlook /safe, and then press Enter.

In Windows 8, on the Apps menu, choose Run, type Outlook /safe, and then choose OK.

Close Outlook, and then open it normally.

Monday, March 13, 2017

Andrew Ng machine learning

Gradient Descent vs Normal Equation
Normal equation good for smaller feature size

Normal Equation Noninvertibility
too many features (m <= n)
redundant features (linearly dependent)
pinv vs inv in Octave.
Normal equation - regularization makes X'X invertible even if it's not.

Blog Archive