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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
WEBVTT Kind: captions; Language: en-US

NOTE
Created on 2024-02-07T20:52:10.2470009Z by ClassTranscribe

00:01:22.340 --> 00:01:22.750
Good morning.

00:01:24.260 --> 00:01:27.280
Alright, so I'm going to just first

00:01:27.280 --> 00:01:29.738
finish up what I was, what I was going

00:01:29.738 --> 00:01:31.660
to cover at the end of the last lecture

00:01:31.660 --> 00:01:32.980
about Cannon.

00:01:33.640 --> 00:01:36.550
And then I'll talk about probabilities

00:01:36.550 --> 00:01:37.540
and Naive Bayes.

00:01:38.260 --> 00:01:39.940
And so I wanted to give an example of

00:01:39.940 --> 00:01:41.930
how K&N is used in practice.

00:01:42.530 --> 00:01:44.880
Here's one example of using it for face

00:01:44.880 --> 00:01:45.920
recognition.

00:01:46.750 --> 00:01:48.480
A lot of times when it's used in

00:01:48.480 --> 00:01:50.030
practice, there's a lot of feature

00:01:50.030 --> 00:01:51.780
learning that goes on ahead of the

00:01:51.780 --> 00:01:52.588
nearest neighbor.

00:01:52.588 --> 00:01:54.510
So nearest neighbor itself is really

00:01:54.510 --> 00:01:55.125
simple.

00:01:55.125 --> 00:01:58.530
It's efficacy depends on learning good

00:01:58.530 --> 00:02:00.039
representation so that.

00:02:00.800 --> 00:02:02.640
Data points that are near each other

00:02:02.640 --> 00:02:04.410
actually have similar labels.

00:02:05.450 --> 00:02:07.385
Here's one example.

00:02:07.385 --> 00:02:10.550
They want to try to be able to

00:02:10.550 --> 00:02:12.330
recognize whether two faces are the

00:02:12.330 --> 00:02:13.070
same person.

00:02:13.820 --> 00:02:16.460
And so the method is that you Detect

00:02:16.460 --> 00:02:18.940
facial features and then use those

00:02:18.940 --> 00:02:21.630
feature detections to align the image

00:02:21.630 --> 00:02:23.300
so that the face looks more frontal.

00:02:24.060 --> 00:02:26.480
Then they use a CNN convolutional

00:02:26.480 --> 00:02:29.240
neural network to train Features that

00:02:29.240 --> 00:02:32.600
will be good for recognizing faces.

00:02:32.600 --> 00:02:34.360
And the way they did that is that they

00:02:34.360 --> 00:02:37.950
first collected hundreds of Faces from

00:02:37.950 --> 00:02:40.300
a few thousand different people.

00:02:40.300 --> 00:02:41.680
I think it was their employees of

00:02:41.680 --> 00:02:42.250
Facebook.

00:02:43.030 --> 00:02:46.420
And they trained a classifier to say

00:02:46.420 --> 00:02:48.970
which, given a face, which of these

00:02:48.970 --> 00:02:50.960
people does the face belong to.

00:02:52.030 --> 00:02:54.340
And from that, they learn a

00:02:54.340 --> 00:02:55.210
REPRESENTATION.

00:02:55.210 --> 00:02:57.030
Those classifiers aren't very useful,

00:02:57.030 --> 00:02:59.300
because nobody's interested in seeing

00:02:59.300 --> 00:03:00.230
given a face.

00:03:00.230 --> 00:03:01.843
Which of the Facebook employees is that

00:03:01.843 --> 00:03:02.914
they want to know?

00:03:02.914 --> 00:03:04.932
Like, is it you want to know?

00:03:04.932 --> 00:03:07.460
Like, organize your photo album or see

00:03:07.460 --> 00:03:08.800
whether you've been tagged in another

00:03:08.800 --> 00:03:09.960
photo or something like that?

00:03:10.630 --> 00:03:12.050
And so then they throw out the

00:03:12.050 --> 00:03:13.980
Classifier and they just use the

00:03:13.980 --> 00:03:16.280
feature representation that was learned

00:03:16.280 --> 00:03:21.070
and use nearest neighbor to identify a

00:03:21.070 --> 00:03:22.510
person that's been detected in a

00:03:22.510 --> 00:03:23.090
photograph.

00:03:24.830 --> 00:03:26.540
So in their paper, they showed that

00:03:26.540 --> 00:03:28.565
this performs similarly to humans in

00:03:28.565 --> 00:03:30.470
this data set called label faces in the

00:03:30.470 --> 00:03:31.970
wild where you're trying to recognize

00:03:31.970 --> 00:03:32.560
celebrities.

00:03:34.140 --> 00:03:35.770
But it can be used for many things.

00:03:35.770 --> 00:03:37.516
So you can organize photo albums, you

00:03:37.516 --> 00:03:40.360
can detect faces and then you try to

00:03:40.360 --> 00:03:41.970
match Faces across the photos.

00:03:41.970 --> 00:03:44.175
So then you can organize like which

00:03:44.175 --> 00:03:46.320
photos have a particular person.

00:03:47.070 --> 00:03:49.950
Again, you can't identify celebrities

00:03:49.950 --> 00:03:51.860
or famous people by building up a

00:03:51.860 --> 00:03:54.919
database of faces of famous people.

00:03:55.870 --> 00:03:58.110
And you can also alert, alert somebody

00:03:58.110 --> 00:04:00.100
if somebody else uploads a photo of

00:04:00.100 --> 00:04:00.330
them.

00:04:00.330 --> 00:04:02.922
So you can see if somebody uploads a

00:04:02.922 --> 00:04:05.364
photo, then you can detect faces, you

00:04:05.364 --> 00:04:07.830
can see what their friends network is,

00:04:07.830 --> 00:04:10.056
see what other which of their faces

00:04:10.056 --> 00:04:12.220
have been uploaded and then Detect the

00:04:12.220 --> 00:04:14.330
other users whose faces have been

00:04:14.330 --> 00:04:16.580
uploaded and ask them for permission to

00:04:16.580 --> 00:04:17.930
like make this photo public.

00:04:19.750 --> 00:04:22.020
So this algorithm is actually used by

00:04:22.020 --> 00:04:22.560
Facebook.

00:04:22.560 --> 00:04:24.340
It has been for several years.

00:04:24.340 --> 00:04:28.640
They're limiting some of its use more

00:04:28.640 --> 00:04:30.544
recently, but they've been.

00:04:30.544 --> 00:04:32.010
But it's been used really heavily.

00:04:32.680 --> 00:04:34.410
And of course they have expanded

00:04:34.410 --> 00:04:36.365
training data because whenever anybody

00:04:36.365 --> 00:04:37.940
uploads photos then they can

00:04:37.940 --> 00:04:40.353
automatically detect them and add them

00:04:40.353 --> 00:04:42.360
to the database.

00:04:42.360 --> 00:04:45.150
So here the use of KN is important

00:04:45.150 --> 00:04:47.220
because KNN doesn't require any

00:04:47.220 --> 00:04:47.490
training.

00:04:47.490 --> 00:04:49.295
So every time somebody uploads a new

00:04:49.295 --> 00:04:50.930
face you can update the model just by

00:04:50.930 --> 00:04:54.430
adding this four 4096 dimensional

00:04:54.430 --> 00:04:56.646
feature vector that corresponds to the

00:04:56.646 --> 00:05:00.230
face and then use it in like based on

00:05:00.230 --> 00:05:02.550
the friend networks to.

00:05:02.910 --> 00:05:04.840
To recognize faces that are associated

00:05:04.840 --> 00:05:05.410
with somebody.

00:05:07.530 --> 00:05:11.270
I won't take time to discuss it now,

00:05:11.270 --> 00:05:13.473
but it's worth thinking about some of

00:05:13.473 --> 00:05:15.710
the consequences of the way that the

00:05:15.710 --> 00:05:17.888
algorithm was trained and the way that

00:05:17.888 --> 00:05:18.620
it's deployed.

00:05:18.620 --> 00:05:19.600
So for example.

00:05:20.510 --> 00:05:22.680
If you think about that, it was that

00:05:22.680 --> 00:05:24.650
the initial Features were learned on

00:05:24.650 --> 00:05:26.030
Facebook employees.

00:05:26.030 --> 00:05:27.440
That's not a very.

00:05:28.070 --> 00:05:29.630
That's not very representative

00:05:29.630 --> 00:05:32.120
demographic of the US the employees

00:05:32.120 --> 00:05:35.000
tend to be younger and.

00:05:35.490 --> 00:05:38.446
Probably skew towards male might skew

00:05:38.446 --> 00:05:40.210
towards certain ethnicities.

00:05:40.820 --> 00:05:43.210
And so the Algorithm may be much better

00:05:43.210 --> 00:05:45.030
at recognizing some kinds of Faces than

00:05:45.030 --> 00:05:46.016
other faces.

00:05:46.016 --> 00:05:47.628
And then, of course, there's lots and

00:05:47.628 --> 00:05:49.495
lots of ethical issues that surround

00:05:49.495 --> 00:05:51.830
the use of face recognition and its

00:05:51.830 --> 00:05:52.610
applications.

00:05:53.930 --> 00:05:55.550
Of course, like in many ways, this is

00:05:55.550 --> 00:05:58.150
used to help people maintain privacy.

00:05:58.150 --> 00:06:00.080
But even the use of recognition at all

00:06:00.080 --> 00:06:03.120
raises privacy concerns, and that's why

00:06:03.120 --> 00:06:04.860
they've limited the use to some extent.

00:06:06.470 --> 00:06:08.060
So just something to think about.

00:06:09.980 --> 00:06:13.430
So just to recap kann, the key

00:06:13.430 --> 00:06:16.480
assumptions of K&N are that K nearest

00:06:16.480 --> 00:06:18.260
neighbors that Samples with similar

00:06:18.260 --> 00:06:19.730
features will have similar output

00:06:19.730 --> 00:06:20.695
predictions.

00:06:20.695 --> 00:06:23.290
And for most of the Distance measures

00:06:23.290 --> 00:06:25.590
you implicitly assumes that all the

00:06:25.590 --> 00:06:27.200
dimensions are equally important.

00:06:27.200 --> 00:06:29.820
So it requires some kind of scaling or

00:06:29.820 --> 00:06:31.500
learning to be really effective.

00:06:33.540 --> 00:06:35.620
The parameters are just the data

00:06:35.620 --> 00:06:36.080
itself.

00:06:36.080 --> 00:06:37.870
You don't really have to learn any kind

00:06:37.870 --> 00:06:40.526
of statistics of the data.

00:06:40.526 --> 00:06:42.270
The data are the parameters.

00:06:43.820 --> 00:06:46.160
The designs are mainly the choice of K

00:06:46.160 --> 00:06:48.130
if you have higher K then it gets

00:06:48.130 --> 00:06:49.360
smoother Prediction.

00:06:50.340 --> 00:06:51.730
You can decide how you're going to

00:06:51.730 --> 00:06:54.400
combine predictions if K is greater

00:06:54.400 --> 00:06:56.750
than one, usually it's just voting or

00:06:56.750 --> 00:06:57.280
averaging.

00:06:58.610 --> 00:07:00.920
You can try to design the features and

00:07:00.920 --> 00:07:03.450
that's where things can get a lot more

00:07:03.450 --> 00:07:03.930
creative.

00:07:04.680 --> 00:07:06.770
And you can choose a Distance function.

00:07:08.900 --> 00:07:12.370
So this K&N is useful in many cases.

00:07:12.370 --> 00:07:14.520
So if you have very few examples per

00:07:14.520 --> 00:07:16.605
class then it can be applied even if

00:07:16.605 --> 00:07:17.320
you just have one.

00:07:18.080 --> 00:07:20.290
It can also work if you have many

00:07:20.290 --> 00:07:21.560
Examples per class.

00:07:22.200 --> 00:07:24.910
It's best if the features are all

00:07:24.910 --> 00:07:26.960
roughly equally important, because K&N

00:07:26.960 --> 00:07:28.540
itself doesn't really learn which

00:07:28.540 --> 00:07:29.449
features are important.

00:07:31.570 --> 00:07:33.910
It's good if the training data is

00:07:33.910 --> 00:07:34.585
changing frequently.

00:07:34.585 --> 00:07:37.520
In the face recognition Example face,

00:07:37.520 --> 00:07:38.830
there's no way that Facebook will

00:07:38.830 --> 00:07:41.160
collect everybody's Faces up front.

00:07:41.160 --> 00:07:43.030
People keep on joining and leaving the

00:07:43.030 --> 00:07:45.480
social network, and so they and they

00:07:45.480 --> 00:07:47.080
don't want to have to keep retraining

00:07:47.080 --> 00:07:49.850
models every time somebody uploads a

00:07:49.850 --> 00:07:52.005
image with a new face in it or tags a

00:07:52.005 --> 00:07:52.615
new face.

00:07:52.615 --> 00:07:54.990
And so the ability to instantly update

00:07:54.990 --> 00:07:56.330
your model is very important.

00:07:58.160 --> 00:07:59.850
You can apply it to classification or

00:07:59.850 --> 00:08:01.740
regression whether you have discrete or

00:08:01.740 --> 00:08:04.570
continuous values, and its most

00:08:04.570 --> 00:08:06.020
powerful when you do some feature

00:08:06.020 --> 00:08:08.180
learning as an upfront operation.

00:08:10.130 --> 00:08:12.210
So there's cases where it has its

00:08:12.210 --> 00:08:13.330
downsides though.

00:08:13.330 --> 00:08:15.650
One is that if you have a lot of

00:08:15.650 --> 00:08:18.250
examples that are available per class,

00:08:18.250 --> 00:08:20.360
then usually training a Logistic

00:08:20.360 --> 00:08:23.690
regressor other Linear Classifier will

00:08:23.690 --> 00:08:26.200
outperform because it's able to learn

00:08:26.200 --> 00:08:27.990
the importance of different Features.

00:08:28.950 --> 00:08:32.125
Also, K&N requires that you store all

00:08:32.125 --> 00:08:34.692
the training data and that may require

00:08:34.692 --> 00:08:38.153
a lot of storage and it requires a lot

00:08:38.153 --> 00:08:40.145
of computation, and that you have to

00:08:40.145 --> 00:08:42.200
compare each new input to all of the

00:08:42.200 --> 00:08:43.750
inputs in your training data.

00:08:43.750 --> 00:08:45.525
So in the case of Facebook for example,

00:08:45.525 --> 00:08:47.745
they don't need if somebody uploads, if

00:08:47.745 --> 00:08:49.780
they detect a face in somebody's image,

00:08:49.780 --> 00:08:51.520
they don't need to compare it to the

00:08:51.520 --> 00:08:53.410
other, like 2 billion Facebook users.

00:08:53.410 --> 00:08:55.176
They just would compare it to people in

00:08:55.176 --> 00:08:56.570
the person's social network, which will

00:08:56.570 --> 00:08:58.900
be a much smaller number of Faces.

00:08:58.970 --> 00:09:01.240
So they're able to limit the

00:09:01.240 --> 00:09:02.190
computation that way.

00:09:05.940 --> 00:09:08.760
And then finally, to recap what we

00:09:08.760 --> 00:09:12.180
learned on Thursday, there's a basic

00:09:12.180 --> 00:09:14.420
machine learning process, which is that

00:09:14.420 --> 00:09:16.170
you've got training data, validation

00:09:16.170 --> 00:09:17.260
data and TestData.

00:09:18.160 --> 00:09:19.980
Given the training data, which are

00:09:19.980 --> 00:09:22.730
pairs of Features and labels, you fit

00:09:22.730 --> 00:09:25.060
the parameters of your Model.

00:09:25.060 --> 00:09:26.950
Then you use the validation Model to

00:09:26.950 --> 00:09:28.670
check how good the Model is and maybe

00:09:28.670 --> 00:09:29.805
check many models.

00:09:29.805 --> 00:09:31.960
You choose the best one and then you

00:09:31.960 --> 00:09:33.590
get your final estimate of performance

