Getting yourself ready for being a Machine Learning Engineer

At the core, its all about knowing:

  1. Probability
  2. Statistics
  3. Linear Algebra
  4. Calculus

My top resources for

  1. Probability and statistics :
  2. Calculus : https://ocw.mit.edu/courses/mathematics/18-01sc-single-variable-calculus-fall-2010/
  3. Bayesian Analytics: https://www.coursera.org/learn/bayesian-statistics/home/info

The best way to start Machine Learning is Andrew NG’s flagship course: https://www.coursera.org/learn/machine-learning

 

Aside: I plan to make this a living document. I will update it as and when I find new resources.

Separable Filters

For convolution / cross-correlation, we use kernels.

Application of an mXm kernel normally takes m2 operation. If the kernel is separable, then it takes only 2m operations.

Hence, some kernels K, can be split into UVT.

For any given K, we can determine if we can split it into separable kernel by taking its SVD.

Let u,z,v = SVD(K)
K is separable, if, Z[0]!= 0 and Z[!=0]=0
Then, U = √(Z[0]) X u1 and V = √(Z[0]) X v1T

See the Jupyter Notebook to see the implementation in python :

http://josephkj.in/wp-content/uploads/2017/01/SeparableFilters.html 

Using pre-trained Deep Convolution Neural Networks as feature identifiers.

We are going to use a Resnet-50 Model trained on ImageNet dataset, as a feature extractor, for a set of input images. The extracted features will be used by a Linear SVM to predict whether any random input image, is in either one of two classes that it belongs.

Steps are enumerated here: http://josephkj.in/wp-content/uploads/2017/01/Classifier.html

Jupyter Notebook Download (NB: Unzip before uploading to Jupyter. The notebook ran successfully on macOS Sierra.)

Pre-req: MxNet, OpenCV, ScikitLearn

I recommend you have the latest Anaconda installed, build the MxNet binary and link it with python that came with Anaconda. That would be perfect.

Simple Webserver in Python 3


#! /usr/local/bin/python3
from http.server import HTTPServer, SimpleHTTPRequestHandler, BaseHTTPRequestHandler
import sys

def start_server(server_class = HTTPServer, handler_class = SimpleHTTPRequestHandler):
    port = 9099
    server_address = ('',port)
    httpd = server_class(server_address, handler_class)
    try:
        print("Serving at port: " + str(port) + ".")
        httpd.serve_forever()
    except KeyboardInterrupt:
        print("\nStopping server.")
        httpd.server_close()
        sys.exit(0)

start_server()


 
 

Concise Python Naming Standards

  • Name your classes and functions consistently; the convention is:
    • to use CamelCase for classes and
    • lower_case_with_underscores for functions and methods.
    • Always use self as the name for the first method argument.
  • Use spaces around operators and after commas, but not directly inside bracketing constructs:

    a = f(1, 2) + g(3, 4).

  • Use 4-space indentation, and no tabs.

    4 spaces are a good compromise between small indentation (allows greater nesting depth) and large indentation (easier to read). Tabs introduce confusion, and are best left out.

  • Wrap lines so that they don’t exceed 79 characters.

    This helps users with small displays and makes it possible to have several code files side-by-side on larger displays.

  • Use blank lines to separate functions and classes, and larger blocks of code inside functions.

  • When possible, put comments on a line of their own.

  • Use docstrings.

  • Don’t use fancy encodings if your code is meant to be used in international environments. Plain ASCII works best in any case.

 

Source : https://docs.python.org/2.7/tutorial/controlflow.html#intermezzo-coding-style

Excellent resource: https://google.github.io/styleguide/pyguide.html

Creating a CSV file on the fly and downloading it using Javascript

There might be situations where you need to create a CSV using some data available within JS layer and allow a user to download it. So you need to construct the CSV file on the fly and then allow the user to download the file.

Data-URI scheme helps in achieving this. You can specify the contents and file name of the file to be downloaded and attach these properties to an anchor element.

This is how you can do it:


<html>

<script type='text/JavaScript'>

 function downloadAsCSV() {
    var a = document.createElement('a');
    a.href = 'data:attachment/csv,' + encodeURIComponent("hello,world!\r\nHow,are,you?");
    a.target = '_blank';
    a.download = 'sample.csv';
    document.body.appendChild(a);
    a.click();
 }

</script>

<body>
 <span style="cursor:pointer;" onclick="downloadAsCSV()">Download as CSV</span>
</body>

</html>

This works on Chrome and Firefox.

35.0.1916.99 version of Chrome has a bug, which can be tracked here.