Machine Learning

A.K.A Predictive Analytics.

 

The word Machine Learning itself sounds very exciting and every single day its usage is only getting bigger and bigger..

The closest definition of ML I’ve come across is as below..

A Computer Program is said to learn from Experience E, with respect to some class of Task T and a Performance Measure M… If its Performance at the tasks in T, as measured by M improves with Experience E

ML lets us find patterns in existing data, with the help of which a model is created. Now this model will be used to do predictive analysis or learning by recognizing patterns in the new data.

Some technical Jargons:

  • Training Data
  • Supervised Learning
  • Unsupervised Learning
  • Reinforcement Learning
  • Target Value – What you are trying to predict
  • Regression [Supervised Learning]
  • Classification [Supervised Learning]
  • Clustering [Unsupervised Learning]
  • Model [Is responsible for making the prediction]

Algorithms

  • Decision Trees
  • Neural Networks
  • Bayesian
  • K Means

 

 

To be Continued..

Advertisements

Tensor Flow

Some assorted notes regarding Tensor Flow.

Current version = TF1.3.. On Windows, TF1.3 can be instaled IF and Only If Python Version 3.5.2 is installed [ and not any other version]

TF is a low level library which provides an interface for

  • Expressing ML algorithms and
  • An Implementation for executing such ML algorithms..

TF is

  • Open Source
  • Scale able
  • From Google

All data in TF are termed as Tensors, representing an n-dimensional array. These Tensors flow between different operations to produce the output and hence the name – TensorFlow

 

Tensor Types:

  • Constants
  • Variable
  • PlaceHolders

 

Training a Model with TF..

  • Data Preparation
  • inference
  • Loss Calculation
  • Optimize

 

 

 

 

MongoDB Shell Functions – Can we customize ?

While working on MongoDB, I accidentally ran a find() count query incorrectly which resulted in something interesting.

While I wanted to execute db.team.find().count(), I ended up hitting enter key a bit too sooner and resultant query in the mongo shell was db.team.find().count  [yeah, without the ()]

While I was expecting an error, the shell actually responded with the function definition of count() method and it goes as below..

 

Query.png

So, above is what exactly happens when we call find().count() in the shell.

So with this, you can start looking into the design and implementation of shell functions and understand the login underneath.

 

Interpreting the query definition ourselves, we can get the count of collection as below as well.

  1. Grab a collection into variable v.
    • var v = db.team.find()
  2. Find the count of v
    • v.count()
  3. use the convertToCountCmd to get the json object
    • var cmd1 = v._convertToCountCmd()
  4. Execute the runReadCommand to get the details of count.
    • db.runReadCommand(cmd1)
  5. db.runReadCommand(cmd1).n
    • Will give the exact count needed.

Below picture depicts the same.

Query2.png Well, Now thats fun..

 

 

Also, Here is how the find() method definition looks like..Query1

One final thought before ending this blog post, will MongoDB allow us to extend the functionality of these methods? For Ex, can i create my own custom Count method using or my own shell function ? At this moment i’m not sure..

Calling all #Mongo experts to answer 🙂

 

 

 

 

Directives in AngularJS

Directives in AngularJS helps in extending the power of HTML.

The important responsibilities of directives are

  1. DOM manipulation [ng-show]
  2. Relieving view events  [ng-click]
  3. Widgets [via custom directives]

 

AngularJS provides a set of build in directives like ng-bind, ng-class etc.

Custom Directives can also be written quite easily. We can either use

  1. Link function of the directive to define how the directive should behave.
  2. Create a Directive Controller and put the logic.

Directives in your View/HTML can be written as:

  1. Element Names or Tags (E)
  2. Attributes (A)
  3. Classes (C)
  4. HTML Comments (M)

(E, A C or M are restriction types)

Note : Angular normalizes an element’s name or tag to map elements and directives. More details can be found here.

 

 

Custom Directive Code Snippet:

 

 

Few important points to note here:

  1. Angular doesn’t complain if there are multiple directives with the same name declared on a page.
  2. While loading the Dynamic DOM, Angular compiles all the directives [including ones with same name as in our examples] but only executes the first directive.
  3. Changing the order of the directive declarations having the same name impacts your output.
  4. Hence its vital to name directives uniquely.

My next post will talk more about

Requiring Directives within another and isolation of scope.

 

Mean Stack

Post#1

MEAN and How..

MEAN is one of the leading full stack java script application development stack which is currently widely used across industry to build large scale DIRTy [Data Intensive Real Time ] applications.

Of course we’ve had LAMP, WAMP and other full stack frameworks during the yester decades. However, MEAN beats them all in many ways and importantly it is Platform independent. Your Code will work on Linux, windows and heck even mac.

The essence of MEAN is Java script and i’ll continue to blog about a few things here for the betterment of the world 😛