00:09:33.590 --> 00:09:34.410
on the TestData.

00:09:36.790 --> 00:09:39.670
We talked about KNN, which is simple

00:09:39.670 --> 00:09:42.040
but effective Classifier and regressor

00:09:42.040 --> 00:09:44.140
that predicts the label of the most

00:09:44.140 --> 00:09:45.540
similar training Example.

00:09:46.770 --> 00:09:49.110
And then we talked about kind of

00:09:49.110 --> 00:09:51.110
patterns of error and what causes

00:09:51.110 --> 00:09:51.580
errors.

00:09:51.580 --> 00:09:53.780
So it's important to remember that as

00:09:53.780 --> 00:09:56.069
you get more training, more training

00:09:56.070 --> 00:09:57.830
samples, you would expect that fitting

00:09:57.830 --> 00:09:58.962
the training data gets harder.

00:09:58.962 --> 00:10:01.500
So your error will tend to go up while

00:10:01.500 --> 00:10:03.390
your error on the TestData will get

00:10:03.390 --> 00:10:05.535
lower because the training data better

00:10:05.535 --> 00:10:07.010
represents the TestData or better

00:10:07.010 --> 00:10:08.430
represents the full distribution.

00:10:09.770 --> 00:10:11.840
And there's many reasons why at the end

00:10:11.840 --> 00:10:13.250
of training your Algorithm, you're

00:10:13.250 --> 00:10:14.720
still going to have error in most

00:10:14.720 --> 00:10:15.220
cases.

00:10:15.880 --> 00:10:17.400
It could be that the problem is

00:10:17.400 --> 00:10:20.940
intrinsically difficult, or it's

00:10:20.940 --> 00:10:22.590
impossible to have 0 error.

00:10:22.590 --> 00:10:24.232
It could be that you're Model has

00:10:24.232 --> 00:10:24.845
limited power.

00:10:24.845 --> 00:10:27.370
It could be that your Model has plenty

00:10:27.370 --> 00:10:29.015
of power, but you have limited data so

00:10:29.015 --> 00:10:30.710
you can't Estimate the parameters

00:10:30.710 --> 00:10:31.290
exactly.

00:10:32.050 --> 00:10:33.100
And it could be that there's

00:10:33.100 --> 00:10:34.550
differences in the training test

00:10:34.550 --> 00:10:35.280
distribution.

00:10:37.020 --> 00:10:38.980
And then finally it's important to

00:10:38.980 --> 00:10:41.315
remember that this Model fitting, the

00:10:41.315 --> 00:10:42.980
model design and fitting is just one

00:10:42.980 --> 00:10:44.750
part of a larger processing collecting

00:10:44.750 --> 00:10:46.600
data and fitting it into an

00:10:46.600 --> 00:10:47.610
application.

00:10:47.610 --> 00:10:51.230
So both the cases of in Facebook's case

00:10:51.230 --> 00:10:54.160
for example they had pre training stage

00:10:54.160 --> 00:10:56.663
which is like training a classifier and

00:10:56.663 --> 00:10:58.852
then they use that in a different, they

00:10:58.852 --> 00:11:01.370
use it in a different way as a nearest

00:11:01.370 --> 00:11:05.320
neighbor recognizer on their pool of

00:11:05.320 --> 00:11:06.010
user data.

00:11:07.070 --> 00:11:10.384
And so they're kind of building a model

00:11:10.384 --> 00:11:11.212
using it.

00:11:11.212 --> 00:11:13.700
They're building a model one way and

00:11:13.700 --> 00:11:15.150
then using it in a different way.

00:11:15.150 --> 00:11:16.660
So often that's the case that you have

00:11:16.660 --> 00:11:17.590
to kind of be creative.

00:11:18.360 --> 00:11:20.580
About how you collect data and how you

00:11:20.580 --> 00:11:23.800
can get the model that you need to

00:11:23.800 --> 00:11:24.860
solve your application.

00:11:28.010 --> 00:11:30.033
Alright, so now I'm going to move on to

00:11:30.033 --> 00:11:31.640
the main topic of today's lecture,

00:11:31.640 --> 00:11:34.880
which is probabilities and the night

00:11:34.880 --> 00:11:35.935
based Classifier.

00:11:35.935 --> 00:11:39.690
So the knight based Classifier is

00:11:39.690 --> 00:11:41.220
unlike nearest neighbor, it's not.

00:11:41.990 --> 00:11:44.020
Usually like the final approach that

00:11:44.020 --> 00:11:46.080
somebody takes, but it's sometimes a

00:11:46.080 --> 00:11:49.460
piece of a piece of how somebody is

00:11:49.460 --> 00:11:51.210
estimating probabilities as part of

00:11:51.210 --> 00:11:51.870
their approach.

00:11:52.690 --> 00:11:55.610
And it's a good introduction to

00:11:55.610 --> 00:11:56.630
Probabilistic models.

00:11:59.220 --> 00:12:02.525
So with the nearest neighbor

00:12:02.525 --> 00:12:04.670
classifier, that's an instance based

00:12:04.670 --> 00:12:05.960
Classifier, which means that you're

00:12:05.960 --> 00:12:07.800
assigning labels just based on matching

00:12:07.800 --> 00:12:08.515
other instances.

00:12:08.515 --> 00:12:11.160
The instances the data are the Model.

00:12:12.260 --> 00:12:14.590
Now we're going to start talking about

00:12:14.590 --> 00:12:15.910
Probabilistic models.

00:12:15.910 --> 00:12:18.290
In a Probabilistic Model, you choose

00:12:18.290 --> 00:12:21.060
the label that is most likely given the

00:12:21.060 --> 00:12:21.630
Features.

00:12:21.630 --> 00:12:23.390
So that's kind of an intuitive thing to

00:12:23.390 --> 00:12:25.510
do if you want to know.

00:12:26.520 --> 00:12:28.690
Which if you're looking at an image and

00:12:28.690 --> 00:12:30.390
trying to classify it into a Digit, it

00:12:30.390 --> 00:12:32.074
makes sense that you would assign it to

00:12:32.074 --> 00:12:34.000
the Digit that is most likely given the

00:12:34.000 --> 00:12:35.940
Features given the pixel intensities.

00:12:36.610 --> 00:12:38.170
But of course, like the challenge is

00:12:38.170 --> 00:12:40.030
modeling this probability function, how

00:12:40.030 --> 00:12:42.590
do you Model the probability of the

00:12:42.590 --> 00:12:44.000
label given the data?

00:12:45.340 --> 00:12:47.520
So this is just a very compact way of

00:12:47.520 --> 00:12:48.135
writing that.

00:12:48.135 --> 00:12:50.270
So I have Y star is the predicted

00:12:50.270 --> 00:12:53.150
label, and that's equal to the argmax

00:12:53.150 --> 00:12:53.836
over Y.

00:12:53.836 --> 00:12:55.770
So it's the Y that maximizes

00:12:55.770 --> 00:12:56.950
probability of Y given X.

00:12:56.950 --> 00:12:59.250
So you assign the label that's most

00:12:59.250 --> 00:13:00.590
likely given the data.

00:13:03.170 --> 00:13:05.210
So I just want to do a very brief

00:13:05.210 --> 00:13:08.240
review of some probability things.

00:13:08.240 --> 00:13:10.730
Hopefully this looks familiar, but it's

00:13:10.730 --> 00:13:12.920
still useful to refresh on it.

00:13:13.720 --> 00:13:15.290
So first Joint and conditional

00:13:15.290 --> 00:13:16.260
probability.

00:13:16.260 --> 00:13:19.040
If you say probability of X&Y then that

00:13:19.040 --> 00:13:20.900
means the probability that both of

00:13:20.900 --> 00:13:24.180
those values are true at the same time,

00:13:24.180 --> 00:13:25.030
so.

00:13:26.330 --> 00:13:28.400
So if you say like the probability that

00:13:28.400 --> 00:13:29.290
it's sunny.

00:13:29.980 --> 00:13:32.540
And it's rainy, then that's probably a

00:13:32.540 --> 00:13:33.910
very low probability, because those

00:13:33.910 --> 00:13:35.700
usually don't happen at the same time.

00:13:35.700 --> 00:13:37.635
Both X&Y are true.

00:13:37.635 --> 00:13:40.396
That's equal to the probability of X

00:13:40.396 --> 00:13:42.179
given Y times probability of Y.

00:13:42.180 --> 00:13:45.725
So probability of X given Y is the

00:13:45.725 --> 00:13:48.700
probability that X is true given the

00:13:48.700 --> 00:13:50.956
known values of Y times the probability

00:13:50.956 --> 00:13:52.280
that Y is true.

00:13:52.970 --> 00:13:54.789
And that's also equal to probability of

00:13:54.790 --> 00:13:56.769
Y given X times probability of X.

00:13:56.770 --> 00:13:59.450
So you can take a Joint probability and

00:13:59.450 --> 00:14:01.580
turn it into a conditional probability

00:14:01.580 --> 00:14:04.370
times the probability of their meaning

00:14:04.370 --> 00:14:06.190
variables, the condition variables.

00:14:07.010 --> 00:14:08.660
And you can apply that down a chain.

00:14:08.660 --> 00:14:11.341
So probability of ABC is probability of

00:14:11.341 --> 00:14:13.531
a given BC times probability of B given

00:14:13.531 --> 00:14:14.900
C times probability of C.

00:14:17.320 --> 00:14:18.730
And then it's important to remember

00:14:18.730 --> 00:14:21.110
Bayes rule, which is a way of relating

00:14:21.110 --> 00:14:23.160
probability of X given Y and

00:14:23.160 --> 00:14:24.869
probability of Y given X.

00:14:25.520 --> 00:14:27.440
So of X given Y.

00:14:28.100 --> 00:14:30.516
Is equal to probability of Y given X

00:14:30.516 --> 00:14:32.222
times probability of X over probability

00:14:32.222 --> 00:14:35.090
of Y and you can get that by saying

00:14:35.090 --> 00:14:38.595
probability of X given Y is probability

00:14:38.595 --> 00:14:41.599
of X&Y over probability of Y.

00:14:41.600 --> 00:14:43.730
So what was done here is you multiply

00:14:43.730 --> 00:14:45.910
this by probability of Y and then

00:14:45.910 --> 00:14:47.771
divide it by probability of Y and

00:14:47.771 --> 00:14:49.501
probability of X given Y times

00:14:49.501 --> 00:14:51.519
probability of Y is probability of X&Y.

00:14:52.600 --> 00:14:54.390
And then the probability of X&Y is

00:14:54.390 --> 00:14:56.030
broken out into probability of Y given

00:14:56.030 --> 00:14:57.209
X times probability of X.

00:14:59.150 --> 00:15:01.040
So often it's the case that you want to

00:15:01.040 --> 00:15:03.484
kind of switch things you the label and

00:15:03.484 --> 00:15:06.339
you want to know the likelihood of the

00:15:06.339 --> 00:15:08.350
Features, but you have like a

00:15:08.350 --> 00:15:10.544
likelihood for that, but you want a

00:15:10.544 --> 00:15:11.830
likelihood the other way of the

00:15:11.830 --> 00:15:13.654
probability of the label given the

00:15:13.654 --> 00:15:13.868
Features.

00:15:13.868 --> 00:15:15.529
And so you use Bayes rule to kind of

00:15:15.530 --> 00:15:17.550
turn the tables on your likelihood

00:15:17.550 --> 00:15:17.950
function.

00:15:20.620 --> 00:15:25.810
So using using using these rules of

00:15:25.810 --> 00:15:26.530
probability.

00:15:27.210 --> 00:15:29.830
We can show that if I want to find the

00:15:29.830 --> 00:15:33.250
Y that maximizes the likelihood of the

00:15:33.250 --> 00:15:34.690
label given the data.

00:15:35.370 --> 00:15:38.490
That's equivalent to finding the Y that

00:15:38.490 --> 00:15:41.240
maximizes the likelihood of the data

00:15:41.240 --> 00:15:44.520
given the label times the probability

00:15:44.520 --> 00:15:45.210
of the label.

00:15:45.920 --> 00:15:47.690
So in other words, if you wanted to

00:15:47.690 --> 00:15:50.030
say, well, what is the probability that

00:15:50.030 --> 00:15:53.550
my face is Derek given my facial

00:15:53.550 --> 00:15:54.220
features?

00:15:54.950 --> 00:15:56.100
That's the top.

00:15:56.100 --> 00:15:58.323
That's equivalent to saying what's the

00:15:58.323 --> 00:16:00.400
probability that it's me without

00:16:00.400 --> 00:16:02.635
looking at the Features times the

00:16:02.635 --> 00:16:04.270
probability of my Features given that

00:16:04.270 --> 00:16:04.870
it's me?

00:16:04.870 --> 00:16:05.980
Those are the same.

00:16:06.330 --> 00:16:09.770
Those the why that maximizes that is

00:16:09.770 --> 00:16:11.150
going to be the same so.

00:16:12.990 --> 00:16:15.230
And the reason for that is derived down

00:16:15.230 --> 00:16:15.720
here.

00:16:15.720 --> 00:16:17.473
So I can take Y given X.

00:16:17.473 --> 00:16:20.686
So argmax of Y given X is the as argmax

00:16:20.686 --> 00:16:23.029
of Y given X times probability of X.

00:16:23.780 --> 00:16:26.000
And the reason for that is just that

00:16:26.000 --> 00:16:27.880
probability of X doesn't depend on Y.

00:16:27.880 --> 00:16:31.140
So I can multiply multiply this thing

00:16:31.140 --> 00:16:33.092
in the argmax by anything that doesn't

00:16:33.092 --> 00:16:35.410
depend on Y and it's going to be

00:16:35.410 --> 00:16:37.890
unchanged because it's just going to.

00:16:38.870 --> 00:16:41.460
The way that maximizes it will be the

00:16:41.460 --> 00:16:41.780
same.

00:16:43.410 --> 00:16:44.940
So then I turn that.

00:16:45.530 --> 00:16:47.810
I turned that into the Joint Y&X and

00:16:47.810 --> 00:16:48.940
then I broke it out again.

00:16:49.900 --> 00:16:51.300
Right, so the reason why this is

00:16:51.300 --> 00:16:54.430
important is that I can choose to

00:16:54.430 --> 00:16:57.562
either Model directly the probability

00:16:57.562 --> 00:17:00.659
of the label given the data, or I can

00:17:00.659 --> 00:17:02.231
choose the Model the probability of the

00:17:02.231 --> 00:17:03.129
data given the label.

00:17:03.910 --> 00:17:06.172
In a Naive Bayes, we're going to Model

00:17:06.172 --> 00:17:07.950
probability the data given the label,

00:17:07.950 --> 00:17:09.510
and then in the next class we'll talk

00:17:09.510 --> 00:17:11.425
about logistic regression where we try

00:17:11.425 --> 00:17:12.930
to directly Model the probability of

00:17:12.930 --> 00:17:14.000
the label given the data.

00:17:22.090 --> 00:17:24.760
All right, so let's just.

00:17:26.170 --> 00:17:29.400
Do a simple probability exercise just

00:17:29.400 --> 00:17:31.430
to kind of make sure that.

00:17:33.430 --> 00:17:34.730
That we get.

00:17:37.010 --> 00:17:38.230
So let's say.

00:17:39.620 --> 00:17:41.060
Here I have a feature.

00:17:41.060 --> 00:17:41.970
Doesn't really matter what the

00:17:41.970 --> 00:17:43.440
Features, but let's say that it's

00:17:43.440 --> 00:17:45.233
whether something is larger than £10

00:17:45.233 --> 00:17:48.210
and I collected a bunch of different

00:17:48.210 --> 00:17:50.530
animals, cats and dogs and measured

00:17:50.530 --> 00:17:50.770
them.

00:17:51.450 --> 00:17:53.130
And I want to train something that will

00:17:53.130 --> 00:17:54.510
tell me whether or not something is a

00:17:54.510 --> 00:17:54.810
cat.

00:17:55.730 --> 00:17:57.370
And so.

00:17:58.190 --> 00:18:00.985
Or a dog, and so I have like 40

