Lecture 13 planet  decision trees, large scale machine learning

Large Scale Machine Learning

Size of data affects model performance much more than a fancy model (even Naive Bayes performs very well). - “The Unreasonable Effectiveness of Data” Decision trees can handle a fund hundred/maybe our to a thousand features. Important to do early stopping to prevent overfitting.

Decision trees:

FindBestSplit is the hardest and we focus on that here, StoppingCriteria and FindPrediction are pretty basic and we go over in the appendix.

FindBestSplit: How to split?

Regression: Use purity:

That is, the difference of variance of the data coming in, and the sum of the variances of the data coming out is as large as possible. If the decrease in variance is as large as possible, we have increased the purity of our data. By variance, we mean variance in the output labels: $Var(D) = \frac{1}{n} \sum_{i \in D}(y_i - \bar{y})^2$

Classification: Use information Gain

Measures how much a given attribute X tells us about the calss Y. $IG(Y|X)$: We must transmit $Y$ over a binary link. How many bits on average would it save us if both ends of the line knew $X$?

Aside: Entropy

Def: Entropy: The smallest possible number of bits on average per symbol needed to transmit a stream of symbols drawn from X’s distribution. The entropy of $X$ is defined as

Low entropy: X is from a uniform distribution (entropy= 1 if evenly distributed, 0 if all the same), High entropy: X is from a varied (peaks/valleys) distribution. A histogram of the frequency distribution of values of X would have many lows and one or two highs.

Information Gain (Used for classifications)

Def: Specific conditional entropy:

Def: Conditional Entropy:

Def: Information Gain: I must transmit $Y$, how many bits on average would it save me if both ends of the line knew $X$? Tells us how much info about Y is contained in X.

Screenshot 2019-10-29 at 11.05.27 PM.png

##PLANET - Building Distributed Decision Trees Using MapReduce General considerations when building a tree: Sometimes, dataset too large to keep in memory, or dataset too big to scan over in a single machine.

PLANET - Parallel Learner for Assembling Numerous Ensemble Trees.

(Panda et al, 2009] Still the state of the art for building large-scale decision trees. A sequence of Spark jobs builds a decision tree. SPark MLLib Decision Trees are based on PLANET.

Setting:

PLANET Architecture: Master keeps track of the model and decides how to grow the tree. The tree is grown level by level, where each level is one MapReduce job. Master takes the current model, the attribute metadata, and the input data, and builds the next level of the tree. These MapReduce jobs each get a set of split candidates and compute their quality.

Screenshot 2019-10-29 at 11.30.10 PM.png

Algo: Tree is built in levels. For each level: 1. Master decides candidate splits $(n, X^{(j)}, v)$ and tells each mapper which splits $(n, X^{(j)}, v)$ to consider. 2. Each mapper gets a subset of data and computes partial statistics for a given split. 3. Reducers collect partial statistics and ourput the quality for a given split $(n, X^{(j)}, v)$. 4. Master makes the final decision as to where to split and grows the tree for one level. \

Screenshot 2019-10-29 at 11.34.03 PM.png

Here is a summary of the breakdown of tasks between mapper, reducer, and master: (2)

In total, there are three types of MapReduce Jobs

  1. MapReduce Initialization (ron once first)
    • For each attribute, identify values to be considered for splits.
  2. MapReduce FindBestSplit (run multiple times, once per level)
    • Mapreduce job to find best split (when there is too much data to fit in memory)
  3. MapReduce InMemoryBuild (run once last)
    • Similar to BuildSubTree but for small data.
    • Grows an entire sub-tree once the data fits in memory. Output: a model file: A file describing the state of the model.

PLANET Components:

Master Node:

Screenshot 2019-10-30 at 12.01.33 AM.png

MapReduce FindBestSplit:

Goal: For a particular split node $n$ find attribute $X^{(j)}$ and value $v$ that maximize purity

where $D, D_L, D_R$ are the parent, left child, and right child datasets produced by the split.

Note that $Var(D) = \frac{1}{n} \sum_{i \in D}(y_i - \bar{y})^2 $ $= \frac{1}{n} \sum_{i \in D}{y_i^2} - \left( \frac{1}{n} \sum_{i \in D} {y_i} \right)^2$. Important observaition: Variance can be computed from sufficient statistics: $N, S=\sum y_i, Q=\sum y_i ^2$ - So each mapper processes subset of data $D_m$ and computes $N_m, S_m, Q_m$ for its own $D_m$. - Each reducer combines the statistics and computes global variances and then purity:

The process for each component is as follows:

Mapper

Screenshot 2019-10-30 at 12.23.24 AM.png

Summary

Screenshot 2019-10-30 at 12.25.37 AM.png

Screenshot 2019-10-30 at 12.28.44 AM.png

Ensemble of Decision Trees

##Appendix: (1) StoppingCriteria: When to stop splitting? If you split too much, you overfit.

Two ideas for when to stop: 1) When the lead is pure in calssification, or in regression, when $var(y) < \epsilon$ for a low threshold $\epsilon$ 2) When # of examples in the leaf is too small, ex. $|D| < 100$.

FindPrediction: How to Predict? Regression

(2) Breakdown of tasks: Mapper:

(3) For small data, we can sort the values along a particular feature and consider every possible split. But data values may not be uniformly populated os many splits may not really make a difference.

(4)Technically initializaion only generates (attribute, value), and the master will append the node later.

(5) We split in a fashion such that we use a limited number of splits such that splits ‘move’ about the same amount of data. We heuristically compute a ‘historgram’ on data and bucketize it such that the counts per bucket are equal. We do it by hashing. Note we must use an ‘equi-depth’ hash function.

(6) Note that the split candidates are only uniformly distributed among mappers in the beginning, as the mappers split the tree, the split candidates are no longer uniformly distributed. That is okay, if we wanted to remake the split candidates each round the algo would take 2x the time.