forked from yang/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI.page
More file actions
1654 lines (1455 loc) · 71.5 KB
/
Copy pathAI.page
File metadata and controls
1654 lines (1455 loc) · 71.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
TODO
- perplexity <http://en.wikipedia.org/wiki/Perplexity#Perplexity_of_a_probability_model>
- generalized additive models (GAM) <http://www.win-vector.com/blog/2011/02/the-cranky-guide-to-trying-r-packages/>
- "linearizing" variables: <http://www.win-vector.com/blog/2012/07/modeling-trick-masked-variables/>
- adaptive lasso aka iterated reweighted l1 (see also iterated l2)
- merge in notes from CS182, 6.867
- Why do kernel smoothers divide the norm by λ before applying the weight fn? Isn't it dealt with in the summation in the estimator fn?
- kalman filters, smoothing
- particle filters
- <http://measuringmeasures.com/blog/2010/3/12/learning-about-machine-learning-2nd-ed.html>
- separating hyperplane
- sigmoid kernel function
- k-means++
- <http://hunch.net/?p=224>
- <http://googleresearch.blogspot.com/2010/04/lessons-learned-developing-practical.html>
- top 10: <http://gettinggeneticsdone.blogspot.com/2010/04/top-10-algorithms-in-data-mining.html>
- k-means/canopy clustering
- model selection criteria: akaike information criterion (AIC), minimum
description length (MDL), bayesian information criterion (BIC)
- common distributions: normal, beta binomial, multinomial
- $t$-test: matched pairs and unmatched
- mixture model for collab filtering
- principal component regression (PCR), partial least squares regression (PLS)
- GMMs
- navia
- Veritable
- cross-categorization: group cols as views, then group rows in each view
as categories
- monte core uses CRP
- nonparam models
- dirichlet process
- chinese restaurant process (CRP)
- conjugate models
- undirected models, Isings, clique potential
- Kullback-Leibler analysis
- http://www.youtube.com/user/sanjeev3007#p/u
- H-measure: fixes some shortcomings of AUC
- http://hunch.net/?p=273
- http://hunch.net/~jl/projects/hash_reps/index.html
- https://sites.google.com/site/icml2011sparsity/
- http://2010.ladisworkshop.org/node/10#keynote1
- PLSR
- self organizing maps
- structural equation modeling
- belief networks (90s; DAGs of hidden/visible), RBMs, stacked RBMs
into DBNs
- from quora:
> Compressed Sensing and Dictionary learning: These algorithms both exploit sparsely-activating (few ones in a zero-one vector) signals that appear in many real-world contexts Although sparsity-inducing algorithms have been around for a long time (in the form of "basis pursuit" and lasso" they've exploded recently, with many new advances (largely initiated by Donoho and Tao's proof of effectiveness). So far, these have touched MRI, radar and computer vision, and lead to an enormous amount of cross-talk between signal processing, statistics and machine learning. Watch for future advances.
>
> Advances in linear, structural and multi-kernel Support Vector Machines: SVMs were invented in the 90's and were a huge deal. In the 2000's they've been radically extended, becoming much faster (linear case), much more powerful (multi-kernel case) and much more flexible (structural case). These three extensions have also motivated a lot of research into connections between SVMs and other algorithms and original research in convex optimization methods.
>
> Latent Dirichlet Allocation: Made great use of an existing paradigm, graphical models, to allow for fast inference of human-interpretable (sort of) topic that make up a document collection. It really made people realize the power of graphical models, and has been endlessly extended.
>
> Deep Learning: Deep Belief Nets restarted interest in deep-learning methods, like neural nets. These have also been coming increasingly in contact with graphical models, like LDA above. People have also shown that they can achieve state-of-the-art results, which people doubted for a long time. Deep architectures are still slow and complex, but they can do a small handful of things that other methods simply can't, and their connections to real neural architecture are tantalizing.
>
> Huge strides in online learning: This is more than an algorithm, it's a whole setting. When you're being given data one point and one label at a time and you're not allowed to store much of it (which is common when dealing with huge data), you still want to be able to learn well from it. In the last decade, many people have successfully expanded connections to game theory (you want to minimize the "regret" of your strategy), found new optimization methods that make use of contextual and gradient information, and now are even expanding into the domain of "stochastic convex optimization", where you want to optimize over a convex function but you get one noisy piece of data at a time (the setting has existed a while, but theoretical research has been much stronger in the 2000's).Suggest Edits
wisdom
- data dredging aka data fishing aka data snooping: inappropriate use of data
mining to uncover misleading relationships in data
- can occur when no hyp formed in advance or reduced data reduces prob of
refuting some hyp
- when doing many significance tests, expect that some results are
significant by chance alone
- no free lunch theorem: many hyps can fit; always assuming *something*
- bias-free learning is futile
- for search/optimization: all algos perform the same on avg (over all
possible cost functions); improving perf requires prior info to match
procedures to problems
- for compression: "No compression algorithm can compress data on average."
- <http://www.aihorizon.com/essays/generalai/no_free_lunch_machine_learning.htm>
- curse of dimensionality: volume grows exponentially with dimensions, so
everything is far away
- to _whiten_ features is to center & rescale them by dividing by SD
learning taxonomies
- great resource:
<http://machine-learning.martinsewell.com/machine-learning.pdf>
- parametric v nonparametric
- parametric learning: models have params that we're estimating, eg Bayesian
learning; hyp complexity fixed
- once params learned, they're all you need to predict
- nonparametric learning: hyp complexity can grow with data
- instance-based aka memory-based learning: hyps directly constructed from
training instances, eg nearest-neighbor, kernels
- eg LWR: must keep training set around; "re-training" all the time
- nonparametric learning (2): infinite dimensional hyp (think of as function)
- rationale: flexibility, performance, more realistic
- TODO
- <http://learning.eng.cam.ac.uk/zoubin/talks/nips09npb.pdf>
data preparation
- attribute selection
- attribute discretization
- data transformation
- interactions (multiplications)
- data cleansing
- missing values, duplicates, noise, typos, systematic errors
- outliers, anomalies
semi-supervised
- EM (TODO: add some instances of EM)
- train on labeled data, then iteratively label unlabeled data
probabilistically (E-step) and re-train on examples weighted by their
probabilities (M-step)
- might work w any classifier & iterative clustering algo, but must ensure
feedback loop is positive; NB and EM are good pair (both assume conditional
independence given class)
- can choose to weigh unlabeled data lower than labeled data
- can assume mixture of multiple components for each class (instead of just
one cluster in each class): in E-step, also probabilistically assign to
components
- co-training
- relies on two separate views where they're
- complementary: $f(x) = f_1(x_1) = f_2(x_2)$
- conditionally indep given label
- pseudocode
LABELED = ...
UNLABELED = ...
UNLABELED' = sample u examples from UNLABELED
iterate:
H1 = train1(view1(LABELED))
H2 = train2(view2(LABELED))
let each H add p positive and n negative examples to LABELED
choose 2(p+n) from UNLABELED to replenish UNLABELED'
- use `UNLABELED'` bc forces H1/H2 to choose more representative examples of
underlying distribution (they try to choose the examples they're most
confident of)
- p,n should maintain ratio of underlying distribution
- H1 labels examples for H2, and vice-versa
- co-training incrementally labels; EM iteratively refines labels
- even when no natural split, artificial (even random) splits can work
(strive for independence)
- co-EM
- co-EM better than co-training better than EM
- better than co-training probably bc it doesn't commit to labels, but
weighs probabilistically
- steps
- train A on labeled data and probabilistically label unlabeled data
- train B on all data and probabilistically relabel
- iterate
- good text classif results with SVMs
expectation-maximization (EM)
- invented in statistics
- Gibbs sampling a kind of Bayesian or stochastic analogue of (frequentist) EM
- whereas EM computes likelihoods of missing values (in the E step) and
maximizes parameters (in the M step), Gibbs sampling treats missing values
and parameters as random variables that we sample from and whose full
distributions we want to know
- ie while EM does updates by (deterministically) computing
maximum-likelihood point estimates of parameters, Gibbs does updates by
sampling for the parameters instead.
- <http://blog.echen.me/2011/08/22/introduction-to-latent-dirichlet-allocation/>
- conn btwn gibbs sampling & LDA
data set balance
- class imbalance is common problem in many problems
- most common techniques
- random undersampling (RUS) of majority class
- shouldn't affect ROC curve
- don't undersample test set
- random oversampling (ROS) of minority class: duplicate samples
- synthetic minority over-sampling technique (SMOTE)
- "informed over-sampling": for each minority sample $s$:
- find $k$ nearest neighbors
- randomly select $j$ of them ($j$ depends on oversampling desired)
- randomly generate synthetic samples along the lines joining $s$ and the
$j$ neighbors
- shortcomings
- may overgeneralize bc it disregards majority class; esp problematic for
highly skewed class distributions bc minority class is very sparse wrt
majority class
- inflexibility: $j$ is fixed in advance
- adaptive synthetic minority oversampling (ASMO): overcomes shortcomings
- <http://www.iro.umontreal.ca/~lisa/workshop2004/slides/japkowicz_slides.ppt>
- may combine SMOTE and undersampling
- <http://metaoptimize.com/qa/questions/232/does-subsampling-bias-the-auc>
- <http://www.machinelearning.org/proceedings/icml2007/papers/62.pdf>
ensemble methods
- decision stumps aka weak learners: predict based on just one feature
- bootstrap aggregating aka bagging
- given a learner (model), trains $t$ classifiers (instances of the learner),
each on some bootstrap sample from the training data
- bootstrap sample: sample w replacement (replace each example)
- given a test example, classifiers take a vote (regressions take avg)
- averages predictions, so not useful for improving linear models
- error estimate: accuracy of the classifiers on their excluded sets
- boosting (adaboost): usu applied to decision trees
- given a learner, trains $t$ classifiers (instances of the learner) on
samples of the training data
- when a classifier is trained, weights for misclassified instances are
increased, so that next classifier must try harder to get those right
- classifiers also assigned a weight based on accuracy on training set
- given a test example, classifiers take a weighted vote
- rely on randomization/perturbation to build diverse models, so only unstable
learners can be used; not useful for stable learners like SVM, NB
- stable learners: produce similar models upon small perturbations to
training set
supervised learning
- classification: discrete/categorical
- regression: continuous
- ordinal regression: ranking (in btwn classification & regression; used in IR)
- old statistically inspired linear methods
- neural networks
- nodes aka units are connected by links propagating activations
- each node is activation function of weighted inputs
- activation functions: threshold or sigmoid/logistic (differentiable)
- bias weight $W_{0,i}$ connected to fixed input $a_0 = -1$, sets actual
threshold
- acyclic/feed-forward networks or cyclic/recurrent networks (memory)
- hidden units/layers: internal units/layers
- FF networks usu arranged in layers
- perceptron: single-layer FF using threshold function; linear
- multilayer backpropagates errors to hidden layers by assuming each hidden
node responsible for some fraction of the error in each of the output nodes
it connects to
- gradient descent for logistic regression *is* perceptron with sigmoid/logit
- decision trees
- pruning: remove irrelevant features; eg $\chi^2$ pruning (math)
- finding split points on continuous features is usu most expensive part
(math)
- ID3: standard simple learning algo
- choose attr w max info gain (or, equivalently, min entropy)
- C4.5: standard modern decision tree learner
- supports continuous attrs, missing values, diffing costs, pruning
irrelevant attrs
- support vector machines (SVM) aka kernel machine
- maximum margin classifiers, potentially with slack
- linear: similar to logistic regression
- Gaussian processes: TODO
- $k$-nearest-neighbors (KNN): classify objects based on closest $k$ neighbors
- case-based reasoning
- knowledge-based ai
- statistical ml
- anytime learning: online continuous learning
- margin infused relaxation algo (MIRA): TODO
- <http://aria42.com/blog/?p=216>
coordinate descent
- no derivative needed; simply pick a direction and move along it
gradient descent
- better alternatives: conjugate gradient, BFGS, L-BFGS (limited-memory BFGS)
graph search
- BFS, DFS, IDFS
- best-first search: explore most promising node according to heuristic fn
- usu.: minimize distance to goal
- A* search: best-first where heuristic fn is distance to goal + distance from
start
- unlike best-first min-dist, may jump off a certain path you've been heading
down to keep from going too far off
- beam search: best-first but at ecah step keep limited # of best candidates
- dijkstra: exact min cost path
- orig algo $O(|V|^2)$; using Fib heap $O(|E| + |V| \log |V|)$
- for each node, maintain a "min known distance from root"
- starting from root, relax neighbors' distances & put into/pop from PQ
- once all neighbors of a node explored, dist won't relax again
- neg edge weights cause inf loops
- pseudocode:
for x in nodes:
x.dist = inf
x.prev = null
root.dist = 0
q = PQ({root})
while x = q.pop():
for y in x.neighbors:
m = min(y.dist, x.dist + edge(x,y))
if m < y.dist:
y.dist = m
y.prev = x // record path
insert or relax y in q
- bellman-ford: single-source shortest-paths all-pairs
- same as dijkstra but instead of greedily relaxing min-dist unvisited node,
relax *all* edges, and can report neg edges (no 'shortest path')
for v in vs: v.dist, v.pred = inf, null
for i in range(len(vs)):
for u,v in es:
if u.dist + edge(u,v) < v.dist:
v.dist = u.dist + edge(u,v)
v.pred = u
for u,v in es:
if u.dist + edge(u,v) < v.dist:
raise Exception('graph contains neg weight edges')
constraint satisfaction
- unification
- backtracking
local search/optimization algos
- hill climbing: each step adjusts a single element in the vector; various ways
to choose successor
- simulated annealing: adjusts all elements in the vector according to gradient
of the hill
- local beam search: hill-climbing in lock-step; share info so that each
exploring thread jumps to one of the best successors found by any of the
other threads
- stochastic beam search: local +
- minimax
- nearest neighbors
- knn: see above
- cuckoo hashing
- genetic algos
instance-based aka memory-based learning
- eg nearest-neighbor, kernels
- attribute weighting: randomly sample instances and check neighbors
- near hits w diff attr val decreases attr relevance
- near misses w diff attr val boosts attr relevance
nearest-neighbor
- density estimation: defines joint dists over input space
- unlike Bayes net, no hidden vars/unsupervised clustering
- distance functions
- continuous features: don't just use Euclidian; normalize by standard
deviation ($Z$-distance)
- special case of Mahalanobis distance, which uses covariance as well
- discrete features: Hamming distance
- can predict some attr $y$ with $P(y|x) = P(y,x) / P(x)$
- supervised learning: predict $y=h(x)$ from $k$ nearest neighbors of $x$
- for discrete: majority vote
- for continuous: average, or do local linear regression using the $k$ points
- high-dimensional problems
- slow kNN search
- curse of dimensionality on distance functions
clustering
- difference from partitioning: clustering is on points that have coordinates
or distances, rather than shapeless graphs
- hierarchical
- agglomerative: bottom-up merging
- divisive: top-down splitting
- partitional: determine all clusters at once; can be used in divisive
- $k$-means: assign each point to cluster with closest centroid; initialize with random centroids
- can use results to determine _clustroids_ (points closest to centroids)
- self-organizing maps (SOM) aka self-organizing feature map (SOFM)
- locality sensitive hashing (LSH): hash similar values to similar values
- a form of dimensionality reduction
- also used in nearest neighbor search
- feature space vectors are sets
- jaccard distance
- random projection:
- each value is a vector in hyperspace
- divide hyperspace with a hyperplane to classify the values in 1 bit
- repeat for more bits
- min-hash, sim-hash are instances of this
- min-hash: <http://knol.google.com/k/simple-simhashing>
- sim-hash
pick hash size, eg 32 bits
let V = [0] * hash size
break up token sequence into features (eg n-char shingles)
hash each feature
for each hash
if bit i is set, V[i]++
if bit i is not set, V[i]--
simhash bit i is set iff V[i] > 0
- <http://matpalm.com/resemblance/simhash/>
- <http://www.cs.princeton.edu/courses/archive/spr04/cos598B/bib/CharikarEstim.pdf>
- density-based: discover arbitrary shapes
- 2-way-/co-/bi-clustering: objects are clustered but also their features; if
data in matrix, then rows and columns clustered simultaneously
- distance measures: euclidian/2-norm, manhattan/1-norm, maximum norm aka
infinity norm, hamming, inner product/cosine similarity
- many clustering algos require number of clusters as input;
mean shift
- "non-param" in that # modes gives # clusters, but still need kernel fn (eg
bandwidth $h$)
- given data points in $k$-dim space, there's a KDE PDF; find its modes
- algo: given kernel fn & data pts, do for each data pt:
- start w window centered at data pt
- until convergence, find kernel-weighted mean over data pts in window (eg
hypersphere, an approximation of where kernel is non-zero) and update
window center
- clustering: assign data pt to the basin it falls into
- theory: this actually is just ascent of gradient of KDE
- used in CV: segmentation, tracking
- tracking: create confidence map in new img based on color histogram of obj
in prev img; use mean shift to find peaks of confidence map
- segmentation: use _discontinuity preserving smoothing_
- combine spatial and range (color) values into $x = [ x_s x_r ]$ (5-dim)
- use special $K(x) = c K(x_s / h_s) K(x_r / h_r)$
- filtered pixel uses orig spatial vector but new range vector of
convergence pt
- slow; some optimizations:
- sampling: sample KDE to get pts for new ("reduced") KDE, and run over these
pts, then simply associate each pt to closest
- adaptive mean shift: vary bandwidth for ea pt: let $h$ be dist to nearest
neighbor (that's L1 norm, can also use L2)
- actually move each data pt at each iteration
v-measure cluster evaluation measure
- "conditional entropy-based external cluster evaluation measure"
- harmonic mean of homogoneity score & completeness score (optionally weighing
each differently)
- other commonly used scores: purity, entropy, F-measure-like "clustering
accuracy", more...
- http://acl.ldc.upenn.edu/D/D07/D07-1043.pdf
machine learning
- linear classif, perceptron, SVM
- non-linear classif, kernels
- n-way classif, rating, ranking
- anomaly detection
- (logistic) regression
- collab filt
- feat sel
- ensembles, boosting
- active learning
- model sel, complexity
- VC-dim, generalization guarantees
- mixture models, EM
- topic models, markov models, HMMs
- bayesian nets (and learning them)
- random fields, conditional random fields, markov random fields, factor graphs, inference
- inference, belief propagation
- inference, junction trees
- conditional models, structured prediction
- structured prediction: similar to classification but predicting an output
with many possible values but still tractable to learn, e.g. structures;
eg POS tags for a string of words
- learning conditional models
Developing a self-driving car for the 2007 DARPA Urban Challenge (Seth Teller's
Angstrom talk, 5/1/08)
- 40 compute cores
- many other teams performed human-assisted map annotation
- Seth's team focused on going almost entirely from sensing
- many other teams used much fewer cores
- uses of sensing
- using vision for finding paint
- using active sensing for depth
- stereo algos: reconstruct 3D from cameras
- recent stereo algos have a global component that is harder to parallelize
- optical flow: estimating motion across time
- groups
- planning & control: how to stay on the white dotted lines; one technical
focus
- perception: another technical focus
- working on the car
- software infrastructure: codebase, OS, etc.
- power-bound
- also CPU-bound in the sense that they could process rawer images, at higher
rates, etc.
- also IO-bound; had 2 GigE and a CAN, all mostly utilized
- Anant: near future will yield cameras that have encoders
- Seth: these are not as useful for vision research
- algos need to know gradients, for instance; what does MPEG do to gradients?
- looked at GPUs
- programming models still painful
- form factor limits (1U blades)
- didn't want DSPs either because they didn't know what algos they ultimately
wanted; everything was exploratory
- Anant: suggest fifth team, on computation resources
MACHINE LEARNING
- variables
- visibility
- _hidden variables_, _latent variables_, _model parameters_, _hypothetical variables_
- _observable variables_, _manifest variables_
- causality
- _independent variable_, _predictor variable_, _regressor_, _controlled variable_, _manipulated variable_, _explanatory variable_
- _dependent variable_, _response variable_, _regressand_, _measured variable_, _responding variable_, _explained variable_, _outcome variable_
- TODO any diff btwn visibility/causality?
- bayes vs frequentist
- TODO diff btwn | and ;?
- models
- data mining
- analyses
- mathematical
- real analysis
- complex analysis
- statistical
- analysis of variance (ANOVA)
- time-series analysis
- latent variable model
- factor analysis
- latent trait analysis
- latent profile analysis
- latent class analysis
- PCA
- exploratory data analysis
feature/dimensionality reduction
- feature selection
- feature extraction
- principal component analysis (PCA)
- autoencoder aka sparse coding
missing values
- usu. non-random; missing bc of other attr (or class label)
- model-specific treatment
- discriminative, eg log reg, can't handle unknowns, need generic treatment
- generative can marginalize over unknowns
- other models, eg trees, can handle: eg treat missing as separate value, or
split instance into new instances (with value filled in) weighted by
frequencies of filled-in value
- <http://www.slideshare.net/pierluca.lanzi/machine-learning-and-data-mining-11-decision-trees>
- generic treatments
- discard examples with missing values; should only do this if don't expect
them to come up again (in test set)
- treat as special value; new discrete value or new indicator for continuous
- reduced-feature models: build models excluding missing features
- _imputation_: fill in missing values
- avg/maj are most common, but generally can use any learner to predict
value
- distribution-based imputation: use the tree splitting technique described
above to impute
- EM: build model (ignoring missing), estimate missing, repeat till
convergence
- resources
- <http://www.cs.toronto.edu/~marlin/research/phd_thesis/marlin-phd-thesis.pdf>
- <http://www.stat.ucla.edu/~yuille/courses/Stat153/Stat_153.htm>
- <http://jmlr.csail.mit.edu/papers/volume8/saar-tsechansky07a/saar-tsechansky07a.pdf>
principal component analysis (PCA)
- use covariance method or SVD (preferred)
- "eval decomp of data covariance matrix" method: rarely used bc inefficient
- `row_data_adjusted = row_data - mean(row_data)` (normalized to have unit
variance?)
- find eig of compute covariance (correlation) matrix
- choose eigenvectors that have biggest eigenvalues; these are the
(principal) components
- _feature vector_ is matrix of col evecs $[e_1, e_2, \dots, e_n]
- `transformed_data = trans(feature_vector) * row_data_adjusted`
- "SVD of mean-centered data matrix" method: faster
- components optimally account for variance in features
- first component extracted accounts for max amt of total variance
- i.e., choose new axis covering greatest "spread" in data points
- i.e., choose new axis minimizing L2 errors
- typically means it will be correlated w several/many vars
- second component extracted accounts for max amt of variance not
accounted for by first component
- results depend on scaling of variables
- eval directly corresponds to fraction of total variance
- eg if total variance of 10, eval of 6.1 means 61% of total variance
- can extract _orthogonal_ components or _oblique_ components (which may
produce cleaner results but also may be more complicated to interpret)
- *not* factor analysis; makes no assumptions about underlying causal model or
latent vars; simply reduce to components that account for most of the variance
- but may sometimes produce similar results
- optimal orthogonal xform but more computationally expensive than eg DCT
- refs
- <http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf>
- <http://support.sas.com/publishing/pubcat/chaps/55129.pdf>
factor analysis
- for when you believe latent factors cause observations
linear discriminant analysis
- alt to PCA that optimizes for class separability
- TODO
- TODO canonical correlation analysis (CCA)
- <http://www.cs.huji.ac.il/~shashua/papers/class8-PCA-LDA.pdf>
- despite name, it's generative; name makes sense vs PCA (which ignores labels)
independent components analysis (ICA)
- PCA: finds orthogonal basis; suited for normal processes
- ICA: suited for strongly non-normal processes
- <http://www.stanford.edu/class/cs229/notes/cs229-notes11.pdf>
eigenfaces
- faces = 100x100 images = 10,000D vectors
- PCA on faces: keep principal eigenvectors ("eigenfaces")
- use PCA trick
PCA transpose trick
- rank of covar matrix is limited by # training examples: if there are $N$
examples, then there are at most $N-1$ evecs with non-0 evals
- if dimensionality much larger than $N$, then transpose the observation matrix
- <http://blog.echen.me/2011/03/14/pca-transpose-trick/>
locally linear embedding
- non-linear dimensionality reduction technique TODO
trending algorithms
- simple baseline trend algorithm: daily trend = most recent day's change *
log(monthly total)
- <http://stackoverflow.com/questions/1635703/understanding-algorithms-for-measuring-trends>
decision tree learning algorithms
- high variance
- unsupervised clustering: put your data all in one class and synthesize a
second class that is uniformly distributed throughout the same space
- RF will then try to distinguish the second class by finding the dense
clusters
- <http://www.genetics.ucla.edu/labs/horvath/RFclustering/RFclustering.htm>
- GINI: TODO
- regression trees can fit any model, but if tree built well then constant
should do well
- usu. use MSE instead of mutual information (pick attr to split where
partitions have minimal variance, as opposed to greatest information gain)
- <http://www.stat.cmu.edu/~cshalizi/350-2006/lecture-10.pdf>
- ID3
- C4.5
- M5
- M5P
- at leaves, train linear regressors
- <http://www.opentox.org/dev/documentation/components/m5p>
advice for applying ML (CS229)
- always evaluate a model on holdout
- model selection: use *three* datasets
- train params on training set
- choose hyperparams that minimize CV set
- evaluate on test set, since evaluating on CV set is more optimistic, since
hyperparams were chosen to minimize CV error
- use error, which is loss without the regularization
- TODO: include plots of error vs model complexity
- training error monotonically decreases
- CV error is convex above this; want to find the min point
- where they converge and error is high: bias (underfitting)
- where they diverge: variance (overfitting)
- similar for plot of error vs regularization $\lambda$ but flipped
horizontally
- TODO: include example learning curves, plots of error over training set size
- train error increases, CV error decreases
- high bias: curves converge; more data won't help
- high variance: curves remain far apart; more data should help
- strategies
- high variance
- more training data
- fewer features
- larger $\lambda$
- high bias
- more features
- more complexity (more NN nodes, more polynomial degrees, etc.)
- smaller $\lambda$
generalization guarantees
- bias: underfitting
- variance: overfitting
- Vapnik-Chervonenkis (VC) dimension
- model _shatters_ some data if for all labelings there's some perfect params
(no errs)
- VC dim of model is size of largest set that model can shatter
- eg linear classifiers: VC-dim of 3
- can predict probabilistic upper bound on test err of classification model
TODO
comparing classifiers
- not sure how trustworthy the following is, but mostly accurate
- high-bias/low-var (eg NB) better for small training sets
- low-bias/high-var (eg kNN, LR) better for bigger training sets
- NB: simple; fast; converges faster than discriminative model like LR; good
for small datasets
- LR: many ways to regularize, so less worry about correlated features; nice
prob interp useful for adjusting thresholds or getting confidence scores;
easily update model w online grad desc, unlike SVMs/DTs
- DT: easy to explain; non-param; RFs avoid overfitting; RFs beat SVMs
- SVM: accurate; slow; too many kernels/params
- <http://www.quora.com/What-are-the-advantages-of-different-classification-algorithms>
generalization error
- cross validation, bootstrapping: methods to estimate generalization error;
based on "resampling"
- often used to choose among different models; e.g. different neural network
architectures; choose one with lowest gen error
- cross validation
- *doesn't* estimate error on future data
- rather, a way to pick best learning algo (and best learning params that
aren't already being numerically optimized)
- $k$-fold cross validation: divide data into $k$ subsets of roughly same
size (folds)
- train $k$ times, each time leaving out one of the subsets, then testing on
one subset
- LOOCV: when $k$ is the sample size ($k=n$ where $n$ is data size)
- leave $v$ out cross validation: more elaborate and expensive that leaves out
all possible subsets
- diff from "split-sample"/"hold-out" method commonly used for early stopping
in neural networks
- only 1 fixed subset (the validation set) used to estimate generalization
error, not $k$ subsets; no "crossing"
- cross-validation to split-sample is superior for small datasets
- LOOCV good for continuous error functions/model-selection methods, bad for
discontinuous ones
- repeated random sub-sampling validation (this may be referred to as
bootstrapping)
- split multiple times randomly; avg over splits
- split multiple times randomly; avg over splits
- stratification
- repeated random sub-sampling validation
- maintain same mean response value is equal in training and test sets
TODO understand that sentence
- useful if responses are dichotomous, where data has unbalanced repr of
the two response values
- stratified $k$-fold CV
- choose folds so that mean response value is approx equal in all folds
TODO understand that sentence
- for dichotomous classification, each fold has ~same +/- labels
- jackknifing: LOOCV but for estimating bias & variance, not gen error
- compute some statistic of interest in each subset
- compare avg of these to avg of entire sample to estimate the latter's bias
- bootstrapping
- repeatedly analyze subsamples of the data rather than subsets
- ea subsample is a random sample with replacement from full sample
- subsamples may be of same cardinality as full sample
- allows us to evaluate estimators
- example from classical statistics: what's the variance of the mean? what
are our confidence intervals?
- example from machine learning: for a decision tree algo, evaluate mean &
variance of (# correct)/(# elements)
- TODO clarify relationship w CV
- seems CV is better for ML tasks, since test set != train set
- bootstrapping works better than CV in many cases?
<http://www.faqs.org/faqs/ai-faq/neural-nets/part3/section-12.html>
- ref: <http://www.faqs.org/faqs/ai-faq/neural-nets/part3/section-12.html>
ML vs statistics
- <http://www-stat.stanford.edu/~jhf/ftp/dm-stat.pdf>
- statistics too focused on math technique rather than ideas
- empirical validation and mathematics are complementary
- stats: prob theory, real analysis, measure theory, asymptotics, decision
theory, markov chains, martingales, ergotic theory
- tools: hyp testing, experimental design, response surface modeling,
ANOVA/MANOVA, linear regression, discriminant analysis, logistic
regression, GLM, canonical correlation, principal components, factor
analysis
- DM
- tools: decision trees, rule induction, nearest neighbors, clustering,
association rules, feature selection, neural nets, graphical models,
genetic algos, self-organizing maps, neuro-fuzzy systems
- <http://brenocon.com/blog/2008/12/statistics-vs-machine-learning-fight/>
computational learning theory
- probably approximately correct (PAC)
- VC theory
- bayesian inference
- algorithmic learning theory
- online machine learning
dumb learners
- majority learner aka ZeroR
- OneR aka stump: generate one rule per predictor, then use only the rule w
smallest error
receiver operating characteristic (ROC)
- based on confusion matrix aka contingency table
- true positive rate aka TPR aka sensitivity: TP/P or TP/(TP+FP)
- false positive rate aka FPR aka 1 - specificity: FP/N or FP/(TN+FN)
- ROC curve: plot of FPR on x and TPR on y while varying threshold
- input: true labels and scores from classifier
- top left is perfect; random tends to be around FPR=TPR diagonal
- python to generate a ROC curve
# say sorted(zip(scores, labels), reverse=True) returns:
# [(.9, 1), (.8, 1), (.6, 0), (.4, 1), (.2, 0), (.1, 0)]
pos, neg = labels.count(1), labels.count(0)
# simple implementation: doesn't sort data first
thresholds = sorted(set(scores), reverse=True)
for i, t in enumerate(thresholds):
# num examples with predict=1 and label=1
tp = sum(label for score, label in zip(scores, labels)
if score >= t and label == 1)
# num examples with predict=1 and label=0
fp = sum(label for score, label in zip(scores, labels)
if score >= t and label == 0)
yield tp/pos, fp/neg
# more efficient implementation sorts data first and accumulates data
tp, fp = 0
# this descends the threshold to each distinct value of score
for score, label in sorted(zip(scores, labels), reverse=True):
if label: tp += 1
else: fp += 1
yield tp/pos, fp/neg
- area under curve (AUC) metric
- random classifier: AUC = .5
- perfect classifier: AUC = 1
- different apps have different prefs
- spam filtering: want low FP
- medical screening tests: want high TP
- AUC has implicit cost functions; diff cost distributions for diff classifiers
- don't use AUC to compare diff classifiers
- <http://www.springerlink.com/content/y35743hp7010g354/>
- <http://metaoptimize.com/qa/questions/4370/how-to-generate-a-roc-curve-for-binary-classification>
- <http://metaoptimize.com/qa/questions/232/does-subsampling-bias-the-auc>
loss functions
- 0-1 loss
- pairwise cross entropy
- lambda loss
- pairwise + RMSE
adaboost
- idea: combine weak classifiers
initially, all examples equally weighted
for some number of rounds,
find a weak classifier that minimizes weighted error
if weighted error >=50% accuracy, break
down-weight correct examples, up-weight incorrect examples
combine subordinate models into final model,
each weighted inversely by training error
learning bayes net structures
- still active research
- search algo: modifying an initial structure (nodes, arcs)
- some assume partial topological order over vars is given
- criteria
- accuracy after fitting params
- if implicit conditional independence assertions are satisfied
- MLE results in fully connected network; must penalize with bayesian
(MAP/MDL) approach over network hyps (prefer simpler networks)
- usu too many structures to sum over, so sample w MCMC
posterior simulation (TODO)
- objective: evaluate integrals over density $p(x)$
- eg estimate expected value
- direct sampling methods
- generally given an un-normalized density $p*(x) = c p(x)$
- uniform: grid search; $$ prohibitively many samples req'd for high dims
- importance: uniform w sampler density $q(x)$
- $q$ should be simple enough to be sampled
- hope that $q*$ is reasonable approx to $p*$
- adjust est by weighting "importance" of each sample
- hard to choose good $q$, esp in high dims
- rejection: like importance but proposal density strictly bounds target
density: $c q*(x) > p*(x)$
- sample $x$ from $q*(x)$,
- $c$ often too big for poor choice of $q$ or high dims
- MCMC
- BUGS, JAGS, etc use M-H not Gibbs; by Gibbs they mean one-var-at-a-time
- <http://stats.stackexchange.com/questions/4191/gibbs-sampling-where-do-the-full-conditionals-come-from>
- metropolis-hastings
- use local density $q(x'; x^{(t)})$, dep on current state $x^{(t)}$
- build markov chain through state space, converging to target density
$P*(x)$
- $Q$ doesn't need to closely approx $P$
- at time $t$, generate tentative state $x'$ from $Q$
- eval $a = \dots$
- gibbs
- inappropriate if any deterministic nodes (transition prob 1) or
non-ergodic (disconnected components)
- one pseudocode (for discrete dists, from <http://dclib.hg.sourceforge.net/hgweb/dclib/dclib/file/474a3c84a175/dlib/bayes_utils/bayes_utils.h>)
iterate
for node in nodes
if node is evidence, skip
compute dist P(node | neighbors) = normalize(
for value in node.values
P(node=value | node.parents) *
prod(P(child | child.parents (incl node=value))
for child in node.children)
)
node.currvalue = sample from dist
- refs
- <http://jakehofman.com/talks/nyc_rmeetup_20090709_jmh.pdf>
- gelman. bayesian data analysis.
sampling
- fwd sampling
- for bayesian networks
- topological order
- queries w evidence: est $P(Y = y \mid E = e)$
- rejection sampling: fwd sampling, discard where $E \ne e$
- $P(E = e)$ usu prohibitively small; too many samples required
- fwd sampling generally infeasible for markov networks; no "roots"
- markov chain: probabilistic state machine
- TODO
markov chain monte carlo (MCMC)
- award-winning expository paper: <http://www.ams.org/journals/bull/2009-46-02/S0273-0979-08-01238-X/S0273-0979-08-01238-X.pdf>
- variational bayes TODO
- deterministic
graphical models
- bayesian network aka belief network aka directed graphical model
- local markov prop: any 2 nodes conditionally indep given parents' values
- edges usu repr causality but not required (either dir)
- plates: for repeating sub vars
- eg naive bayes, neural nets
- _markov blanket_: neighbors; parents, children, children's parents
- every node is conditionally indep of all other nodes in network given
blanket
- dynamic bayesian network: for sequences of vars, eg time series
- eg HMMs, kalman filter
- markov network aka markov random fields aka undirected graphical model
- reprs some things bayes nets can't (cyclic deps) & vice versa (induced deps)
- eg log-linear models, gaussian markov random field TODO
- must satisfy pairwise, local, global markov props TODO
- conditional random fields TODO
- factor graph
- bipartite hypergraph representing factorization of a function TODO
- <http://cacm.acm.org/magazines/2010/12/102122-bayesian-networks/fulltext>
linear classifiers
- naive bayes
- generative
- it's actually linear: <http://nlp.stanford.edu/IR-book/html/htmledition/linear-versus-nonlinear-classifiers-1.html>
- choose $c_0$ iff $\log \frac{P(c_0|d)}{P(c_1|d)} = \log
\frac{P(c_0)}{P(c_1)} + \sum_{k=K} \log \frac{P(t_k|c_0)}{P(t_k|c_1)} >
0$ where $K$ is the set of terms in the document
- logistic regression
- discriminative
- for $K$ classes, $P(y|x) = \frac{ \exp(w_y \cdot x) }{
\sum_{y'\in\{1,\dots,K\}} \exp(w_{y'} \cdot x) }$
- <http://www.quora.com/What-is-the-difference-between-logistic-regression-and-Naive-Bayes>
generative vs discriminative
- discriminative: LR, perceptron, SVM
- good generalization when much data
- generative: LDA, NB
- more interest in semisupervised learning bc harder to get labels
- can train discriminatively, but no longer make use of unlabeled data
- <http://research.microsoft.com/en-us/um/people/minka/papers/LasserreBishopMinka06.pdf>
GLM
- families
- Bernoulli and binomial: logistic regression
- Gaussian: OLS regression
- multinomial: softmax regression
- Poisson: for modelling count-data
- gamma and exponential: for modelling continuous, non-neg RVs, eg time
intervals
- beta and Dirichlet: for dists over probs
- many more...
- residual deviance, null deviance TODO
maximum entropy
- _max entropy classifier_ aka _multinomial logit_
- generalizes logistic regression