00:18:00.985 --> 00:18:03.280
different cats and 45 different dogs,

00:18:03.280 --> 00:18:04.860
and I measured whether or not they're

00:18:04.860 --> 00:18:06.693
bigger than £10.

00:18:06.693 --> 00:18:10.270
So first, given this empirical

00:18:10.270 --> 00:18:12.505
distribution, given these samples that

00:18:12.505 --> 00:18:15.120
I have, what's the probability that Y

00:18:15.120 --> 00:18:15.810
is a cat?

00:18:22.430 --> 00:18:25.970
So it's actually 40 / 85 because it's

00:18:25.970 --> 00:18:26.960
going to be.

00:18:27.640 --> 00:18:29.030
Let me see if I can write on this.

00:18:36.840 --> 00:18:37.330
OK.

00:18:39.520 --> 00:18:40.460
That's not what I wanted.

00:18:43.970 --> 00:18:45.500
If I can get the pen to work.

00:18:48.610 --> 00:18:50.360
OK, it doesn't work that well.

00:18:55.010 --> 00:18:56.250
OK, forget that.

00:18:56.250 --> 00:18:57.420
Alright, I'll write it on the board.

00:18:57.420 --> 00:18:59.639
So it's 40 / 85.

00:19:01.780 --> 00:19:05.010
So it's 40 / 40 + 45.

00:19:05.920 --> 00:19:08.595
And that's because there's 40 cats and

00:19:08.595 --> 00:19:09.888
there's 45 dogs.

00:19:09.888 --> 00:19:13.040
So I take the count of all the cats and

00:19:13.040 --> 00:19:14.970
divide it by the count of all the data

00:19:14.970 --> 00:19:16.635
in total, all the cats and dogs.

00:19:16.635 --> 00:19:17.860
So that's 40 / 85.

00:19:18.580 --> 00:19:20.470
And what's the probability that Y is a

00:19:20.470 --> 00:19:22.810
cat given that X is false?

00:19:29.380 --> 00:19:31.510
So it's right?

00:19:31.510 --> 00:19:34.240
So it's 15 / 20 or 3 / 4.

00:19:34.240 --> 00:19:35.890
And that's because given that X is

00:19:35.890 --> 00:19:37.620
false, I'm just in this one column

00:19:37.620 --> 00:19:40.799
here, so it's 15 / 15 / 20.

00:19:42.090 --> 00:19:45.110
And what's the probability that X is

00:19:45.110 --> 00:19:46.650
false given that Y is a cat?

00:19:49.320 --> 00:19:51.570
Right, 15 / 480 because if I know that

00:19:51.570 --> 00:19:53.500
Y is a Cat, then I'm in the top row, so

00:19:53.500 --> 00:19:55.590
it's just 15 divided by all the cats,

00:19:55.590 --> 00:19:56.650
so 15 / 40.

00:19:58.320 --> 00:20:00.737
OK, and it's important to remember that

00:20:00.737 --> 00:20:03.119
Y given X is different than X given Y.

00:20:05.110 --> 00:20:08.276
Right, so some other simple rules of

00:20:08.276 --> 00:20:08.572
probability.

00:20:08.572 --> 00:20:11.150
One is the law of total probability.

00:20:11.150 --> 00:20:13.060
That is, if you sum over all the values

00:20:13.060 --> 00:20:16.020
of a variable, then the sum of those

00:20:16.020 --> 00:20:17.630
probabilities is equal to 1.

00:20:18.240 --> 00:20:20.450
And if this were a continuous variable,

00:20:20.450 --> 00:20:21.840
it would just be an integral over the

00:20:21.840 --> 00:20:23.716
domain of X over all the values of X

00:20:23.716 --> 00:20:26.180
and then the integral over P of X is

00:20:26.180 --> 00:20:26.690
equal to 1.

00:20:27.980 --> 00:20:29.470
Then I've got Marginalization.

00:20:29.470 --> 00:20:31.990
So if I have a joint probability of two

00:20:31.990 --> 00:20:34.150
variables and I want to get rid of one

00:20:34.150 --> 00:20:34.520
of them.

00:20:35.280 --> 00:20:37.630
Then I take this sum over all the

00:20:37.630 --> 00:20:39.290
values of 1 and the variables.

00:20:39.290 --> 00:20:41.052
In this case it's the sum over all the

00:20:41.052 --> 00:20:41.900
values of X.

00:20:42.570 --> 00:20:46.268
Of X&Y and that's going to be equal to

00:20:46.268 --> 00:20:46.910
P of Y.

00:20:53.440 --> 00:20:55.380
And then finally independence.

00:20:55.380 --> 00:20:59.691
So A is independent of B if and only if

00:20:59.691 --> 00:21:02.414
the probability of A&B is equal to the

00:21:02.414 --> 00:21:04.115
probability of a times the probability

00:21:04.115 --> 00:21:04.660
of B.

00:21:05.430 --> 00:21:07.974
Or another way to write it is that

00:21:07.974 --> 00:21:10.142
probability that what this implies is

00:21:10.142 --> 00:21:12.500
that probability of a given B is equal

00:21:12.500 --> 00:21:13.890
to probability of a.

00:21:13.890 --> 00:21:15.680
So if I just divide both sides by

00:21:15.680 --> 00:21:17.250
probability of B then I get that.

00:21:18.160 --> 00:21:20.855
Or probability of B given A equals

00:21:20.855 --> 00:21:22.010
probability of B.

00:21:22.010 --> 00:21:24.150
So these things are the top one.

00:21:24.150 --> 00:21:25.700
Might not be something that pops into

00:21:25.700 --> 00:21:26.420
your head right away.

00:21:26.420 --> 00:21:28.450
It's not necessarily as intuitive, but

00:21:28.450 --> 00:21:30.001
these are pretty intuitive that

00:21:30.001 --> 00:21:32.376
probability of a given B equals

00:21:32.376 --> 00:21:33.564
probability of a.

00:21:33.564 --> 00:21:36.050
So in other words, whether or not a is

00:21:36.050 --> 00:21:37.470
true doesn't depend on B at all.

00:21:38.720 --> 00:21:40.430
And whether or not B is true doesn't

00:21:40.430 --> 00:21:42.360
depend on A at all, and then you can

00:21:42.360 --> 00:21:44.810
easily get to the one up there just by

00:21:44.810 --> 00:21:47.410
multiplying here both sides by

00:21:47.410 --> 00:21:48.100
probability of a.

00:21:56.140 --> 00:21:59.180
Alright, so in some of the slides

00:21:59.180 --> 00:22:00.650
there's going to be a bunch of like

00:22:00.650 --> 00:22:02.760
indices, so I just wanted to try to be

00:22:02.760 --> 00:22:04.370
consistent in the way that I use them.

00:22:05.030 --> 00:22:07.674
And also like usually verbally say what

00:22:07.674 --> 00:22:10.543
the what the variables mean, but when I

00:22:10.543 --> 00:22:14.300
say XI mean the ith feature so I is a

00:22:14.300 --> 00:22:15.085
feature index.

00:22:15.085 --> 00:22:18.619
When I say XNI mean the nth sample, so

00:22:18.620 --> 00:22:20.520
north is the sample index and Lynn

00:22:20.520 --> 00:22:21.590
would be the nth label.

00:22:22.370 --> 00:22:24.993
So if I say X and I, then that's the

00:22:24.993 --> 00:22:26.760
ith feature of the nth label.

00:22:26.760 --> 00:22:29.763
So for digits for example, would be the

00:22:29.763 --> 00:22:33.720
ith pixel of the nth Digit Example.

00:22:35.070 --> 00:22:37.580
I used this delta here to indicate with

00:22:37.580 --> 00:22:39.900
some expression inside to indicate that

00:22:39.900 --> 00:22:42.780
it returns true or returns one if the

00:22:42.780 --> 00:22:44.850
expression inside it is true and 0

00:22:44.850 --> 00:22:45.410
otherwise.

00:22:46.200 --> 00:22:48.110
And I'll Use V for a feature value.

00:22:55.320 --> 00:22:57.900
So if I want to Estimate the

00:22:57.900 --> 00:22:59.830
probabilities of some function, I can

00:22:59.830 --> 00:23:00.578
just do it by counting.

00:23:00.578 --> 00:23:02.760
So if I want to say what is the

00:23:02.760 --> 00:23:04.950
probability that X equals some value

00:23:04.950 --> 00:23:07.600
and I have capital N Samples, then I

00:23:07.600 --> 00:23:09.346
can just take a sum over all the

00:23:09.346 --> 00:23:11.350
samples and count for how many of them

00:23:11.350 --> 00:23:14.030
XN equals V so that's kind of intuitive

00:23:14.030 --> 00:23:14.480
if I have.

00:23:15.870 --> 00:23:17.750
If I have a month full of days and I

00:23:17.750 --> 00:23:19.280
want to say what's the probability that

00:23:19.280 --> 00:23:21.610
one of those days is sunny, then I can

00:23:21.610 --> 00:23:23.809
just take a sum over all the I can

00:23:23.810 --> 00:23:25.370
count how many sunny days there were

00:23:25.370 --> 00:23:26.908
divided by the total number of days and

00:23:26.908 --> 00:23:27.930
that gives me an Estimate.

00:23:31.930 --> 00:23:35.340
But what if I have 100 variables?

00:23:35.340 --> 00:23:36.380
So if I have.

00:23:37.310 --> 00:23:39.220
For example, in the digits case I have

00:23:39.220 --> 00:23:42.840
784 different and pixel intensities.

00:23:43.710 --> 00:23:46.350
And there's no way I can count over all

00:23:46.350 --> 00:23:48.222
possible combinations of pixel

00:23:48.222 --> 00:23:49.000
intensities, right?

00:23:49.000 --> 00:23:51.470
Even if I were to turn them into binary

00:23:51.470 --> 00:23:56.070
values, there would be 2 to the 784

00:23:56.070 --> 00:23:58.107
different combinations of pixel

00:23:58.107 --> 00:23:58.670
intensities.

00:23:58.670 --> 00:24:01.635
So you would need like data samples

00:24:01.635 --> 00:24:03.520
that are equal to like number of atoms

00:24:03.520 --> 00:24:05.300
in the universe or something like that

00:24:05.300 --> 00:24:07.415
in order to even begin to Estimate it.

00:24:07.415 --> 00:24:08.900
And that would that would only be

00:24:08.900 --> 00:24:10.460
giving you very few samples per

00:24:10.460 --> 00:24:11.050
combination.

00:24:12.860 --> 00:24:15.407
So obviously, like jointly modeling a

00:24:15.407 --> 00:24:17.799
whole bunch of different, the

00:24:17.800 --> 00:24:19.431
probability of a whole bunch of

00:24:19.431 --> 00:24:20.740
different variables is usually

00:24:20.740 --> 00:24:23.490
impossible, and even approximating it,

00:24:23.490 --> 00:24:24.880
it's very challenging.

00:24:24.880 --> 00:24:26.260
You have to try to solve for the

00:24:26.260 --> 00:24:28.036
dependency structures and then solve

00:24:28.036 --> 00:24:30.236
for different combinations of variables

00:24:30.236 --> 00:24:30.699
and.

00:24:31.550 --> 00:24:33.740
And then worry about the dependencies

00:24:33.740 --> 00:24:35.040
that aren't fully accounted for.

00:24:35.880 --> 00:24:37.670
And so it's just really difficult to

00:24:37.670 --> 00:24:40.160
estimate the probability of all your

00:24:40.160 --> 00:24:41.810
Features given the label.

00:24:42.900 --> 00:24:43.610
Jointly.

00:24:44.440 --> 00:24:47.540
And so that's the Naive Bayes Model

00:24:47.540 --> 00:24:48.240
comes in.

00:24:48.240 --> 00:24:50.430
It makes us greatly simplifying

00:24:50.430 --> 00:24:51.060
assumption.

00:24:51.730 --> 00:24:54.132
Which is that all of the features are

00:24:54.132 --> 00:24:56.010
independent given the label, so it

00:24:56.010 --> 00:24:57.480
doesn't mean the Features are

00:24:57.480 --> 00:24:57.840
independent.

00:24:57.940 --> 00:25:00.200
Unconditionally, but they're

00:25:00.200 --> 00:25:02.370
independent given the label, so.

00:25:03.550 --> 00:25:05.716
So because of because they're

00:25:05.716 --> 00:25:06.149
independent.

00:25:06.150 --> 00:25:08.400
Remember that probability of A&B equals

00:25:08.400 --> 00:25:11.173
probability of a * b times probability

00:25:11.173 --> 00:25:12.603
B if they're independent.

00:25:12.603 --> 00:25:15.160
So probability of X that's like a Joint

00:25:15.160 --> 00:25:17.920
X, all the Features given Y is equal to

00:25:17.920 --> 00:25:20.501
the product over all the features of

00:25:20.501 --> 00:25:22.919
probability of each feature given Y.

00:25:24.880 --> 00:25:28.866
And so then I can make my Classifier as

00:25:28.866 --> 00:25:30.450
the Y star.

00:25:30.450 --> 00:25:32.880
The most likely label is the one that

00:25:32.880 --> 00:25:35.415
maximizes this joint probability of

00:25:35.415 --> 00:25:37.930
probability of X given Y times

00:25:37.930 --> 00:25:38.779
probability of Y.

00:25:39.810 --> 00:25:42.715
And this thing, the joint probability

00:25:42.715 --> 00:25:44.985
of X given Y would be really hard to

00:25:44.985 --> 00:25:45.240
Estimate.

00:25:45.240 --> 00:25:47.490
You need tons of data, but this is not

00:25:47.490 --> 00:25:49.120
so hard to Estimate because you're just

00:25:49.120 --> 00:25:50.590
estimating the probability of 1

00:25:50.590 --> 00:25:51.590
variable at a time.

00:25:57.200 --> 00:25:59.190
So for example if I.

00:25:59.810 --> 00:26:01.900
In the Digit Example, this would be

00:26:01.900 --> 00:26:03.860
saying that the I'm going to choose the

00:26:03.860 --> 00:26:07.310
label that maximizes the product of

00:26:07.310 --> 00:26:09.220
likelihoods of each of the pixel

00:26:09.220 --> 00:26:09.980
intensities.

00:26:10.690 --> 00:26:12.555
So I'm just going to consider each

00:26:12.555 --> 00:26:13.170
pixel.

00:26:13.170 --> 00:26:15.170
How likely is each pixel to have its

00:26:15.170 --> 00:26:16.959
intensity given the label?

00:26:16.960 --> 00:26:18.230
And then I choose the label that

00:26:18.230 --> 00:26:20.132
maximizes that, taking the product of

00:26:20.132 --> 00:26:21.760
all the all those likelihoods over the

00:26:21.760 --> 00:26:22.140
pixels.

00:26:23.210 --> 00:26:23.690
So.

00:26:24.650 --> 00:26:26.880
Obviously it's not a perfect Model,

00:26:26.880 --> 00:26:28.210
even if I know that.

00:26:28.210 --> 00:26:30.610
If I'm given that it's a three, knowing

00:26:30.610 --> 00:26:32.759
that one pixel has an intensity of 1

00:26:32.760 --> 00:26:33.920
makes it more likely that the

00:26:33.920 --> 00:26:35.815
neighboring pixel has a likelihood of

00:26:35.815 --> 00:26:36.240
1.

00:26:36.240 --> 00:26:37.630
On the other hand, it's not a terrible

00:26:37.630 --> 00:26:38.710
Model either.

00:26:38.710 --> 00:26:41.028
If I know that it's a 3, then I have a

00:26:41.028 --> 00:26:43.210
pretty good idea of the expected

00:26:43.210 --> 00:26:45.177
intensity of each pixel, so I have a

00:26:45.177 --> 00:26:46.503
pretty good idea of how likely each

00:26:46.503 --> 00:26:47.920
pixel is to be a one or a zero.

00:26:50.490 --> 00:26:51.780
In the case of the temperature

00:26:51.780 --> 00:26:53.760
Regression will make a slightly

00:26:53.760 --> 00:26:55.040
different assumption.

00:26:55.040 --> 00:26:57.736
So here we have continuous Features and

00:26:57.736 --> 00:26:59.320
a continuous Prediction.

00:27:00.030 --> 00:27:02.840
So we're going to assume that each

00:27:02.840 --> 00:27:05.490
feature predicts the temperature that

00:27:05.490 --> 00:27:07.690
we're trying to predict the tomorrow's

00:27:07.690 --> 00:27:10.160
Cleveland temperature with some offset

00:27:10.160 --> 00:27:10.673
and variance.

00:27:10.673 --> 00:27:13.100
So for example, if I know yesterday's

00:27:13.100 --> 00:27:14.670
Cleveland temperature, then tomorrow's

00:27:14.670 --> 00:27:16.633
Cleveland temperature is probably about

00:27:16.633 --> 00:27:19.300
the same, but with some variance around

00:27:19.300 --> 00:27:19.577
it.

00:27:19.577 --> 00:27:21.239
If I know the Cleveland temperature

00:27:21.240 --> 00:27:23.520
from three days ago, then tomorrow's is

00:27:23.520 --> 00:27:25.732
also expected to be about the same but

00:27:25.732 --> 00:27:26.525
with higher variance.

00:27:26.525 --> 00:27:28.596
If I know the temperature of Austin,

00:27:28.596 --> 00:27:30.590
TX, then probably Cleveland is a bit

00:27:30.590 --> 00:27:31.819
colder with some variance.

00:27:33.550 --> 00:27:34.940
And so I'm going to use just that

00:27:34.940 --> 00:27:37.100
combination of individual predictions

00:27:37.100 --> 00:27:38.480
to make my final prediction.

00:27:44.170 --> 00:27:48.680
So here is the Naive Bayes Algorithm.

00:27:49.540 --> 00:27:53.250
For training, I Estimate the parameters

00:27:53.250 --> 00:27:55.370
for each of my likelihood functions,

00:27:55.370 --> 00:27:57.290
the probability of each feature given

00:27:57.290 --> 00:27:57.910
the label.

00:27:58.940 --> 00:28:01.878
And I Estimate the parameters for my

00:28:01.878 --> 00:28:02.232
prior.

00:28:02.232 --> 00:28:06.640
The prior is like the my Estimate, my

00:28:06.640 --> 00:28:08.370
likelihood of the label when I don't

00:28:08.370 --> 00:28:10.180
know anything else, just before I look

00:28:10.180 --> 00:28:11.200
at anything.

00:28:11.200 --> 00:28:13.475
So the probability of the label.

00:28:13.475 --> 00:28:14.770
And that's usually really easy to

00:28:14.770 --> 00:28:15.140
Estimate.

00:28:17.020 --> 00:28:19.280
And then at Prediction time, I'm going

00:28:19.280 --> 00:28:22.970
to solve for the label that maximizes

00:28:22.970 --> 00:28:26.330
the probability of X&Y or the and which

00:28:26.330 --> 00:28:28.620
the Naive Bayes assumption is the

00:28:28.620 --> 00:28:31.110
product over I of probability of XI

00:28:31.110 --> 00:28:32.649
given Y times probability of Y.

00:28:36.470 --> 00:28:40.455
The Naive Naive Bayes is that it's just

00:28:40.455 --> 00:28:42.050
the independence assumption.

00:28:42.050 --> 00:28:45.150
It's not an insult to Thomas Bayes that

00:28:45.150 --> 00:28:46.890
he's an idiot or something.

00:28:46.890 --> 00:28:49.970
It's just that we're going to make this

00:28:49.970 --> 00:28:52.140
very simplifying assumption.

00:28:58.170 --> 00:29:00.550
So all right, so the first thing we

00:29:00.550 --> 00:29:02.710
have to deal with is how do we Estimate

00:29:02.710 --> 00:29:03.590
this probability?

00:29:03.590 --> 00:29:06.500
We want to get some probability of each

00:29:06.500 --> 00:29:08.050
feature given the data.

00:29:08.960 --> 00:29:10.990
And the basic principles are that you

00:29:10.990 --> 00:29:12.909
want to choose parameters.

00:29:12.910 --> 00:29:14.550
First you have to have a model for your

00:29:14.550 --> 00:29:16.610
likelihood, and then you have to

00:29:16.610 --> 00:29:19.394
maximize the parameters of that model

00:29:19.394 --> 00:29:21.908
that you have to, sorry, Choose the

00:29:21.908 --> 00:29:22.885
parameters of that Model.

00:29:22.885 --> 00:29:25.180
That makes your training data most

00:29:25.180 --> 00:29:25.600
likely.

00:29:25.600 --> 00:29:27.210
That's the main principle.

00:29:27.210 --> 00:29:29.780
So if I say somebody says maximum

00:29:29.780 --> 00:29:32.390
likelihood estimation or Emily, that's

00:29:32.390 --> 00:29:34.190
like straight up maximizes the

00:29:34.190 --> 00:29:37.865
probability of the data given your

00:29:37.865 --> 00:29:38.800
parameters in your model.

00:29:40.320 --> 00:29:42.480
Sometimes that can result in

00:29:42.480 --> 00:29:44.120
overconfident estimates.

00:29:44.120 --> 00:29:46.210
So for example if I just have like.

00:29:46.970 --> 00:29:47.800
If I.

00:29:48.430 --> 00:29:51.810
If I have like 2 measurements, let's

00:29:51.810 --> 00:29:53.470
say I want to know what's the average

00:29:53.470 --> 00:29:56.044
weight of a bird and I just have two

00:29:56.044 --> 00:29:58.480
birds, and I say it's probably like a

00:29:58.480 --> 00:29:59.585
Gaussian distribution.

00:29:59.585 --> 00:30:02.012
I can Estimate a mean and a variance

00:30:02.012 --> 00:30:05.970
from those two birds, but that Estimate

00:30:05.970 --> 00:30:07.105
could be like way off.

00:30:07.105 --> 00:30:09.100
So often it's a good idea to have some

00:30:09.100 --> 00:30:11.530
kind of Prior or to prevent the

00:30:11.530 --> 00:30:12.780
variance from going too low.

00:30:12.780 --> 00:30:14.740
So if I looked at two birds and I said

00:30:14.740 --> 00:30:16.860
and they both happen to be like 47

00:30:16.860 --> 00:30:17.510
grams.

00:30:17.870 --> 00:30:19.965
I probably wouldn't want to say that

00:30:19.965 --> 00:30:22.966
the mean is 47 and the variance is 0,

00:30:22.966 --> 00:30:25.170
because then I would be saying like if

00:30:25.170 --> 00:30:27.090
there's another bird that has 48 grams,

00:30:27.090 --> 00:30:28.550
that's like infinitely unlikely.

00:30:28.550 --> 00:30:29.880
It's a 0 probability.

00:30:29.880 --> 00:30:31.600
So often you want to have some kind of

00:30:31.600 --> 00:30:34.270
Prior over your variables as well in

00:30:34.270 --> 00:30:37.025
order to prevent likelihoods going to 0

00:30:37.025 --> 00:30:38.430
because you just didn't have enough

00:30:38.430 --> 00:30:40.120
data to correctly Estimate them.

00:30:40.930 --> 00:30:42.650
So it's like Warren Buffett says with

00:30:42.650 --> 00:30:43.230
investing.

00:30:43.850 --> 00:30:45.550
It's not just about maximizing the

00:30:45.550 --> 00:30:47.690
expectation, it's also about making

00:30:47.690 --> 00:30:48.890
sure there are no zeros.

00:30:48.890 --> 00:30:50.190
Because if you have a zero and your

00:30:50.190 --> 00:30:51.670
product of likelihoods, the whole thing

00:30:51.670 --> 00:30:52.090
is 0.

00:30:53.690 --> 00:30:55.995
And if you have a zero, return your

00:30:55.995 --> 00:30:57.900
whole investment at any point, your

00:30:57.900 --> 00:30:59.330
whole bank account is 0.

00:31:03.120 --> 00:31:06.550
All right, so we have so.

00:31:06.920 --> 00:31:08.840
How do we Estimate P of X given Y given

00:31:08.840 --> 00:31:09.340
the data?

00:31:09.340 --> 00:31:10.980
It's always based on maximizing the

00:31:10.980 --> 00:31:11.930
likelihood of the data.

00:31:12.690 --> 00:31:14.360
Over your parameters, but you have

00:31:14.360 --> 00:31:15.940
different solutions depending on your

00:31:15.940 --> 00:31:18.200
Model and.

00:31:18.370 --> 00:31:19.860
I guess it just depends on your Model.

00:31:20.520 --> 00:31:24.180
So for binomial, a binomial is just if

00:31:24.180 --> 00:31:25.790
you have a binary variable, then

00:31:25.790 --> 00:31:27.314
there's some probability that the

00:31:27.314 --> 00:31:29.450
variable is 1 and 1 minus that

00:31:29.450 --> 00:31:31.790
probability that the variable is 0.

00:31:31.790 --> 00:31:36.126
So Theta Ki is the probability that X I

00:31:36.126 --> 00:31:38.510
= 1 given y = K.

00:31:39.510 --> 00:31:40.590
And you can write it.

00:31:40.590 --> 00:31:42.349
It's kind of a weird way.

00:31:42.350 --> 00:31:43.700
I mean it looks like a weird way to

00:31:43.700 --> 00:31:44.390
write it.

00:31:44.390 --> 00:31:46.190
But if you think about it, if XI equals

00:31:46.190 --> 00:31:48.760
one, then the probability is Theta Ki.

00:31:49.390 --> 00:31:51.630
And if XI equals zero, then the

00:31:51.630 --> 00:31:54.160
probability is 1 minus Theta Ki so.

00:31:54.800 --> 00:31:55.440
Makes sense?

00:31:56.390 --> 00:31:58.390
And if I want to Estimate this, all I

00:31:58.390 --> 00:32:00.530
have to do is count over all my data

00:32:00.530 --> 00:32:01.180
Samples.

00:32:01.180 --> 00:32:06.410
How many times does xni equal 1 and y =

00:32:06.410 --> 00:32:06.880
K?

00:32:07.530 --> 00:32:09.310
Divided by the total number of times

00:32:09.310 --> 00:32:10.490
that Y and equals K.

00:32:11.610 --> 00:32:13.290
And then here it is in Python.

00:32:13.290 --> 00:32:15.620
So it's just a sum over all my data.

00:32:15.620 --> 00:32:18.170
I'm looking at the ith feature here,

00:32:18.170 --> 00:32:20.377
checking how many times these equal 1

00:32:20.377 --> 00:32:23.585
and the label is equal to K divided by

00:32:23.585 --> 00:32:25.170
the number of times the label is equal

00:32:25.170 --> 00:32:25.580
to K.

00:32:27.240 --> 00:32:28.780
And if I have a multinomial, it's

00:32:28.780 --> 00:32:31.100
basically the same thing except that I

00:32:31.100 --> 00:32:35.342
sum over the number of times that X and

00:32:35.342 --> 00:32:37.990
I = V, where V could be say, zero to 10

00:32:37.990 --> 00:32:38.840
or something like that.

00:32:39.740 --> 00:32:42.490
And otherwise it's the same.

00:32:42.490 --> 00:32:46.040
So I can Estimate if I have 10

00:32:46.040 --> 00:32:49.576
different variables and I Estimate

00:32:49.576 --> 00:32:52.590
Theta KIV for all 10 variables, then

00:32:52.590 --> 00:32:54.410
the sum of those Theta kives should be

00:32:54.410 --> 00:32:54.624
one.

00:32:54.624 --> 00:32:56.540
So one of those is a constrained

00:32:56.540 --> 00:32:56.910
variable.

00:32:58.820 --> 00:33:00.420
And it will workout that way if you

00:33:00.420 --> 00:33:01.270
Estimate it this way.

00:33:05.970 --> 00:33:08.733
So if we have a continuous variable by

00:33:08.733 --> 00:33:11.730
the way, like, these can be fairly

00:33:11.730 --> 00:33:15.360
easily derived just by writing out the

00:33:15.360 --> 00:33:18.720
likelihood terms and taking a partial

00:33:18.720 --> 00:33:21.068
derivative with respect to the variable

00:33:21.068 --> 00:33:22.930
and setting that equal to 0.

00:33:22.930 --> 00:33:24.810
But it does take like a page of

00:33:24.810 --> 00:33:26.940
equations, so I decided not to subject

00:33:26.940 --> 00:33:27.379
you to it.

00:33:28.260 --> 00:33:30.190
Since since, solving for these is not

00:33:30.190 --> 00:33:30.920
the point right now.

00:33:32.920 --> 00:33:34.730
And so.

00:33:34.800 --> 00:33:36.000
Are.

00:33:36.000 --> 00:33:38.620
Let's say X is a continuous variable.

00:33:38.620 --> 00:33:40.740
Maybe I want to assume that XI is a

00:33:40.740 --> 00:33:44.052
Gaussian given some label, where the

00:33:44.052 --> 00:33:45.770
label is a discrete variable.

00:33:47.220 --> 00:33:51.023
So Gaussians, if you took hopefully you

00:33:51.023 --> 00:33:52.625
took probably your statistics and you

00:33:52.625 --> 00:33:53.940
probably ran into Gaussians all the

00:33:53.940 --> 00:33:54.230
time.

00:33:54.230 --> 00:33:55.820
Gaussians come up a lot for many

00:33:55.820 --> 00:33:56.550
reasons.

00:33:56.550 --> 00:33:58.749
One of them is that if you add a lot of

00:33:58.750 --> 00:34:01.125
random variables together, then if you

00:34:01.125 --> 00:34:02.839
add enough of them, then it will end up

00:34:02.840 --> 00:34:03.000
there.

00:34:03.000 --> 00:34:04.280
Some of them will end up being a

00:34:04.280 --> 00:34:05.320
Gaussian distribution.

00:34:07.080 --> 00:34:09.415
So there's lots of things end up being

00:34:09.415 --> 00:34:09.700
Gaussians.

00:34:09.700 --> 00:34:11.500
Gaussians is a really common noise

00:34:11.500 --> 00:34:13.536
model, and it also is like really easy

00:34:13.536 --> 00:34:14.320
to work with.

00:34:14.320 --> 00:34:16.060
Even though it looks complicated.

00:34:16.060 --> 00:34:17.820
When you take the log of it ends up

00:34:17.820 --> 00:34:19.342
just being a quadratic, which is easy

00:34:19.342 --> 00:34:20.010
to minimize.

00:34:22.250 --> 00:34:24.460
So there's the Gaussian expression on

00:34:24.460 --> 00:34:24.950
the top.

00:34:26.550 --> 00:34:28.420
And I.

00:34:29.290 --> 00:34:30.610
So let me get my.

00:34:33.940 --> 00:34:34.490
There it goes.

00:34:34.490 --> 00:34:37.060
OK, so here's the Gaussian expression

00:34:37.060 --> 00:34:39.260
one over square of 2π Sigma Ki.

00:34:39.260 --> 00:34:42.075
So the parameters here are M UI which

00:34:42.075 --> 00:34:43.830
is mu Ki which is the mean.

00:34:44.980 --> 00:34:47.700
For the KTH label and the ith feature

00:34:47.700 --> 00:34:49.946
in Sigma, Ki is the stair deviation for

00:34:49.946 --> 00:34:52.080
the Keith label and the Ith feature.

00:34:52.900 --> 00:34:54.700
And so the higher the standard

00:34:54.700 --> 00:34:57.090
deviation is, the bigger the Gaussian

00:34:57.090 --> 00:34:57.425
is.

00:34:57.425 --> 00:34:59.920
So if you look at these plots here, the

00:34:59.920 --> 00:35:02.150
it's kind of blurry the.

00:35:02.770 --> 00:35:05.540
The red curve or the actually the

00:35:05.540 --> 00:35:07.130
yellow curve has like the biggest

00:35:07.130 --> 00:35:08.880
distribution, the broadest distribution

00:35:08.880 --> 00:35:10.510
and it has the highest variance or

00:35:10.510 --> 00:35:12.010
highest standard deviation.

00:35:14.070 --> 00:35:15.780
So this is the MLE, the maximum

00:35:15.780 --> 00:35:17.240
likelihood estimate of the mean.

00:35:17.240 --> 00:35:19.809
It's just the sum of all the X's

00:35:19.810 --> 00:35:21.850
divided by the number of X's.

00:35:21.850 --> 00:35:25.109
Or, sorry, it's a sum over all the X's.

00:35:26.970 --> 00:35:30.190
For which Y n = K divided by the total

00:35:30.190 --> 00:35:31.900
number of times that Y n = K.

00:35:32.790 --> 00:35:34.845
Because I'm estimating the conditional

00:35:34.845 --> 00:35:36.120
conditional mean.

00:35:36.760 --> 00:35:41.570
So it's the sum over all the X's time.

00:35:41.570 --> 00:35:44.060
This will be where Y and equals K

00:35:44.060 --> 00:35:45.670
divided by the count of y = K.

00:35:46.320 --> 00:35:48.050
And they're staring deviation squared.

00:35:48.050 --> 00:35:50.650
Or the variance is the sum over all the

00:35:50.650 --> 00:35:53.340
differences of the X and the mean

00:35:53.340 --> 00:35:56.890
squared where Y and equals K divided by

00:35:56.890 --> 00:35:58.890
the number of times that y = K.

00:35:59.640 --> 00:36:01.180
And you have to estimate the mean

00:36:01.180 --> 00:36:02.480
before you Estimate the steering

00:36:02.480 --> 00:36:02.950
deviation.

00:36:02.950 --> 00:36:05.100
And if you take a statistics class,

00:36:05.100 --> 00:36:07.980
you'll probably like prove that this is

00:36:07.980 --> 00:36:09.945
an OK thing to do, that you're relying

00:36:09.945 --> 00:36:11.720
on one Estimate in order to get the

00:36:11.720 --> 00:36:12.720
other Estimate.

00:36:12.720 --> 00:36:14.420
But it does turn out it's OK.

00:36:16.670 --> 00:36:20.220
Alright, so in our homework for the

00:36:20.220 --> 00:36:22.890
temperature Regression, we're going to

00:36:22.890 --> 00:36:26.095
assume that Y minus XI is a Gaussian,

00:36:26.095 --> 00:36:27.930
so we have two continuous variables.

00:36:28.900 --> 00:36:29.710
So.

00:36:30.940 --> 00:36:34.847
The idea is that the temperature of

00:36:34.847 --> 00:36:38.565
some city on someday predicts the

00:36:38.565 --> 00:36:41.530
temperature of Cleveland on some other

00:36:41.530 --> 00:36:41.850
day.

00:36:42.600 --> 00:36:44.600
With some offset and some variance.

00:36:45.830 --> 00:36:48.190
And that is pretty easy to Model.

00:36:48.190 --> 00:36:51.020
So here's Sigma I is then the stair

00:36:51.020 --> 00:36:53.770
deviation of that offset Prediction and

00:36:53.770 --> 00:36:54.910
MU I is the offset.

00:36:55.560 --> 00:36:58.230
And I just have Y minus XI minus MU I

00:36:58.230 --> 00:37:00.166
squared here instead of Justice XI

00:37:00.166 --> 00:37:02.590
minus MU I squared, which would be if I

00:37:02.590 --> 00:37:03.960
just said XI is a Gaussian.

00:37:05.170 --> 00:37:08.820
And the mean is just why the sum of Y

00:37:08.820 --> 00:37:11.603
minus XI divided by north, where north

00:37:11.603 --> 00:37:12.870
is the total number of Samples.

00:37:13.990 --> 00:37:14.820
Because why?

00:37:14.820 --> 00:37:16.618
Is not discrete, so I'm not counting

00:37:16.618 --> 00:37:20.100
over certain over only values X where Y

00:37:20.100 --> 00:37:21.625
is equal to some value, I'm counting

00:37:21.625 --> 00:37:22.550
over all the values.

00:37:23.410 --> 00:37:25.280
And the Syrian deviation or their

00:37:25.280 --> 00:37:28.590
variance is Y minus XI minus MU I

00:37:28.590 --> 00:37:29.630
squared divided by north.

00:37:30.480 --> 00:37:32.300
And here's the Python.

00:37:33.630 --> 00:37:35.840
Here I just use the mean and steering

00:37:35.840 --> 00:37:37.630
deviation functions to get it, but it's

00:37:37.630 --> 00:37:40.470
also not a very long formula if I were

00:37:40.470 --> 00:37:41.340
to write it all out.

00:37:44.020 --> 00:37:46.830
And then X&Y were jointly Gaussian.

00:37:46.830 --> 00:37:49.660
So if I say that I need to jointly

00:37:49.660 --> 00:37:52.850
Model them, then one way to do it is

00:37:52.850 --> 00:37:53.600
by.

00:37:54.460 --> 00:37:56.510
By saying that probability of XI given

00:37:56.510 --> 00:38:00.660
Y is the joint probability of XI and Y.

00:38:00.660 --> 00:38:03.070
So now I have a 2 variable Gaussian

00:38:03.070 --> 00:38:06.780
with A2 variable mean and a two by two

00:38:06.780 --> 00:38:07.900
covariance matrix.

00:38:08.920 --> 00:38:11.210
Divided by the probability of Y, which

00:38:11.210 --> 00:38:12.700
is a 1D Gaussian.

00:38:12.700 --> 00:38:14.636
Just the Gaussian over probability of

00:38:14.636 --> 00:38:14.999
Y.

00:38:15.000 --> 00:38:16.340
And if you were to write out all the

00:38:16.340 --> 00:38:18.500
math for it would simplify into some

00:38:18.500 --> 00:38:21.890
other Gaussian equation, but it's

00:38:21.890 --> 00:38:23.360
easier to think about it this way.

00:38:27.660 --> 00:38:28.140
Alright.

00:38:28.140 --> 00:38:31.660
And then what if XI is continuous but

00:38:31.660 --> 00:38:32.770
it's not Gaussian?

00:38:33.920 --> 00:38:35.750
And why is discrete?

00:38:35.750 --> 00:38:37.763
There's one simple thing I can do is I

00:38:37.763 --> 00:38:40.770
can just first turn X into a discrete.

00:38:40.860 --> 00:38:41.490


00:38:42.280 --> 00:38:45.060
Into a discrete function, so.

00:38:46.810 --> 00:38:48.640
For example if.

00:38:49.590 --> 00:38:52.260
Let me venture with my pen again, but.

00:39:08.410 --> 00:39:08.810
Can't do it.

00:39:08.810 --> 00:39:09.170
I want.

00:39:15.140 --> 00:39:15.490
OK.

00:39:16.820 --> 00:39:20.930
So for example, X has a range from.

00:39:21.120 --> 00:39:22.130
From zero to 1.

00:39:22.810 --> 00:39:26.332
That's the case for our intensities of

00:39:26.332 --> 00:39:28.340
the pixel, intensities of amnesty.

00:39:29.180 --> 00:39:31.830
I can just set a threshold for example

00:39:31.830 --> 00:39:38.230
of 0.5 and if X is greater than 05 then

00:39:38.230 --> 00:39:40.369
I'm going to say that it's equal to 1.

00:39:41.030 --> 00:39:43.860
NFX is less than five, then I'm going

00:39:43.860 --> 00:39:45.050
to say it's equal to 0.

00:39:45.050 --> 00:39:46.440
So now I turn my continuous

00:39:46.440 --> 00:39:49.350
distribution into a binary distribution

00:39:49.350 --> 00:39:51.040
and now I can just Estimate it using

00:39:51.040 --> 00:39:52.440
the Bernoulli equation.

00:39:53.100 --> 00:39:54.910
Or I could turn X into 10 different

00:39:54.910 --> 00:39:57.280
values by just multiplying X by 10 and

00:39:57.280 --> 00:39:58.050
taking the floor.

00:39:58.050 --> 00:39:59.560
So now the values are zero to 9.

00:40:01.490 --> 00:40:04.150
So that's one that's actually the one

00:40:04.150 --> 00:40:06.110
of the easiest way to deal with the

00:40:06.110 --> 00:40:08.190
continuous variable that's not

00:40:08.190 --> 00:40:08.850
Gaussian.

00:40:12.900 --> 00:40:15.950
Sometimes X will be like text, so for

00:40:15.950 --> 00:40:18.800
example it could be like blue, orange

00:40:18.800 --> 00:40:19.430
or green.

00:40:20.080 --> 00:40:22.070
And then you just need to Map those

00:40:22.070 --> 00:40:25.390
different text tokens into integers.

00:40:25.390 --> 00:40:26.441
So I might say blue.

00:40:26.441 --> 00:40:28.654
I'm going to say I'm going to Map blue

00:40:28.654 --> 00:40:30.620
into zero, orange into one, green into

00:40:30.620 --> 00:40:32.580
two, and then I can just Solve by

00:40:32.580 --> 00:40:33.060
counting.

00:40:36.610 --> 00:40:38.830
And then finally I need to also

00:40:38.830 --> 00:40:40.380
Estimate the probability of Y.

00:40:41.060 --> 00:40:42.990
One common thing to do is just to say

00:40:42.990 --> 00:40:45.880
that Y is equally likely to be all the

00:40:45.880 --> 00:40:46.860
possible labels.

00:40:47.550 --> 00:40:49.440
And that can be a good thing to do,

00:40:49.440 --> 00:40:51.169
because maybe our training distribution

00:40:51.170 --> 00:40:52.870
isn't even, but you don't think you're

00:40:52.870 --> 00:40:54.310
training distribution will be the same

00:40:54.310 --> 00:40:55.790
as the test distribution.

00:40:55.790 --> 00:40:58.340
So then you say that probability of Y

00:40:58.340 --> 00:41:00.470
is uniform even though it's not uniform

00:41:00.470 --> 00:41:00.920
in training.

00:41:01.630 --> 00:41:03.530
If it's uniform, you can just ignore it

00:41:03.530 --> 00:41:05.910
because it won't have any effect on

00:41:05.910 --> 00:41:07.060
which Y is most likely.

00:41:07.980 --> 00:41:09.860
FY is discrete and non uniform.

00:41:09.860 --> 00:41:11.810
You can just solve it by counting how

00:41:11.810 --> 00:41:14.050
many times is Y equal 1 divided by all

00:41:14.050 --> 00:41:16.850
my data is the probability of Y equal

00:41:16.850 --> 00:41:17.070
1.

00:41:17.790 --> 00:41:19.450
If it's continuous, you can Model it as

00:41:19.450 --> 00:41:21.660
a Gaussian or chop it up into bins and

00:41:21.660 --> 00:41:23.000
then turn it into a classification

00:41:23.000 --> 00:41:23.360
problem.

00:41:25.690 --> 00:41:26.050
Right.

00:41:28.290 --> 00:41:31.550
So I'll give you your minute or two,

00:41:31.550 --> 00:41:32.230
Stretch break.

00:41:32.230 --> 00:41:33.650
But I want you to think about this

00:41:33.650 --> 00:41:34.370
while you do that.

00:41:35.390 --> 00:41:38.100
So suppose I want to classify a fruit

00:41:38.100 --> 00:41:40.230
based on description and my Features

00:41:40.230 --> 00:41:42.389
are weight, color, shape and whether

00:41:42.390 --> 00:41:44.190
it's a hard whether the outside is

00:41:44.190 --> 00:41:44.470
hard.

00:41:45.330 --> 00:41:47.960
And so first, here's some examples of

00:41:47.960 --> 00:41:49.100
those Features.

00:41:49.100 --> 00:41:50.750
See if you can figure out which fruit

00:41:50.750 --> 00:41:51.990
correspond to these Features.

00:41:52.630 --> 00:41:56.150
And second, what might be a good set of

00:41:56.150 --> 00:41:58.080
models to use for probability of XI

00:41:58.080 --> 00:41:59.730
given fruit for those four Features?

00:42:01.210 --> 00:42:03.620
So you have two minutes to think about

00:42:03.620 --> 00:42:05.630
it and Oregon Stretch or use the

00:42:05.630 --> 00:42:07.240
bathroom or check your e-mail or

00:42:07.240 --> 00:42:07.620
whatever.

00:44:24.040 --> 00:44:24.730
Alright.

00:44:26.640 --> 00:44:31.100
So first, what is the top 1.5 pounds

00:44:31.100 --> 00:44:31.640
red round?

00:44:31.640 --> 00:44:33.750
Yes, OK, good.

00:44:33.750 --> 00:44:34.870
That's what I was thinking.

00:44:34.870 --> 00:44:37.930
What's the 2nd 115 pounds?

00:44:39.070 --> 00:44:39.810
Avocado.

00:44:39.810 --> 00:44:41.260
That's a huge avocado.

00:44:43.770 --> 00:44:44.660
What is it?

00:44:46.290 --> 00:44:48.090
Watermelon watermelons, what I was

00:44:48.090 --> 00:44:48.450
thinking.

00:44:49.170 --> 00:44:52.140
.1 pounds purple round and not hard.

00:44:53.330 --> 00:44:54.980
I was thinking of a Grape.

00:44:54.980 --> 00:44:55.980
OK, good.

00:44:57.480 --> 00:44:58.900
There wasn't really, there wasn't

00:44:58.900 --> 00:45:00.160
necessarily a right answer.

00:45:00.160 --> 00:45:01.790
It's just kind of what I was thinking.

00:45:02.800 --> 00:45:05.642
Alright, and then how do you Model the

00:45:05.642 --> 00:45:07.700
probability of the feature given the

00:45:07.700 --> 00:45:08.450
fruit for each of these?

00:45:08.450 --> 00:45:09.550
So let's say the weight.

00:45:09.550 --> 00:45:11.172
What would be a good model for

00:45:11.172 --> 00:45:13.270
probability of XI given the label?

00:45:15.080 --> 00:45:17.420
Gaussian would, Gaussian would probably

00:45:17.420 --> 00:45:18.006
be a good choice.

00:45:18.006 --> 00:45:19.820
It has each of these probably has some

00:45:19.820 --> 00:45:21.250
expectation, maybe a Gaussian

00:45:21.250 --> 00:45:22.130
distribution around it.

00:45:24.000 --> 00:45:26.490
Alright, what about the color red,

00:45:26.490 --> 00:45:27.315
green, purple?

00:45:27.315 --> 00:45:28.440
What could I do for that?

00:45:31.440 --> 00:45:35.610
So I could use a multinomial so I can

00:45:35.610 --> 00:45:37.210
just turn it into discrete very

00:45:37.210 --> 00:45:39.410
discrete numbers, integer numbers and

00:45:39.410 --> 00:45:41.480
then count and the shape.

00:45:50.470 --> 00:45:52.470
So if there's assuming that there's

00:45:52.470 --> 00:45:54.470
other shapes, I don't know if there are

00:45:54.470 --> 00:45:55.880
star fruit for example.

00:45:56.790 --> 00:45:58.940
And then multinomial.

00:45:58.940 --> 00:46:00.640
But either way I'll turn it in discrete

00:46:00.640 --> 00:46:04.090
variables and count and the yes nodes.

00:46:05.540 --> 00:46:07.010
So that will be Binomial.

00:46:08.240 --> 00:46:08.540
OK.

00:46:14.840 --> 00:46:18.500
All right, so now we know how to

00:46:18.500 --> 00:46:20.770
Estimate probability of X given Y.

00:46:20.770 --> 00:46:23.065
Now after I go through all that work on

00:46:23.065 --> 00:46:25.178
the training data and I get new test

00:46:25.178 --> 00:46:25.512
sample.

00:46:25.512 --> 00:46:27.900
Now I want to know what's the most

00:46:27.900 --> 00:46:29.620
likely label of that test sample.

00:46:31.200 --> 00:46:31.660
So.

00:46:32.370 --> 00:46:33.860
I can write this in two ways.

00:46:33.860 --> 00:46:36.615
One is I can write Y is the argmax over

00:46:36.615 --> 00:46:38.735
the product of probability of XI given

00:46:38.735 --> 00:46:39.959
Y times probability of Y.

00:46:40.990 --> 00:46:44.334
Or I can write it as the argmax of the

00:46:44.334 --> 00:46:46.718
log of that, which is just the argmax

00:46:46.718 --> 00:46:48.970
of Y of the sum over I of log of

00:46:48.970 --> 00:46:50.904
probability of XI given Yi plus log of

00:46:50.904 --> 00:46:51.599
probability of Y.

00:46:52.570 --> 00:46:55.130
And I can do that because the thing

00:46:55.130 --> 00:46:57.798
that maximizes X also maximizes log of

00:46:57.798 --> 00:46:59.280
X and vice versa.

00:46:59.280 --> 00:47:01.910
And that's actually a really useful

00:47:01.910 --> 00:47:04.270
property because often the logs are

00:47:04.270 --> 00:47:05.745
probabilities are a lot simpler.

00:47:05.745 --> 00:47:08.790
And for example, if I took for example

00:47:08.790 --> 00:47:10.434
at the Gaussian, if I take the log of

00:47:10.434 --> 00:47:11.950
the Gaussian, then it just becomes a

00:47:11.950 --> 00:47:12.760
squared term.

00:47:13.640 --> 00:47:16.400
And the other thing is that these

00:47:16.400 --> 00:47:18.350
probability of Xis might be.

00:47:18.470 --> 00:47:21.553
If I have a lot of them, if I have like

00:47:21.553 --> 00:47:23.723
500 of them and they're on average like

00:47:23.723 --> 00:47:26.320
.1, that would be like .1 to the 500,

00:47:26.320 --> 00:47:27.530
which is going to go outside in

00:47:27.530 --> 00:47:28.690
numerical precision.

00:47:28.690 --> 00:47:30.740
So if you try to Compute this product

00:47:30.740 --> 00:47:32.290
directly, you're probably going to get

00:47:32.290 --> 00:47:34.470
0 or some kind of wonky value.

00:47:35.190 --> 00:47:37.320
And so it's much better to take the sum

00:47:37.320 --> 00:47:39.265
of the logs than to take the product of

00:47:39.265 --> 00:47:40.060
the probabilities.

00:47:42.650 --> 00:47:44.290
Right, so, but I can compute the

00:47:44.290 --> 00:47:45.830
probability of X&Y or the log

00:47:45.830 --> 00:47:48.004
probability of X&Y for each value of Y

00:47:48.004 --> 00:47:49.630
and then choose the value with maximum

00:47:49.630 --> 00:47:50.240
likelihood.

00:47:50.240 --> 00:47:51.686
That will work in the case of the

00:47:51.686 --> 00:47:53.409
digits because I only have 10 digits.

00:47:54.420 --> 00:47:56.940
And so I can check for each possible

00:47:56.940 --> 00:48:00.365
Digit, how likely is the sum of log

00:48:00.365 --> 00:48:01.958
probability of XI given Yi plus

00:48:01.958 --> 00:48:03.770
probability log probability of Y.

00:48:03.770 --> 00:48:06.980
And then I choose the Digit Digit label

00:48:06.980 --> 00:48:08.570
that makes this most likely.

00:48:11.240 --> 00:48:12.580
That's pretty simple.

00:48:12.580 --> 00:48:14.110
In the case of Y is discrete.

00:48:14.900 --> 00:48:16.415
And again, I just want to emphasize

00:48:16.415 --> 00:48:18.983
that this thing of turning product of

00:48:18.983 --> 00:48:21.070
probabilities into a sum of log

00:48:21.070 --> 00:48:23.250
probabilities is really, really widely

00:48:23.250 --> 00:48:23.760
used.

00:48:23.760 --> 00:48:27.610
Almost anytime you Solve for anything

00:48:27.610 --> 00:48:29.140
with probabilities, it involves that

00:48:29.140 --> 00:48:29.380
step.

00:48:31.840 --> 00:48:34.420
Now if Y is continuous, it's a bit more

00:48:34.420 --> 00:48:36.610
complicated and I.

00:48:37.440 --> 00:48:39.890
So I have the derivation here for you.

00:48:39.890 --> 00:48:42.166
So this is for the case.

00:48:42.166 --> 00:48:44.859
I'm going to use as an example the case

00:48:44.860 --> 00:48:47.470
where I'm modeling probability of Y

00:48:47.470 --> 00:48:51.400
minus XI of 1 dimensional Gaussian.

00:48:53.280 --> 00:48:56.260
And anytime you solve this kind of

00:48:56.260 --> 00:48:58.320
thing you're going to go through, you

00:48:58.320 --> 00:48:59.580
would go through the same derivation.

00:48:59.580 --> 00:49:00.280
If it's not.

00:49:00.280 --> 00:49:03.180
Just like a simple matter of if you

00:49:03.180 --> 00:49:05.000
don't have discrete wise, if you have

00:49:05.000 --> 00:49:06.360
continuous wise, then you have to find

00:49:06.360 --> 00:49:08.320
the Y that actually maximizes this

00:49:08.320 --> 00:49:10.760
because you can't check all possible

00:49:10.760 --> 00:49:12.310
values of a continuous variable.

00:49:14.180 --> 00:49:15.390
So it's not.

00:49:16.540 --> 00:49:17.451
It's a lot.

00:49:17.451 --> 00:49:18.362
It's a lot.

00:49:18.362 --> 00:49:20.350
It's a fair number of equations, but

00:49:20.350 --> 00:49:23.420
it's not anything super complicated.

00:49:23.420 --> 00:49:24.940
Let me see if I can get my cursor up

00:49:24.940 --> 00:49:25.960
there again, OK?

00:49:26.710 --> 00:49:29.560
Alright, so first I take the partial

00:49:29.560 --> 00:49:32.526
derivative of the log probability of

00:49:32.526 --> 00:49:34.780
X&Y with respect to Y and set it equal

00:49:34.780 --> 00:49:35.190
to 0.

00:49:35.190 --> 00:49:36.890
So you might remember from calculus

00:49:36.890 --> 00:49:38.720
like if you want to find the min or Max

00:49:38.720 --> 00:49:39.580
of some value.

00:49:40.290 --> 00:49:43.109
Then take the partial with respect to

00:49:43.110 --> 00:49:44.750
some variable.

00:49:44.750 --> 00:49:47.340
You take the partial derivative with

00:49:47.340 --> 00:49:48.800
respect to that variable and set it

00:49:48.800 --> 00:49:49.539
equal to 0.

00:49:50.680 --> 00:49:51.360
And.

00:49:53.080 --> 00:49:55.020
So here I did that.

00:49:55.020 --> 00:49:58.100
Now I've plugged in this Gaussian

00:49:58.100 --> 00:50:00.200
distribution and taken the log.

00:50:01.050 --> 00:50:02.510
And I kind of like there's some

00:50:02.510 --> 00:50:04.020
invisible steps here, because there's

00:50:04.020 --> 00:50:06.410
some terms like the log of one over

00:50:06.410 --> 00:50:07.940
square of 2π Sigma.

00:50:08.580 --> 00:50:10.069
That just don't.

00:50:10.069 --> 00:50:12.290
Those terms don't matter because they

00:50:12.290 --> 00:50:13.080
don't involve Y.

00:50:13.080 --> 00:50:14.743
So the partial derivative of those

00:50:14.743 --> 00:50:16.215
terms with respect to Y is 0.

00:50:16.215 --> 00:50:19.090
So I just didn't include them.

00:50:19.750 --> 00:50:21.815
So these are the terms that include Y

00:50:21.815 --> 00:50:23.590
and I've already taken the log.

00:50:23.590 --> 00:50:25.550
This was originally east to the -, 1

00:50:25.550 --> 00:50:27.839
half whatever is shown here, and the

00:50:27.839 --> 00:50:30.360
log of X of X is equal to X.

00:50:31.840 --> 00:50:33.490
And so I get this guy.

00:50:34.450 --> 00:50:36.530
Now I broke it out into different

00:50:36.530 --> 00:50:39.320
terms, so I did the quadratic of Y

00:50:39.320 --> 00:50:41.190
minus XI minus MU I ^2.

00:50:42.420 --> 00:50:44.100
Mainly so that I don't have to use the

00:50:44.100 --> 00:50:45.620
chain rule and I can keep my

00:50:45.620 --> 00:50:46.740
derivatives really Simple.

00:50:47.830 --> 00:50:51.959
So here I just broke that out to y ^2 y

00:50:51.960 --> 00:50:54.130
axis YMUI.

00:50:54.130 --> 00:50:55.530
And again, I don't need to worry about

00:50:55.530 --> 00:50:57.779
the MU I squared over Sigma I squared

00:50:57.780 --> 00:50:59.750
because it doesn't involve Y so I just

00:50:59.750 --> 00:51:00.230
left it out.

00:51:02.140 --> 00:51:03.990
I.

00:51:04.100 --> 00:51:07.021
Take the derivative with respect to Y.

00:51:07.021 --> 00:51:09.468
So the derivative of y ^2 is 2 Y.

00:51:09.468 --> 00:51:10.976
So this half goes away.

00:51:10.976 --> 00:51:14.080
Derivative of YX is just X.

00:51:15.070 --> 00:51:18.000
So this should be a subscript I.

00:51:18.730 --> 00:51:21.120
And then I did the same for these guys

00:51:21.120 --> 00:51:21.330
here.

00:51:22.500 --> 00:51:25.740
It's just basic algebra, so I just try

00:51:25.740 --> 00:51:27.610
to group the terms that involve Y and

00:51:27.610 --> 00:51:29.480
the terms that don't involve Yi, put

00:51:29.480 --> 00:51:30.840
the terms that don't involve Y and the

00:51:30.840 --> 00:51:33.370
right side, and then finally I divide

00:51:33.370 --> 00:51:36.830
the coefficient of Y and I get this guy

00:51:36.830 --> 00:51:37.150
here.

00:51:38.030 --> 00:51:41.269
So at the end Y is equal to 1 over the

00:51:41.270 --> 00:51:44.408
sum over all the features of 1 / sqrt.

00:51:44.408 --> 00:51:46.690
I mean one over Sigma I ^2.

00:51:47.420 --> 00:51:50.580
Plus one over Sigma y ^2 which is the

00:51:50.580 --> 00:51:52.160
standard deviation of the Prior of Y.

00:51:52.160 --> 00:51:53.906
Or if I just assumed uniform likelihood

00:51:53.906 --> 00:51:55.520
of Yi wouldn't need that term.

00:51:56.610 --> 00:51:59.400
And then that's times the sum over all

00:51:59.400 --> 00:52:02.700
the features of that feature value.

00:52:02.700 --> 00:52:03.930
This should be subscript I.

00:52:04.940 --> 00:52:10.430
Plus MU I divided by Sigma I ^2 plus mu

00:52:10.430 --> 00:52:13.811
Y, the Prior mean of Y divided by Sigma

00:52:13.811 --> 00:52:14.539
y ^2.

00:52:16.150 --> 00:52:18.940
And so this is just a, it's actually

00:52:18.940 --> 00:52:19.849
just a weighted.

00:52:19.850 --> 00:52:22.823
If you say that one over Sigma I

00:52:22.823 --> 00:52:26.035
squared is Wei, it's like a weight for

00:52:26.035 --> 00:52:27.565
that prediction of the ith feature.

00:52:27.565 --> 00:52:29.830
This is just a weighted average of the

00:52:29.830 --> 00:52:31.720
predictions from all the Features

00:52:31.720 --> 00:52:33.250
that's weighted by one over the

00:52:33.250 --> 00:52:35.573
steering deviation squared or one over

00:52:35.573 --> 00:52:36.190
the variance.

00:52:37.590 --> 00:52:40.421
And so I have one over the sum over I

00:52:40.421 --> 00:52:45.683
of WI plus WY times, the sum X plus mu

00:52:45.683 --> 00:52:49.722
I XI plus MU I times, Wei plus mu Y

00:52:49.722 --> 00:52:50.100
times.

00:52:50.100 --> 00:52:50.670
Why?

00:52:51.630 --> 00:52:53.240
Amy sounds similar, unfortunately.

00:52:54.780 --> 00:52:56.430
So it's just the weighted average of

00:52:56.430 --> 00:52:57.910
all the predictions of the individual

00:52:57.910 --> 00:52:58.174
features.

00:52:58.174 --> 00:53:00.093
And it makes sense that it kind of

00:53:00.093 --> 00:53:01.624
makes sense intuitively that the weight

00:53:01.624 --> 00:53:02.650
is 1 over the variance.

00:53:02.650 --> 00:53:04.490
So if you have really high variance,

00:53:04.490 --> 00:53:05.790
then the weight is small.

00:53:05.790 --> 00:53:08.155
So if, for example, maybe the

00:53:08.155 --> 00:53:09.839
temperature in Sacramento is a really

00:53:09.840 --> 00:53:11.513
bad predictor for the temperature in

00:53:11.513 --> 00:53:12.984
Cleveland, so it will have high

00:53:12.984 --> 00:53:14.840
variance and it gets a little weight,

00:53:14.840 --> 00:53:16.460
while the temperature in Cleveland the

00:53:16.460 --> 00:53:19.130
previous day is much more highly

00:53:19.130 --> 00:53:20.849
predictive, has lower variance, so

00:53:20.850 --> 00:53:21.639
it'll get more weight.

00:53:32.280 --> 00:53:35.380
So let me pause here.

00:53:35.380 --> 00:53:38.690
So any questions about?

00:53:39.670 --> 00:53:43.255
Estimating the likelihoods P of X given

00:53:43.255 --> 00:53:47.970
Y, or solving for the Y that makes.

00:53:47.970 --> 00:53:49.880
That's most likely given your

00:53:49.880 --> 00:53:50.500
likelihoods.

00:53:52.460 --> 00:53:54.470
And obviously if I'm happy to work

00:53:54.470 --> 00:53:56.610
through this in office hours as well in

00:53:56.610 --> 00:53:59.940
the TAS should also if you want to like

00:53:59.940 --> 00:54:01.100
spend more time working through the

00:54:01.100 --> 00:54:01.530
equations.

00:54:03.920 --> 00:54:04.930
I just want to pause.

00:54:04.930 --> 00:54:07.830
I know it's a lot of math to soak up.

00:54:09.870 --> 00:54:13.260
And really, it's not that memorizing

00:54:13.260 --> 00:54:14.370
these things isn't important.

00:54:14.370 --> 00:54:15.860
It's really the process that you just

00:54:15.860 --> 00:54:17.385
set the partial derivative with respect

00:54:17.385 --> 00:54:20.140
to Y, set it to zero, and then you do

00:54:20.140 --> 00:54:20.540
the.

00:54:21.250 --> 00:54:23.120
Do the partial derivative and solve the

00:54:23.120 --> 00:54:23.510
algebra.

00:54:26.700 --> 00:54:28.050
All right, I'll go on then.

00:54:28.050 --> 00:54:31.990
So far, this is pure maximum likelihood

00:54:31.990 --> 00:54:32.530
estimation.

00:54:32.530 --> 00:54:34.920
I'm not, I'm not imposing any kinds of

00:54:34.920 --> 00:54:36.470
Priors over my parameters.

00:54:37.570 --> 00:54:39.600
In practice, you do want to impose a

00:54:39.600 --> 00:54:41.010
Prior in your parameters to make sure

00:54:41.010 --> 00:54:42.220
you don't have any zeros.

00:54:43.750 --> 00:54:46.380
Otherwise, like if some in the digits

00:54:46.380 --> 00:54:48.809
case for example the test sample had a

00:54:48.810 --> 00:54:50.470
dot in an unlikely place.

00:54:50.470 --> 00:54:52.662
If I had just had like a one and some

00:54:52.662 --> 00:54:54.030
unlikely pixel, all the probabilities

00:54:54.030 --> 00:54:55.630
would be 0 and you wouldn't know what

00:54:55.630 --> 00:54:57.620
the label is because of that one stupid

00:54:57.620 --> 00:54:57.970
pixel.

00:54:58.730 --> 00:55:01.040
So you want to have some kind of Prior?

00:55:01.730 --> 00:55:03.425
To avoid these zero probabilities.

00:55:03.425 --> 00:55:06.260
So the most common case if you're

00:55:06.260 --> 00:55:08.760
estimating a distribution of discrete

00:55:08.760 --> 00:55:10.430
variables like a multinomial or

00:55:10.430 --> 00:55:13.010
Binomial, is to just initialize with

00:55:13.010 --> 00:55:13.645
some count.

00:55:13.645 --> 00:55:16.180
So you just say for example alpha

00:55:16.180 --> 00:55:16.880
equals one.

00:55:17.610 --> 00:55:20.110
And now I say the probability of X I =

00:55:20.110 --> 00:55:21.620
V given y = K.

00:55:22.400 --> 00:55:24.950
Is Alpha plus the count of how many

00:55:24.950 --> 00:55:27.740
times XI equals V and y = K.

00:55:28.690 --> 00:55:31.865
Divided by the all the different values

00:55:31.865 --> 00:55:35.300
of alpha plus account of XI equals that

00:55:35.300 --> 00:55:37.610
value in y = K probably for clarity I

00:55:37.610 --> 00:55:39.700
should have used something other than B

00:55:39.700 --> 00:55:41.630
in the denominator, but hopefully

00:55:41.630 --> 00:55:42.230
that's clear enough.

00:55:43.060 --> 00:55:46.170
Here's the and then here's the Python

00:55:46.170 --> 00:55:47.070
for that, so it's just.

00:55:47.880 --> 00:55:50.350
Sum of all the values where XI equals V

00:55:50.350 --> 00:55:52.470
and y = K Plus some alpha.

00:55:53.300 --> 00:55:54.980
So if alpha equals zero, then I don't

00:55:54.980 --> 00:55:55.710
have any Prior.

00:55:56.840 --> 00:56:00.450
And then I'm just dividing by the sum

00:56:00.450 --> 00:56:04.270
of times at y = K and there will be.

00:56:04.850 --> 00:56:06.540
The number of alphas will be equal to

00:56:06.540 --> 00:56:08.150
the number of different values, so this

00:56:08.150 --> 00:56:10.510
is like a little bit of a shortcut, but

00:56:10.510 --> 00:56:11.330
it's the same thing.

00:56:12.860 --> 00:56:14.760
If I have a continuous variable and

00:56:14.760 --> 00:56:15.060
I've.

00:56:15.730 --> 00:56:17.010
Modeled it with the Gaussian.

00:56:17.010 --> 00:56:18.470
Then the usual thing to do is just to

00:56:18.470 --> 00:56:20.180
add a small value to your steering

00:56:20.180 --> 00:56:21.420
deviation or your variance.

00:56:22.110 --> 00:56:24.320
And you might want to make that value

00:56:24.320 --> 00:56:27.650
if N is unknown, then make it dependent

00:56:27.650 --> 00:56:29.300
on north so that if you have a huge

00:56:29.300 --> 00:56:31.395
number of samples then the effect of

00:56:31.395 --> 00:56:33.880
the Prior will go down, which is what

00:56:33.880 --> 00:56:34.170
you want.

00:56:36.140 --> 00:56:39.513
So for example, you can say that the

00:56:39.513 --> 00:56:41.990
stern deviation is whatever this

00:56:41.990 --> 00:56:44.770
whatever the MLE estimate of the stern

00:56:44.770 --> 00:56:47.340
deviation is, plus some small value

00:56:47.340 --> 00:56:49.730
sqrt 1 over the length of north.

00:56:50.420 --> 00:56:51.350
Of X, sorry.

00:57:00.440 --> 00:57:02.670
So what the Prior does is it.

00:57:02.810 --> 00:57:05.995
In the case of the discrete variables,

00:57:05.995 --> 00:57:09.110
the Prior is trying to push your

00:57:09.110 --> 00:57:11.152
Estimate towards a uniform likelihood.

00:57:11.152 --> 00:57:13.000
In fact, in both cases it's pushing it

00:57:13.000 --> 00:57:14.280
towards a uniform likelihood.

00:57:15.400 --> 00:57:18.670
So if you had a really large alpha,

00:57:18.670 --> 00:57:20.550
then let's say.

00:57:22.090 --> 00:57:23.440
Let's say that.

00:57:24.620 --> 00:57:25.850
Or I don't know if I can think of

00:57:25.850 --> 00:57:26.170
something.

00:57:28.140 --> 00:57:29.550
Let's say you have a population of

00:57:29.550 --> 00:57:30.900
students and you're trying to estimate

00:57:30.900 --> 00:57:32.510
the probability that a student is male.

00:57:33.520 --> 00:57:36.570
If I say alpha equals 1000, then I'm

00:57:36.570 --> 00:57:37.860
going to need like an awful lot of

00:57:37.860 --> 00:57:40.156
students before I budge very far from a

00:57:40.156 --> 00:57:42.070
5050 chance that a student is male or

00:57:42.070 --> 00:57:42.620
female.

00:57:42.620 --> 00:57:44.057
Because I'll start with saying there's

00:57:44.057 --> 00:57:46.213
1000 males and 1000 females, and then

00:57:46.213 --> 00:57:48.676
I'll count all the males and add them

00:57:48.676 --> 00:57:50.832
to 1000, count all the females, add

00:57:50.832 --> 00:57:53.370
them to 1000, and then I would take the

00:57:53.370 --> 00:57:55.210
male plus 1000 count and divide it by

00:57:55.210 --> 00:57:57.660
2000 plus the total population.

00:57:59.130 --> 00:58:00.860
If Alpha is 0, then I'm going to get

00:58:00.860 --> 00:58:03.410
just my raw empirical Estimate.

00:58:03.410 --> 00:58:06.810
So if I had like 3 students and I say

00:58:06.810 --> 00:58:09.090
alpha equals zero, and I have two males

00:58:09.090 --> 00:58:11.140
and a female, then I'll say 2/3 of them

00:58:11.140 --> 00:58:11.550
are male.

00:58:12.410 --> 00:58:14.670
If I say alpha is 1 and I have two

00:58:14.670 --> 00:58:17.110
males and a female, then I would say

00:58:17.110 --> 00:58:20.490
that my probability of male is 3 / 5

00:58:20.490 --> 00:58:24.100
because it's 2 + 1 / 3 + 2.

00:58:27.060 --> 00:58:28.330
Their deviation it's the same.

00:58:28.330 --> 00:58:30.240
It's like trying to just broaden your

00:58:30.240 --> 00:58:32.600
variance from what you would Estimate

00:58:32.600 --> 00:58:33.580
directly from the data.

00:58:36.500 --> 00:58:39.260
So I think I will not ask you all these

00:58:39.260 --> 00:58:41.210
probabilities because they're kind of

00:58:41.210 --> 00:58:43.220
you've shown the ability to count

00:58:43.220 --> 00:58:44.810
before mostly.

00:58:46.550 --> 00:58:47.640
And.

00:58:47.850 --> 00:58:50.060
So here's for example, the probability

00:58:50.060 --> 00:58:54.509
of X 1 = 0 and y = 0 is 2 out of four.

00:58:54.510 --> 00:58:56.050
I can get that just by looking down

00:58:56.050 --> 00:58:56.670
these rows.

00:58:56.670 --> 00:58:58.870
It takes a little bit of time, but

00:58:58.870 --> 00:59:02.786
there's four times that y = 0 and out

00:59:02.786 --> 00:59:06.660
of those two times X 1 = 0 and so this

00:59:06.660 --> 00:59:07.440
is 2 out of four.

00:59:08.090 --> 00:59:08.930
And the same.

00:59:08.930 --> 00:59:11.260
I can use the same counting method to

00:59:11.260 --> 00:59:13.120
get all of these other probabilities

00:59:13.120 --> 00:59:13.410
here.

00:59:15.770 --> 00:59:19.450
So just to check that everyone's awake,

00:59:19.450 --> 00:59:22.970
if I, what is the probability of Y?

00:59:23.840 --> 00:59:27.370
And X 1 = 1 and X 2 = 1.

00:59:28.500 --> 00:59:30.019
So can you get it from?

00:59:30.019 --> 00:59:32.560
Can you get it from this guy under an

00:59:32.560 --> 00:59:33.450
independence?

00:59:33.450 --> 00:59:35.670
So get it from this under an under an I

00:59:35.670 --> 00:59:36.540
Bayes assumption.

00:59:41.350 --> 00:59:43.240
Let's say I should say probability of Y

00:59:43.240 --> 00:59:43.860
equal 1.

00:59:45.380 --> 00:59:47.910
Probability of y = 1 given X 1 = 1 and

00:59:47.910 --> 00:59:48.930
X 2 = 1.

00:59:57.500 --> 01:00:00.560
And you don't worry about simplifying

01:00:00.560 --> 01:00:02.610
your numerator and denominator.

01:00:03.530 --> 01:00:05.110
What are the things that get multiplied

01:00:05.110 --> 01:00:05.610
together?

01:00:10.460 --> 01:00:14.350
Not sort of, partly that's in there.

01:00:15.220 --> 01:00:17.880
Raise your hand if you think the

01:00:17.880 --> 01:00:18.560
answer.

01:00:19.550 --> 01:00:21.130
I just want to give everyone time.

01:00:24.650 --> 01:00:27.962
But I mean probability of y = 1 given X

01:00:27.962 --> 01:00:29.960
1 = 1 and X 2 = 1.

01:00:39.830 --> 01:00:41.220
A Naive Bayes assumption.

01:01:24.310 --> 01:01:25.800
The raise your hand if you.

01:01:26.490 --> 01:01:27.030
Finished.

01:01:56.450 --> 01:01:57.740
But don't tell me the answer yet.

01:02:18.470 --> 01:02:19.260
Equals one.

01:02:23.210 --> 01:02:23.420
Alright.

01:02:23.420 --> 01:02:24.830
Did anybody get it yet?

01:02:24.830 --> 01:02:25.950
Raise your hand if you did.

01:02:25.950 --> 01:02:26.910
I just don't want to.

01:02:28.170 --> 01:02:29.110
Give it too early.

01:03:46.370 --> 01:03:46.960
Alright.

01:03:48.170 --> 01:03:52.029
Example, some people have gotten it, so

01:03:52.030 --> 01:03:53.950
let me I'll start going through it.

01:03:53.950 --> 01:03:55.480
All right, so the Naive Bayes

01:03:55.480 --> 01:03:56.005
assumption.

01:03:56.005 --> 01:03:57.760
So this would be.

01:03:58.060 --> 01:03:58.250
OK.

01:04:00.690 --> 01:04:02.960
OK, probability it's actually my touch

01:04:02.960 --> 01:04:03.230
screen.

01:04:03.230 --> 01:04:04.400
I think is kind of broken.

01:04:05.250 --> 01:04:09.560
Probability of X1 given Y times

01:04:09.560 --> 01:04:14.815
probability X2 given Y sorry equals

01:04:14.815 --> 01:04:15.200
one.

01:04:16.630 --> 01:04:19.050
Times probability of Y equal 1.

01:04:19.910 --> 01:04:21.950
Right, so it's the product of the

01:04:21.950 --> 01:04:23.180
probabilities of the Features.

01:04:23.180 --> 01:04:24.730
Give them label times the probability

01:04:24.730 --> 01:04:25.240
of the label.

01:04:26.500 --> 01:04:29.990
And so that will be probability of XYX.

01:04:31.030 --> 01:04:32.819
1 = 1.

01:04:33.850 --> 01:04:37.317
Given probability of Yi mean given y =

01:04:37.317 --> 01:04:38.260
1 is 3/4.

01:04:42.110 --> 01:04:46.010
And probably the X 2 = 1 given y = 1 is

01:04:46.010 --> 01:04:46.750
3/4.

01:04:49.250 --> 01:04:52.550
And the probability that y = 1 is two

01:04:52.550 --> 01:04:53.940
quarters or 1/2.

01:04:58.570 --> 01:05:00.180
So it's 930 seconds.

01:05:01.120 --> 01:05:01.390
Right.

01:05:02.580 --> 01:05:05.846
And the probability that y = 0 given X

01:05:05.846 --> 01:05:08.059
1 = 1 and Y 1 = 1.

01:05:09.800 --> 01:05:11.840
I mean sorry, the probability of y = 0

01:05:11.840 --> 01:05:14.480
given the X is equal equal 1.

01:05:15.620 --> 01:05:16.770
Is.

01:05:18.600 --> 01:05:19.190
Let's see.

01:05:20.250 --> 01:05:23.780
So that would be 2 fourths times 2

01:05:23.780 --> 01:05:24.300
fourths.

01:05:25.180 --> 01:05:26.320
Times 2 fourths.

01:05:27.260 --> 01:05:31.300
So if X 1 = 1 and X2 equal 1, then it's

01:05:31.300 --> 01:05:33.540
more likely that Y is equal to 1 than

01:05:33.540 --> 01:05:35.070
that Y is equal to 0.

01:05:41.720 --> 01:05:46.750
If I had if I use my Prior, this is how

01:05:46.750 --> 01:05:48.055
the probabilities would change.

01:05:48.055 --> 01:05:51.060
So if I say alpha equals one, you can

01:05:51.060 --> 01:05:52.900
see that the probabilities get less

01:05:52.900 --> 01:05:53.510
Peaky.

01:05:53.510 --> 01:05:56.422
So I went from 1/4 to 261 quarter and

01:05:56.422 --> 01:05:58.951
3/4 to 2/6 and four six for example.

01:05:58.951 --> 01:06:02.316
So 1/3 and 2/3 is more uniform than 1/4

01:06:02.316 --> 01:06:03.129
and 3/4.

01:06:05.050 --> 01:06:07.040
And then if the initial estimate was

01:06:07.040 --> 01:06:09.020
1/2, the final Estimate will still be

01:06:09.020 --> 01:06:11.620
1/2 because it's because this Prior is

01:06:11.620 --> 01:06:13.650
just trying to push things towards 1/2.

01:06:20.780 --> 01:06:24.220
So I want to give one example of a use

01:06:24.220 --> 01:06:24.550
case.

01:06:24.550 --> 01:06:25.685
So I've actually.

01:06:25.685 --> 01:06:28.360
I mean I want to say like I used Naive

01:06:28.360 --> 01:06:30.630
Bayes, but I use that assumption pretty

01:06:30.630 --> 01:06:31.440
often.

01:06:31.440 --> 01:06:33.480
For example if I wanted to Estimate a

01:06:33.480 --> 01:06:35.210
distribution of RGB colors.

01:06:36.740 --> 01:06:38.410
I would first convert it to a different

01:06:38.410 --> 01:06:39.860
color space, but let's just say I want

01:06:39.860 --> 01:06:41.780
to Estimate distribution of LGBT RGB

01:06:41.780 --> 01:06:42.390
colors.

01:06:42.390 --> 01:06:45.055
Then even though it's 3 dimensions, is

01:06:45.055 --> 01:06:45.690
a pretty.

01:06:45.690 --> 01:06:47.920
You need like a lot of data to estimate

01:06:47.920 --> 01:06:48.610
that distribution.

01:06:48.610 --> 01:06:50.700
And So what I might do is I'll say,

01:06:50.700 --> 01:06:52.820
well, I'm going to assume that RG and B

01:06:52.820 --> 01:06:54.645
are independent and so the probability

01:06:54.645 --> 01:06:57.350
of RGB is just the probability of R

01:06:57.350 --> 01:06:58.808
times probability of G times

01:06:58.808 --> 01:06:59.524
probability B.

01:06:59.524 --> 01:07:01.600
And I compute a histogram for each of

01:07:01.600 --> 01:07:04.940
those, and I use that to get my as my

01:07:04.940 --> 01:07:06.230
likelihood Estimate.

01:07:06.560 --> 01:07:08.520
So it's like really commonly used in

01:07:08.520 --> 01:07:10.120
that kind of setting where you want to

01:07:10.120 --> 01:07:11.770
Estimate the distribution of multiple

01:07:11.770 --> 01:07:13.380
variables and there's just no way to

01:07:13.380 --> 01:07:13.810
get a Joint.

01:07:13.810 --> 01:07:17.100
The only options you really have are to

01:07:17.100 --> 01:07:18.410
make something the Naive Bayes

01:07:18.410 --> 01:07:21.330
assumption or to do a mixture of

01:07:21.330 --> 01:07:23.416
Gaussians, which we'll talk about later

01:07:23.416 --> 01:07:24.320
in the semester.

01:07:26.380 --> 01:07:27.940
Right, But here's the case where it's

01:07:27.940 --> 01:07:29.450
used for object detection.

01:07:29.450 --> 01:07:32.280
So this was by Schneiderman Kanadi and

01:07:32.280 --> 01:07:35.500
it was the most accurate face and car

01:07:35.500 --> 01:07:36.520
detector for a while.

01:07:37.450 --> 01:07:39.720
They detector is based on wavelet

01:07:39.720 --> 01:07:41.420
coefficients which are just like local

01:07:41.420 --> 01:07:42.610
intensity differences.

01:07:43.320 --> 01:07:46.010
And the.

01:07:46.090 --> 01:07:48.880
The It's a Probabilistic framework, so

01:07:48.880 --> 01:07:51.070
they're trying to say whether if you

01:07:51.070 --> 01:07:54.107
Extract a window of Features from the

01:07:54.107 --> 01:07:56.386
image, some Features over some part of

01:07:56.386 --> 01:07:56.839
the image.

01:07:57.450 --> 01:07:59.020
And Extract all the wavelet

01:07:59.020 --> 01:08:00.330
coefficients.

01:08:00.330 --> 01:08:02.390
Then you want to say that it's a face

01:08:02.390 --> 01:08:03.950
if the probability of those

01:08:03.950 --> 01:08:05.853
coefficients is greater given that it's

01:08:05.853 --> 01:08:08.390
a face, than given that's not a face

01:08:08.390 --> 01:08:10.330
times the probability that's a face

01:08:10.330 --> 01:08:11.730
over the probability that's not a face.

01:08:12.430 --> 01:08:14.680
So it's this basic Probabilistic Model.

01:08:14.680 --> 01:08:16.740
And again, the probability modeling.

01:08:16.740 --> 01:08:17.920
The probability of all those

01:08:17.920 --> 01:08:19.370
coefficients is way too hard.

01:08:20.330 --> 01:08:23.290
On the other hand, modeling all the

01:08:23.290 --> 01:08:25.560
Features as independent given the label

01:08:25.560 --> 01:08:26.950
is a little bit too much of a

01:08:26.950 --> 01:08:28.410
simplifying assumption.

01:08:28.410 --> 01:08:30.270
So they use this algorithm that they

01:08:30.270 --> 01:08:33.220
call semi Naive Bayes which is proposed

01:08:33.220 --> 01:08:34.040
earlier.

01:08:35.220 --> 01:08:37.946
Where you just you Model the

01:08:37.946 --> 01:08:39.803
probabilities of little groups of

01:08:39.803 --> 01:08:41.380
features and then you say that the

01:08:41.380 --> 01:08:43.166
total probability is the probability

01:08:43.166 --> 01:08:44.830
the product or the probabilities of

01:08:44.830 --> 01:08:45.849
these groups of Features.

01:08:46.710 --> 01:08:47.845
So they call these patterns.

01:08:47.845 --> 01:08:50.160
So first you do some look at the mutual

01:08:50.160 --> 01:08:51.870
information, you have ways of measuring

01:08:51.870 --> 01:08:54.050
the dependence of different variables,

01:08:54.050 --> 01:08:56.470
and you cluster the Features together

01:08:56.470 --> 01:08:58.280
based on their dependencies.

01:08:58.920 --> 01:09:00.430
And then for little clusters of

01:09:00.430 --> 01:09:02.149
Features, 3 Features.

01:09:03.060 --> 01:09:05.800
You Estimate the probability of the

01:09:05.800 --> 01:09:08.500
Joint combination of these features and

01:09:08.500 --> 01:09:11.230
then the total probability of all the

01:09:11.230 --> 01:09:11.620
Features.

01:09:11.620 --> 01:09:12.920
I'm glad this isn't worker.

01:09:12.920 --> 01:09:14.788
The total probability of all the

01:09:14.788 --> 01:09:16.660
features is the product of the

01:09:16.660 --> 01:09:18.270
probabilities of each of these groups

01:09:18.270 --> 01:09:18.840
of Features.

01:09:19.890 --> 01:09:21.140
And so you Model.

01:09:21.140 --> 01:09:23.616
Likely a set of features are given that

01:09:23.616 --> 01:09:25.270
it's a face, and how likely they are

01:09:25.270 --> 01:09:27.790
given that it's not a face or given a

01:09:27.790 --> 01:09:29.280
random patch from an image.

01:09:29.930 --> 01:09:32.260
And then that can be used to classify

01:09:32.260 --> 01:09:33.060
images as face.

01:09:33.060 --> 01:09:33.896
You're not face.

01:09:33.896 --> 01:09:35.560
And you would Estimate this separately

01:09:35.560 --> 01:09:37.120
for cars and for each orientation of

01:09:37.120 --> 01:09:38.110
car question.

01:09:43.310 --> 01:09:45.399
So the question was what beat the 2005

01:09:45.400 --> 01:09:45.840
model?

01:09:45.840 --> 01:09:47.750
I'm not really sure that there was

01:09:47.750 --> 01:09:50.180
something that beat it in 2006, but

01:09:50.180 --> 01:09:53.820
that when Dalal Triggs SVM based

01:09:53.820 --> 01:09:55.570
detector came out.

01:09:56.200 --> 01:09:57.680
And I think it might have been, I

01:09:57.680 --> 01:10:00.617
didn't look it up so I'm not sure, but

01:10:00.617 --> 01:10:02.930
I was, I'm pretty confident it was the

01:10:02.930 --> 01:10:04.947
most accurate up to 2005, but not

01:10:04.947 --> 01:10:06.070
confident after that.

01:10:07.250 --> 01:10:10.430
And now it took a while for face

01:10:10.430 --> 01:10:12.650
detection to get more accurate than

01:10:12.650 --> 01:10:15.630
most famous face detector was actually

01:10:15.630 --> 01:10:18.330
the Viola joins detector, which was

01:10:18.330 --> 01:10:20.515
popular because it was really fast.

01:10:20.515 --> 01:10:24.046
This thing man at a couple frames per

01:10:24.046 --> 01:10:26.414
second, but Viola Jones ran at 15

01:10:26.414 --> 01:10:28.560
frames per second in 2001.

01:10:30.310 --> 01:10:31.960
But Viola Jones wasn't quite as

01:10:31.960 --> 01:10:32.460
accurate.

01:10:35.210 --> 01:10:37.840
Alright, so Summary of Naive bees.

01:10:38.180 --> 01:10:38.790
And.

01:10:39.940 --> 01:10:41.740
So the key assumption is that the

01:10:41.740 --> 01:10:43.460
Features are independent given the

01:10:43.460 --> 01:10:43.870
labels.

01:10:46.730 --> 01:10:48.110
The parameters are just the

01:10:48.110 --> 01:10:50.173
probabilities, are the parameters of

01:10:50.173 --> 01:10:51.990
each of these probability functions,

01:10:51.990 --> 01:10:53.908
the probability of each feature given Y

01:10:53.908 --> 01:10:55.750
and probability of Y and justice.

01:10:55.750 --> 01:10:57.250
Like in the Simple fruit example I

01:10:57.250 --> 01:10:59.405
gave, you can use different models for

01:10:59.405 --> 01:10:59.976
different features.

01:10:59.976 --> 01:11:02.340
Some of the features could be discrete

01:11:02.340 --> 01:11:04.120
values and some could be continuous

01:11:04.120 --> 01:11:04.560
values.

01:11:04.560 --> 01:11:05.520
That's not a problem.

01:11:08.520 --> 01:11:10.150
You have to choose which probability

01:11:10.150 --> 01:11:11.510
function you're going to use for each

01:11:11.510 --> 01:11:11.940
feature.

01:11:14.450 --> 01:11:16.250
Nine days can be useful if you have

01:11:16.250 --> 01:11:18.080
limited training data, because you only

01:11:18.080 --> 01:11:19.560
have to Estimate these one-dimensional

01:11:19.560 --> 01:11:21.150
distributions, which you can do from

01:11:21.150 --> 01:11:22.370
relatively few Samples.

01:11:23.000 --> 01:11:24.420
And if the features are not highly

01:11:24.420 --> 01:11:26.540
interdependent, and it can also be

01:11:26.540 --> 01:11:27.970
useful as a baseline if you want

01:11:27.970 --> 01:11:29.766
something that's fast to code, train

01:11:29.766 --> 01:11:30.579
and test.

01:11:30.580 --> 01:11:32.900
So as you do your homework, I think out

01:11:32.900 --> 01:11:34.860
of the methods, Naive Bayes has the

01:11:34.860 --> 01:11:37.140
lowest training plus test time.

01:11:37.140 --> 01:11:40.139
Logistic regression is going to be

01:11:40.140 --> 01:11:42.618
roughly tied for test time, but it

01:11:42.618 --> 01:11:43.680
takes an awful lot.

01:11:43.680 --> 01:11:45.980
Well, it takes longer to train.

01:11:45.980 --> 01:11:48.379
KNN takes no time to train, but takes a

01:11:48.380 --> 01:11:49.570
whole lot longer to test.

01:11:54.630 --> 01:11:56.830
So when not to use?

01:11:56.830 --> 01:11:58.760
Usually Logistic or linear regression

01:11:58.760 --> 01:12:01.070
will work better if you have enough

01:12:01.070 --> 01:12:01.440
data.

01:12:02.230 --> 01:12:05.510
And the reason is that under most

01:12:05.510 --> 01:12:07.860
probability the exponential

01:12:07.860 --> 01:12:09.790
distribution of probability models

01:12:09.790 --> 01:12:11.940
which include Binomial, multinomial and

01:12:11.940 --> 01:12:12.530
Gaussian.

01:12:13.640 --> 01:12:15.657
You can rewrite Naive Bayes as a linear

01:12:15.657 --> 01:12:18.993
function of the input features, but the

01:12:18.993 --> 01:12:21.740
linear function is highly constrained

01:12:21.740 --> 01:12:23.750
based on this, estimating likelihoods

01:12:23.750 --> 01:12:25.650
for each feature separately.

01:12:25.650 --> 01:12:27.500
Where linear and logistic regression,

01:12:27.500 --> 01:12:28.970
which we'll talk about next Thursday,

01:12:28.970 --> 01:12:30.815
are not constrained, you can solve for

01:12:30.815 --> 01:12:32.300
the full range of coefficients.

01:12:33.440 --> 01:12:35.050
The other issue is that it doesn't

01:12:35.050 --> 01:12:37.890
provide a very good confidence Estimate

01:12:37.890 --> 01:12:39.720
because it over counts the influence of

01:12:39.720 --> 01:12:40.880
dependent variables.

01:12:40.880 --> 01:12:42.860
If you repeat a feature of many times,

01:12:42.860 --> 01:12:44.680
it's going to count it every time, and

01:12:44.680 --> 01:12:47.215
so it will tend to have too much weight

01:12:47.215 --> 01:12:48.930
and give you bad confidence estimates.

01:12:51.010 --> 01:12:55.100
9 Bayes is easy and fast to train, Fast

01:12:55.100 --> 01:12:56.130
for inference.

01:12:56.130 --> 01:12:57.400
You can use it with different kinds of

01:12:57.400 --> 01:12:58.040
variables.

01:12:58.040 --> 01:12:59.220
It doesn't account for feature

01:12:59.220 --> 01:13:00.730
interaction, doesn't provide good

01:13:00.730 --> 01:13:01.670
confidence estimates.

01:13:02.390 --> 01:13:04.210
And it's best when used with discrete

01:13:04.210 --> 01:13:06.270
variables, those that can be fit well

01:13:06.270 --> 01:13:08.830
by a Gaussian, or if you use kernel

01:13:08.830 --> 01:13:10.690
density estimation, which is something

01:13:10.690 --> 01:13:11.840
that we'll talk about later in this

01:13:11.840 --> 01:13:13.580
semester, a more general like

01:13:13.580 --> 01:13:15.080
continuous distribution function.

01:13:17.210 --> 01:13:19.560
And justice, as a reminder, don't pack

01:13:19.560 --> 01:13:21.730
up until I'm done, but this will be the

01:13:21.730 --> 01:13:22.570
second to last slide.

01:13:24.220 --> 01:13:25.890
So things remember.

01:13:27.140 --> 01:13:28.950
So Probabilistic models are really

01:13:28.950 --> 01:13:30.837
large class of machine learning

01:13:30.837 --> 01:13:31.160
methods.

01:13:31.160 --> 01:13:32.590
There are many different kinds of

01:13:32.590 --> 01:13:34.690
machine learning methods that are based

01:13:34.690 --> 01:13:36.480
on estimating the likelihoods of the

01:13:36.480 --> 01:13:38.170
label given the data or the data given

01:13:38.170 --> 01:13:38.730
the label.

01:13:39.580 --> 01:13:41.630
Naive Bayes assumes that Features are

01:13:41.630 --> 01:13:45.430
independent given the label, and it's

01:13:45.430 --> 01:13:46.860
easy and fast to estimate the

01:13:46.860 --> 01:13:48.920
parameters and reduces the risk of

01:13:48.920 --> 01:13:50.480
overfitting when you have limited data.

01:13:52.270 --> 01:13:52.590
It's.

01:13:52.590 --> 01:13:55.190
You don't usually have to derive how to

01:13:55.190 --> 01:13:57.910
solve for the likelihood parameters,

01:13:57.910 --> 01:13:59.660
but you can do it if you want to by

01:13:59.660 --> 01:14:00.954
taking the partial derivative.

01:14:00.954 --> 01:14:03.540
Usually it's usually you would be using

01:14:03.540 --> 01:14:06.140
a common a common kind of Model and you

01:14:06.140 --> 01:14:07.290
can just look up the Emily.

01:14:09.490 --> 01:14:11.160
The Prediction involves finding the way

01:14:11.160 --> 01:14:13.190
that maximizes the probability of the

01:14:13.190 --> 01:14:15.150
data and the label, either by trying

01:14:15.150 --> 01:14:17.250
all the possible values of Y or solving

01:14:17.250 --> 01:14:18.230
the partial derivative.

01:14:19.270 --> 01:14:21.535
And finally, Maximizing log probability

01:14:21.535 --> 01:14:24.060
of I is equivalent to Maximizing

01:14:24.060 --> 01:14:25.360
probability of.

01:14:25.520 --> 01:14:27.310
Sorry, Maximizing log probability of

01:14:27.310 --> 01:14:30.270
X&Y is equivalent to maximizing the

01:14:30.270 --> 01:14:32.250
probability of X&Y, and it's usually

01:14:32.250 --> 01:14:34.000
much easier, so it's important to

01:14:34.000 --> 01:14:34.390
remember that.

01:14:35.970 --> 01:14:36.180
Right.

01:14:36.180 --> 01:14:37.840
And then next class I'm going to talk

01:14:37.840 --> 01:14:40.030
about logistic regression and linear

01:14:40.030 --> 01:14:40.700
regression.

01:14:41.530 --> 01:14:44.870
And one more thing is I posted a review

01:14:44.870 --> 01:14:49.310
questions and answers to the 1st 2

01:14:49.310 --> 01:14:51.440
cannon and this lecture on the web

01:14:51.440 --> 01:14:52.050
page.

01:14:52.050 --> 01:14:53.690
You don't have to do them but they're

01:14:53.690 --> 01:14:55.410
good review for the exam or just the

01:14:55.410 --> 01:14:56.820
check your knowledge after each

01:14:56.820 --> 01:14:57.200
lecture.

01:14:57.890 --> 01:14:58.750
Thank you.

01:15:11.030 --> 01:15:11.320
I.