diff --git a/doc/LectureNotes/DataFiles/bank.csv b/doc/LectureNotes/DataFiles/bank.csv new file mode 100644 index 000000000..930337395 --- /dev/null +++ b/doc/LectureNotes/DataFiles/bank.csv @@ -0,0 +1,1372 @@ +3.6216,8.6661,-2.8073,-0.44699,0 +4.5459,8.1674,-2.4586,-1.4621,0 +3.866,-2.6383,1.9242,0.10645,0 +3.4566,9.5228,-4.0112,-3.5944,0 +0.32924,-4.4552,4.5718,-0.9888,0 +4.3684,9.6718,-3.9606,-3.1625,0 +3.5912,3.0129,0.72888,0.56421,0 +2.0922,-6.81,8.4636,-0.60216,0 +3.2032,5.7588,-0.75345,-0.61251,0 +1.5356,9.1772,-2.2718,-0.73535,0 +1.2247,8.7779,-2.2135,-0.80647,0 +3.9899,-2.7066,2.3946,0.86291,0 +1.8993,7.6625,0.15394,-3.1108,0 +-1.5768,10.843,2.5462,-2.9362,0 +3.404,8.7261,-2.9915,-0.57242,0 +4.6765,-3.3895,3.4896,1.4771,0 +2.6719,3.0646,0.37158,0.58619,0 +0.80355,2.8473,4.3439,0.6017,0 +1.4479,-4.8794,8.3428,-2.1086,0 +5.2423,11.0272,-4.353,-4.1013,0 +5.7867,7.8902,-2.6196,-0.48708,0 +0.3292,-4.4552,4.5718,-0.9888,0 +3.9362,10.1622,-3.8235,-4.0172,0 +0.93584,8.8855,-1.6831,-1.6599,0 +4.4338,9.887,-4.6795,-3.7483,0 +0.7057,-5.4981,8.3368,-2.8715,0 +1.1432,-3.7413,5.5777,-0.63578,0 +-0.38214,8.3909,2.1624,-3.7405,0 +6.5633,9.8187,-4.4113,-3.2258,0 +4.8906,-3.3584,3.4202,1.0905,0 +-0.24811,-0.17797,4.9068,0.15429,0 +1.4884,3.6274,3.308,0.48921,0 +4.2969,7.617,-2.3874,-0.96164,0 +-0.96511,9.4111,1.7305,-4.8629,0 +-1.6162,0.80908,8.1628,0.60817,0 +2.4391,6.4417,-0.80743,-0.69139,0 +2.6881,6.0195,-0.46641,-0.69268,0 +3.6289,0.81322,1.6277,0.77627,0 +4.5679,3.1929,-2.1055,0.29653,0 +3.4805,9.7008,-3.7541,-3.4379,0 +4.1711,8.722,-3.0224,-0.59699,0 +-0.2062,9.2207,-3.7044,-6.8103,0 +-0.0068919,9.2931,-0.41243,-1.9638,0 +0.96441,5.8395,2.3235,0.066365,0 +2.8561,6.9176,-0.79372,0.48403,0 +-0.7869,9.5663,-3.7867,-7.5034,0 +2.0843,6.6258,0.48382,-2.2134,0 +-0.7869,9.5663,-3.7867,-7.5034,0 +3.9102,6.065,-2.4534,-0.68234,0 +1.6349,3.286,2.8753,0.087054,0 +4.3239,-4.8835,3.4356,-0.5776,0 +5.262,3.9834,-1.5572,1.0103,0 +3.1452,5.825,-0.51439,-1.4944,0 +2.549,6.1499,-1.1605,-1.2371,0 +4.9264,5.496,-2.4774,-0.50648,0 +4.8265,0.80287,1.6371,1.1875,0 +2.5635,6.7769,-0.61979,0.38576,0 +5.807,5.0097,-2.2384,0.43878,0 +3.1377,-4.1096,4.5701,0.98963,0 +-0.78289,11.3603,-0.37644,-7.0495,0 +2.888,0.44696,4.5907,-0.24398,0 +0.49665,5.527,1.7785,-0.47156,0 +4.2586,11.2962,-4.0943,-4.3457,0 +1.7939,-1.1174,1.5454,-0.26079,0 +5.4021,3.1039,-1.1536,1.5651,0 +2.5367,2.599,2.0938,0.20085,0 +4.6054,-4.0765,2.7587,0.31981,0 +2.4235,9.5332,-3.0789,-2.7746,0 +1.0009,7.7846,-0.28219,-2.6608,0 +0.12326,8.9848,-0.9351,-2.4332,0 +3.9529,-2.3548,2.3792,0.48274,0 +4.1373,0.49248,1.093,1.8276,0 +4.7181,10.0153,-3.9486,-3.8582,0 +4.1654,-3.4495,3.643,1.0879,0 +4.4069,10.9072,-4.5775,-4.4271,0 +2.3066,3.5364,0.57551,0.41938,0 +3.7935,7.9853,-2.5477,-1.872,0 +0.049175,6.1437,1.7828,-0.72113,0 +0.24835,7.6439,0.9885,-0.87371,0 +1.1317,3.9647,3.3979,0.84351,0 +2.8033,9.0862,-3.3668,-1.0224,0 +4.4682,2.2907,0.95766,0.83058,0 +5.0185,8.5978,-2.9375,-1.281,0 +1.8664,7.7763,-0.23849,-2.9634,0 +3.245,6.63,-0.63435,0.86937,0 +4.0296,2.6756,0.80685,0.71679,0 +-1.1313,1.9037,7.5339,1.022,0 +0.87603,6.8141,0.84198,-0.17156,0 +4.1197,-2.7956,2.0707,0.67412,0 +3.8027,0.81529,2.1041,1.0245,0 +1.4806,7.6377,-2.7876,-1.0341,0 +4.0632,3.584,0.72545,0.39481,0 +4.3064,8.2068,-2.7824,-1.4336,0 +2.4486,-6.3175,7.9632,0.20602,0 +3.2718,1.7837,2.1161,0.61334,0 +-0.64472,-4.6062,8.347,-2.7099,0 +2.9543,1.076,0.64577,0.89394,0 +2.1616,-6.8804,8.1517,-0.081048,0 +3.82,10.9279,-4.0112,-5.0284,0 +-2.7419,11.4038,2.5394,-5.5793,0 +3.3669,-5.1856,3.6935,-1.1427,0 +4.5597,-2.4211,2.6413,1.6168,0 +5.1129,-0.49871,0.62863,1.1189,0 +3.3397,-4.6145,3.9823,-0.23751,0 +4.2027,0.22761,0.96108,0.97282,0 +3.5438,1.2395,1.997,2.1547,0 +2.3136,10.6651,-3.5288,-4.7672,0 +-1.8584,7.886,-1.6643,-1.8384,0 +3.106,9.5414,-4.2536,-4.003,0 +2.9163,10.8306,-3.3437,-4.122,0 +3.9922,-4.4676,3.7304,-0.1095,0 +1.518,5.6946,0.094818,-0.026738,0 +3.2351,9.647,-3.2074,-2.5948,0 +4.2188,6.8162,-1.2804,0.76076,0 +1.7819,6.9176,-1.2744,-1.5759,0 +2.5331,2.9135,-0.822,-0.12243,0 +3.8969,7.4163,-1.8245,0.14007,0 +2.108,6.7955,-0.1708,0.4905,0 +2.8969,0.70768,2.29,1.8663,0 +0.9297,-3.7971,4.6429,-0.2957,0 +3.4642,10.6878,-3.4071,-4.109,0 +4.0713,10.4023,-4.1722,-4.7582,0 +-1.4572,9.1214,1.7425,-5.1241,0 +-1.5075,1.9224,7.1466,0.89136,0 +-0.91718,9.9884,1.1804,-5.2263,0 +2.994,7.2011,-1.2153,0.3211,0 +-2.343,12.9516,3.3285,-5.9426,0 +3.7818,-2.8846,2.2558,-0.15734,0 +4.6689,1.3098,0.055404,1.909,0 +3.4663,1.1112,1.7425,1.3388,0 +3.2697,-4.3414,3.6884,-0.29829,0 +5.1302,8.6703,-2.8913,-1.5086,0 +2.0139,6.1416,0.37929,0.56938,0 +0.4339,5.5395,2.033,-0.40432,0 +-1.0401,9.3987,0.85998,-5.3336,0 +4.1605,11.2196,-3.6136,-4.0819,0 +5.438,9.4669,-4.9417,-3.9202,0 +5.032,8.2026,-2.6256,-1.0341,0 +5.2418,10.5388,-4.1174,-4.2797,0 +-0.2062,9.2207,-3.7044,-6.8103,0 +2.0911,0.94358,4.5512,1.234,0 +1.7317,-0.34765,4.1905,-0.99138,0 +4.1736,3.3336,-1.4244,0.60429,0 +3.9232,-3.2467,3.4579,0.83705,0 +3.8481,10.1539,-3.8561,-4.2228,0 +0.5195,-3.2633,3.0895,-0.9849,0 +3.8584,0.78425,1.1033,1.7008,0 +1.7496,-0.1759,5.1827,1.2922,0 +3.6277,0.9829,0.68861,0.63403,0 +2.7391,7.4018,0.071684,-2.5302,0 +4.5447,8.2274,-2.4166,-1.5875,0 +-1.7599,11.9211,2.6756,-3.3241,0 +5.0691,0.21313,0.20278,1.2095,0 +3.4591,11.112,-4.2039,-5.0931,0 +1.9358,8.1654,-0.023425,-2.2586,0 +2.486,-0.99533,5.3404,-0.15475,0 +2.4226,-4.5752,5.947,0.21507,0 +3.9479,-3.7723,2.883,0.019813,0 +2.2634,-4.4862,3.6558,-0.61251,0 +1.3566,4.2358,2.1341,0.3211,0 +5.0452,3.8964,-1.4304,0.86291,0 +3.5499,8.6165,-3.2794,-1.2009,0 +0.17346,7.8695,0.26876,-3.7883,0 +2.4008,9.3593,-3.3565,-3.3526,0 +4.8851,1.5995,-0.00029081,1.6401,0 +4.1927,-3.2674,2.5839,0.21766,0 +1.1166,8.6496,-0.96252,-1.8112,0 +1.0235,6.901,-2.0062,-2.7125,0 +-1.803,11.8818,2.0458,-5.2728,0 +0.11739,6.2761,-1.5495,-2.4746,0 +0.5706,-0.0248,1.2421,-0.5621,0 +4.0552,-2.4583,2.2806,1.0323,0 +-1.6952,1.0657,8.8294,0.94955,0 +-1.1193,10.7271,2.0938,-5.6504,0 +1.8799,2.4707,2.4931,0.37671,0 +3.583,-3.7971,3.4391,-0.12501,0 +0.19081,9.1297,-3.725,-5.8224,0 +3.6582,5.6864,-1.7157,-0.23751,0 +-0.13144,-1.7775,8.3316,0.35214,0 +2.3925,9.798,-3.0361,-2.8224,0 +1.6426,3.0149,0.22849,-0.147,0 +-0.11783,-1.5789,8.03,-0.028031,0 +-0.69572,8.6165,1.8419,-4.3289,0 +2.9421,7.4101,-0.97709,-0.88406,0 +-1.7559,11.9459,3.0946,-4.8978,0 +-1.2537,10.8803,1.931,-4.3237,0 +3.2585,-4.4614,3.8024,-0.15087,0 +1.8314,6.3672,-0.036278,0.049554,0 +4.5645,-3.6275,2.8684,0.27714,0 +2.7365,-5.0325,6.6608,-0.57889,0 +0.9297,-3.7971,4.6429,-0.2957,0 +3.9663,10.1684,-4.1131,-4.6056,0 +1.4578,-0.08485,4.1785,0.59136,0 +4.8272,3.0687,0.68604,0.80731,0 +-2.341,12.3784,0.70403,-7.5836,0 +-1.8584,7.886,-1.6643,-1.8384,0 +4.1454,7.257,-1.9153,-0.86078,0 +1.9157,6.0816,0.23705,-2.0116,0 +4.0215,-2.1914,2.4648,1.1409,0 +5.8862,5.8747,-2.8167,-0.30087,0 +-2.0897,10.8265,2.3603,-3.4198,0 +4.0026,-3.5943,3.5573,0.26809,0 +-0.78689,9.5663,-3.7867,-7.5034,0 +4.1757,10.2615,-3.8552,-4.3056,0 +0.83292,7.5404,0.65005,-0.92544,0 +4.8077,2.2327,-0.26334,1.5534,0 +5.3063,5.2684,-2.8904,-0.52716,0 +2.5605,9.2683,-3.5913,-1.356,0 +2.1059,7.6046,-0.47755,-1.8461,0 +2.1721,-0.73874,5.4672,-0.72371,0 +4.2899,9.1814,-4.6067,-4.3263,0 +3.5156,10.1891,-4.2759,-4.978,0 +2.614,8.0081,-3.7258,-1.3069,0 +0.68087,2.3259,4.9085,0.54998,0 +4.1962,0.74493,0.83256,0.753,0 +6.0919,2.9673,-1.3267,1.4551,0 +1.3234,3.2964,0.2362,-0.11984,0 +1.3264,1.0326,5.6566,-0.41337,0 +-0.16735,7.6274,1.2061,-3.6241,0 +-1.3,10.2678,-2.953,-5.8638,0 +-2.2261,12.5398,2.9438,-3.5258,0 +2.4196,6.4665,-0.75688,0.228,0 +1.0987,0.6394,5.989,-0.58277,0 +4.6464,10.5326,-4.5852,-4.206,0 +-0.36038,4.1158,3.1143,-0.37199,0 +1.3562,3.2136,4.3465,0.78662,0 +0.5706,-0.0248,1.2421,-0.5621,0 +-2.6479,10.1374,-1.331,-5.4707,0 +3.1219,-3.137,1.9259,-0.37458,0 +5.4944,1.5478,0.041694,1.9284,0 +-1.3389,1.552,7.0806,1.031,0 +-2.3361,11.9604,3.0835,-5.4435,0 +2.2596,-0.033118,4.7355,-0.2776,0 +0.46901,-0.63321,7.3848,0.36507,0 +2.7296,2.8701,0.51124,0.5099,0 +2.0466,2.03,2.1761,-0.083634,0 +-1.3274,9.498,2.4408,-5.2689,0 +3.8905,-2.1521,2.6302,1.1047,0 +3.9994,0.90427,1.1693,1.6892,0 +2.3952,9.5083,-3.1783,-3.0086,0 +3.2704,6.9321,-1.0456,0.23447,0 +-1.3931,1.5664,7.5382,0.78403,0 +1.6406,3.5488,1.3964,-0.36424,0 +2.7744,6.8576,-1.0671,0.075416,0 +2.4287,9.3821,-3.2477,-1.4543,0 +4.2134,-2.806,2.0116,0.67412,0 +1.6472,0.48213,4.7449,1.225,0 +2.0597,-0.99326,5.2119,-0.29312,0 +0.3798,0.7098,0.7572,-0.4444,0 +1.0135,8.4551,-1.672,-2.0815,0 +4.5691,-4.4552,3.1769,0.0042961,0 +0.57461,10.1105,-1.6917,-4.3922,0 +0.5734,9.1938,-0.9094,-1.872,0 +5.2868,3.257,-1.3721,1.1668,0 +4.0102,10.6568,-4.1388,-5.0646,0 +4.1425,-3.6792,3.8281,1.6297,0 +3.0934,-2.9177,2.2232,0.22283,0 +2.2034,5.9947,0.53009,0.84998,0 +3.744,0.79459,0.95851,1.0077,0 +3.0329,2.2948,2.1135,0.35084,0 +3.7731,7.2073,-1.6814,-0.94742,0 +3.1557,2.8908,0.59693,0.79825,0 +1.8114,7.6067,-0.9788,-2.4668,0 +4.988,7.2052,-3.2846,-1.1608,0 +2.483,6.6155,-0.79287,-0.90863,0 +1.594,4.7055,1.3758,0.081882,0 +-0.016103,9.7484,0.15394,-1.6134,0 +3.8496,9.7939,-4.1508,-4.4582,0 +0.9297,-3.7971,4.6429,-0.2957,0 +4.9342,2.4107,-0.17594,1.6245,0 +3.8417,10.0215,-4.2699,-4.9159,0 +5.3915,9.9946,-3.8081,-3.3642,0 +4.4072,-0.070365,2.0416,1.1319,0 +2.6946,6.7976,-0.40301,0.44912,0 +5.2756,0.13863,0.12138,1.1435,0 +3.4312,6.2637,-1.9513,-0.36165,0 +4.052,-0.16555,0.45383,0.51248,0 +1.3638,-4.7759,8.4182,-1.8836,0 +0.89566,7.7763,-2.7473,-1.9353,0 +1.9265,7.7557,-0.16823,-3.0771,0 +0.20977,-0.46146,7.7267,0.90946,0 +4.068,-2.9363,2.1992,0.50084,0 +2.877,-4.0599,3.6259,-0.32544,0 +0.3223,-0.89808,8.0883,0.69222,0 +-1.3,10.2678,-2.953,-5.8638,0 +1.7747,-6.4334,8.15,-0.89828,0 +1.3419,-4.4221,8.09,-1.7349,0 +0.89606,10.5471,-1.4175,-4.0327,0 +0.44125,2.9487,4.3225,0.7155,0 +3.2422,6.2265,0.12224,-1.4466,0 +2.5678,3.5136,0.61406,-0.40691,0 +-2.2153,11.9625,0.078538,-7.7853,0 +4.1349,6.1189,-2.4294,-0.19613,0 +1.934,-9.2828e-06,4.816,-0.33967,0 +2.5068,1.1588,3.9249,0.12585,0 +2.1464,6.0795,-0.5778,-2.2302,0 +0.051979,7.0521,-2.0541,-3.1508,0 +1.2706,8.035,-0.19651,-2.1888,0 +1.143,0.83391,5.4552,-0.56984,0 +2.2928,9.0386,-3.2417,-1.2991,0 +0.3292,-4.4552,4.5718,-0.9888,0 +2.9719,6.8369,-0.2702,0.71291,0 +1.6849,8.7489,-1.2641,-1.3858,0 +-1.9177,11.6894,2.5454,-3.2763,0 +2.3729,10.4726,-3.0087,-3.2013,0 +1.0284,9.767,-1.3687,-1.7853,0 +0.27451,9.2186,-3.2863,-4.8448,0 +1.6032,-4.7863,8.5193,-2.1203,0 +4.616,10.1788,-4.2185,-4.4245,0 +4.2478,7.6956,-2.7696,-1.0767,0 +4.0215,-2.7004,2.4957,0.36636,0 +5.0297,-4.9704,3.5025,-0.23751,0 +1.5902,2.2948,3.2403,0.18404,0 +2.1274,5.1939,-1.7971,-1.1763,0 +1.1811,8.3847,-2.0567,-0.90345,0 +0.3292,-4.4552,4.5718,-0.9888,0 +5.7353,5.2808,-2.2598,0.075416,0 +2.6718,5.6574,0.72974,-1.4892,0 +1.5799,-4.7076,7.9186,-1.5487,0 +2.9499,2.2493,1.3458,-0.037083,0 +0.5195,-3.2633,3.0895,-0.9849,0 +3.7352,9.5911,-3.9032,-3.3487,0 +-1.7344,2.0175,7.7618,0.93532,0 +3.884,10.0277,-3.9298,-4.0819,0 +3.5257,1.2829,1.9276,1.7991,0 +4.4549,2.4976,1.0313,0.96894,0 +-0.16108,-6.4624,8.3573,-1.5216,0 +4.2164,9.4607,-4.9288,-5.2366,0 +3.5152,6.8224,-0.67377,-0.46898,0 +1.6988,2.9094,2.9044,0.11033,0 +1.0607,2.4542,2.5188,-0.17027,0 +2.0421,1.2436,4.2171,0.90429,0 +3.5594,1.3078,1.291,1.6556,0 +3.0009,5.8126,-2.2306,-0.66553,0 +3.9294,1.4112,1.8076,0.89782,0 +3.4667,-4.0724,4.2882,1.5418,0 +3.966,3.9213,0.70574,0.33662,0 +1.0191,2.33,4.9334,0.82929,0 +0.96414,5.616,2.2138,-0.12501,0 +1.8205,6.7562,0.0099913,0.39481,0 +4.9923,7.8653,-2.3515,-0.71984,0 +-1.1804,11.5093,0.15565,-6.8194,0 +4.0329,0.23175,0.89082,1.1823,0 +0.66018,10.3878,-1.4029,-3.9151,0 +3.5982,7.1307,-1.3035,0.21248,0 +-1.8584,7.886,-1.6643,-1.8384,0 +4.0972,0.46972,1.6671,0.91593,0 +3.3299,0.91254,1.5806,0.39352,0 +3.1088,3.1122,0.80857,0.4336,0 +-4.2859,8.5234,3.1392,-0.91639,0 +-1.2528,10.2036,2.1787,-5.6038,0 +0.5195,-3.2633,3.0895,-0.9849,0 +0.3292,-4.4552,4.5718,-0.9888,0 +0.88872,5.3449,2.045,-0.19355,0 +3.5458,9.3718,-4.0351,-3.9564,0 +-0.21661,8.0329,1.8848,-3.8853,0 +2.7206,9.0821,-3.3111,-0.96811,0 +3.2051,8.6889,-2.9033,-0.7819,0 +2.6917,10.8161,-3.3,-4.2888,0 +-2.3242,11.5176,1.8231,-5.375,0 +2.7161,-4.2006,4.1914,0.16981,0 +3.3848,3.2674,0.90967,0.25128,0 +1.7452,4.8028,2.0878,0.62627,0 +2.805,0.57732,1.3424,1.2133,0 +5.7823,5.5788,-2.4089,-0.056479,0 +3.8999,1.734,1.6011,0.96765,0 +3.5189,6.332,-1.7791,-0.020273,0 +3.2294,7.7391,-0.37816,-2.5405,0 +3.4985,3.1639,0.22677,-0.1651,0 +2.1948,1.3781,1.1582,0.85774,0 +2.2526,9.9636,-3.1749,-2.9944,0 +4.1529,-3.9358,2.8633,-0.017686,0 +0.74307,11.17,-1.3824,-4.0728,0 +1.9105,8.871,-2.3386,-0.75604,0 +-1.5055,0.070346,6.8681,-0.50648,0 +0.58836,10.7727,-1.3884,-4.3276,0 +3.2303,7.8384,-3.5348,-1.2151,0 +-1.9922,11.6542,2.6542,-5.2107,0 +2.8523,9.0096,-3.761,-3.3371,0 +4.2772,2.4955,0.48554,0.36119,0 +1.5099,0.039307,6.2332,-0.30346,0 +5.4188,10.1457,-4.084,-3.6991,0 +0.86202,2.6963,4.2908,0.54739,0 +3.8117,10.1457,-4.0463,-4.5629,0 +0.54777,10.3754,-1.5435,-4.1633,0 +2.3718,7.4908,0.015989,-1.7414,0 +-2.4953,11.1472,1.9353,-3.4638,0 +4.6361,-2.6611,2.8358,1.1991,0 +-2.2527,11.5321,2.5899,-3.2737,0 +3.7982,10.423,-4.1602,-4.9728,0 +-0.36279,8.2895,-1.9213,-3.3332,0 +2.1265,6.8783,0.44784,-2.2224,0 +0.86736,5.5643,1.6765,-0.16769,0 +3.7831,10.0526,-3.8869,-3.7366,0 +-2.2623,12.1177,0.28846,-7.7581,0 +1.2616,4.4303,-1.3335,-1.7517,0 +2.6799,3.1349,0.34073,0.58489,0 +-0.39816,5.9781,1.3912,-1.1621,0 +4.3937,0.35798,2.0416,1.2004,0 +2.9695,5.6222,0.27561,-1.1556,0 +1.3049,-0.15521,6.4911,-0.75346,0 +2.2123,-5.8395,7.7687,-0.85302,0 +1.9647,6.9383,0.57722,0.66377,0 +3.0864,-2.5845,2.2309,0.30947,0 +0.3798,0.7098,0.7572,-0.4444,0 +0.58982,7.4266,1.2353,-2.9595,0 +0.14783,7.946,1.0742,-3.3409,0 +-0.062025,6.1975,1.099,-1.131,0 +4.223,1.1319,0.72202,0.96118,0 +0.64295,7.1018,0.3493,-0.41337,0 +1.941,0.46351,4.6472,1.0879,0 +4.0047,0.45937,1.3621,1.6181,0 +3.7767,9.7794,-3.9075,-3.5323,0 +3.4769,-0.15314,2.53,2.4495,0 +1.9818,9.2621,-3.521,-1.872,0 +3.8023,-3.8696,4.044,0.95343,0 +4.3483,11.1079,-4.0857,-4.2539,0 +1.1518,1.3864,5.2727,-0.43536,0 +-1.2576,1.5892,7.0078,0.42455,0 +1.9572,-5.1153,8.6127,-1.4297,0 +-2.484,12.1611,2.8204,-3.7418,0 +-1.1497,1.2954,7.701,0.62627,0 +4.8368,10.0132,-4.3239,-4.3276,0 +-0.12196,8.8068,0.94566,-4.2267,0 +1.9429,6.3961,0.092248,0.58102,0 +1.742,-4.809,8.2142,-2.0659,0 +-1.5222,10.8409,2.7827,-4.0974,0 +-1.3,10.2678,-2.953,-5.8638,0 +3.4246,-0.14693,0.80342,0.29136,0 +2.5503,-4.9518,6.3729,-0.41596,0 +1.5691,6.3465,-0.1828,-2.4099,0 +1.3087,4.9228,2.0013,0.22024,0 +5.1776,8.2316,-3.2511,-1.5694,0 +2.229,9.6325,-3.1123,-2.7164,0 +5.6272,10.0857,-4.2931,-3.8142,0 +1.2138,8.7986,-2.1672,-0.74182,0 +0.3798,0.7098,0.7572,-0.4444,0 +0.5415,6.0319,1.6825,-0.46122,0 +4.0524,5.6802,-1.9693,0.026279,0 +4.7285,2.1065,-0.28305,1.5625,0 +3.4359,0.66216,2.1041,1.8922,0 +0.86816,10.2429,-1.4912,-4.0082,0 +3.359,9.8022,-3.8209,-3.7133,0 +3.6702,2.9942,0.85141,0.30688,0 +1.3349,6.1189,0.46497,0.49826,0 +3.1887,-3.4143,2.7742,-0.2026,0 +2.4527,2.9653,0.20021,-0.056479,0 +3.9121,2.9735,0.92852,0.60558,0 +3.9364,10.5885,-3.725,-4.3133,0 +3.9414,-3.2902,3.1674,1.0866,0 +3.6922,-3.9585,4.3439,1.3517,0 +5.681,7.795,-2.6848,-0.92544,0 +0.77124,9.0862,-1.2281,-1.4996,0 +3.5761,9.7753,-3.9795,-3.4638,0 +1.602,6.1251,0.52924,0.47886,0 +2.6682,10.216,-3.4414,-4.0069,0 +2.0007,1.8644,2.6491,0.47369,0 +0.64215,3.1287,4.2933,0.64696,0 +4.3848,-3.0729,3.0423,1.2741,0 +0.77445,9.0552,-2.4089,-1.3884,0 +0.96574,8.393,-1.361,-1.4659,0 +3.0948,8.7324,-2.9007,-0.96682,0 +4.9362,7.6046,-2.3429,-0.85302,0 +-1.9458,11.2217,1.9079,-3.4405,0 +5.7403,-0.44284,0.38015,1.3763,0 +-2.6989,12.1984,0.67661,-8.5482,0 +1.1472,3.5985,1.9387,-0.43406,0 +2.9742,8.96,-2.9024,-1.0379,0 +4.5707,7.2094,-3.2794,-1.4944,0 +0.1848,6.5079,2.0133,-0.87242,0 +0.87256,9.2931,-0.7843,-2.1978,0 +0.39559,6.8866,1.0588,-0.67587,0 +3.8384,6.1851,-2.0439,-0.033204,0 +2.8209,7.3108,-0.81857,-1.8784,0 +2.5817,9.7546,-3.1749,-2.9957,0 +3.8213,0.23175,2.0133,2.0564,0 +0.3798,0.7098,0.7572,-0.4444,0 +3.4893,6.69,-1.2042,-0.38751,0 +-1.7781,0.8546,7.1303,0.027572,0 +2.0962,2.4769,1.9379,-0.040962,0 +0.94732,-0.57113,7.1903,-0.67587,0 +2.8261,9.4007,-3.3034,-1.0509,0 +0.0071249,8.3661,0.50781,-3.8155,0 +0.96788,7.1907,1.2798,-2.4565,0 +4.7432,2.1086,0.1368,1.6543,0 +3.6575,7.2797,-2.2692,-1.144,0 +3.8832,6.4023,-2.432,-0.98363,0 +3.4776,8.811,-3.1886,-0.92285,0 +1.1315,7.9212,1.093,-2.8444,0 +2.8237,2.8597,0.19678,0.57196,0 +1.9321,6.0423,0.26019,-2.053,0 +3.0632,-3.3315,5.1305,0.8267,0 +-1.8411,10.8306,2.769,-3.0901,0 +2.8084,11.3045,-3.3394,-4.4194,0 +2.5698,-4.4076,5.9856,0.078002,0 +-0.12624,10.3216,-3.7121,-6.1185,0 +3.3756,-4.0951,4.367,1.0698,0 +-0.048008,-1.6037,8.4756,0.75558,0 +0.5706,-0.0248,1.2421,-0.5621,0 +0.88444,6.5906,0.55837,-0.44182,0 +3.8644,3.7061,0.70403,0.35214,0 +1.2999,2.5762,2.0107,-0.18967,0 +2.0051,-6.8638,8.132,-0.2401,0 +4.9294,0.27727,0.20792,0.33662,0 +2.8297,6.3485,-0.73546,-0.58665,0 +2.565,8.633,-2.9941,-1.3082,0 +2.093,8.3061,0.022844,-3.2724,0 +4.6014,5.6264,-2.1235,0.19309,0 +5.0617,-0.35799,0.44698,0.99868,0 +-0.2951,9.0489,-0.52725,-2.0789,0 +3.577,2.4004,1.8908,0.73231,0 +3.9433,2.5017,1.5215,0.903,0 +2.6648,10.754,-3.3994,-4.1685,0 +5.9374,6.1664,-2.5905,-0.36553,0 +2.0153,1.8479,3.1375,0.42843,0 +5.8782,5.9409,-2.8544,-0.60863,0 +-2.3983,12.606,2.9464,-5.7888,0 +1.762,4.3682,2.1384,0.75429,0 +4.2406,-2.4852,1.608,0.7155,0 +3.4669,6.87,-1.0568,-0.73147,0 +3.1896,5.7526,-0.18537,-0.30087,0 +0.81356,9.1566,-2.1492,-4.1814,0 +0.52855,0.96427,4.0243,-1.0483,0 +2.1319,-2.0403,2.5574,-0.061652,0 +0.33111,4.5731,2.057,-0.18967,0 +1.2746,8.8172,-1.5323,-1.7957,0 +2.2091,7.4556,-1.3284,-3.3021,0 +2.5328,7.528,-0.41929,-2.6478,0 +3.6244,1.4609,1.3501,1.9284,0 +-1.3885,12.5026,0.69118,-7.5487,0 +5.7227,5.8312,-2.4097,-0.24527,0 +3.3583,10.3567,-3.7301,-3.6991,0 +2.5227,2.2369,2.7236,0.79438,0 +0.045304,6.7334,1.0708,-0.9332,0 +4.8278,7.7598,-2.4491,-1.2216,0 +1.9476,-4.7738,8.527,-1.8668,0 +2.7659,0.66216,4.1494,-0.28406,0 +-0.10648,-0.76771,7.7575,0.64179,0 +0.72252,-0.053811,5.6703,-1.3509,0 +4.2475,1.4816,-0.48355,0.95343,0 +3.9772,0.33521,2.2566,2.1625,0 +3.6667,4.302,0.55923,0.33791,0 +2.8232,10.8513,-3.1466,-3.9784,0 +-1.4217,11.6542,-0.057699,-7.1025,0 +4.2458,1.1981,0.66633,0.94696,0 +4.1038,-4.8069,3.3491,-0.49225,0 +1.4507,8.7903,-2.2324,-0.65259,0 +3.4647,-3.9172,3.9746,0.36119,0 +1.8533,6.1458,1.0176,-2.0401,0 +3.5288,0.71596,1.9507,1.9375,0 +3.9719,1.0367,0.75973,1.0013,0 +3.534,9.3614,-3.6316,-1.2461,0 +3.6894,9.887,-4.0788,-4.3664,0 +3.0672,-4.4117,3.8238,-0.81682,0 +2.6463,-4.8152,6.3549,0.003003,0 +2.2893,3.733,0.6312,-0.39786,0 +1.5673,7.9274,-0.056842,-2.1694,0 +4.0405,0.51524,1.0279,1.106,0 +4.3846,-4.8794,3.3662,-0.029324,0 +2.0165,-0.25246,5.1707,1.0763,0 +4.0446,11.1741,-4.3582,-4.7401,0 +-0.33729,-0.64976,7.6659,0.72326,0 +-2.4604,12.7302,0.91738,-7.6418,0 +4.1195,10.9258,-3.8929,-4.1802,0 +2.0193,0.82356,4.6369,1.4202,0 +1.5701,7.9129,0.29018,-2.1953,0 +2.6415,7.586,-0.28562,-1.6677,0 +5.0214,8.0764,-3.0515,-1.7155,0 +4.3435,3.3295,0.83598,0.64955,0 +1.8238,-6.7748,8.3873,-0.54139,0 +3.9382,0.9291,0.78543,0.6767,0 +2.2517,-5.1422,4.2916,-1.2487,0 +5.504,10.3671,-4.413,-4.0211,0 +2.8521,9.171,-3.6461,-1.2047,0 +1.1676,9.1566,-2.0867,-0.80647,0 +2.6104,8.0081,-0.23592,-1.7608,0 +0.32444,10.067,-1.1982,-4.1284,0 +3.8962,-4.7904,3.3954,-0.53751,0 +2.1752,-0.8091,5.1022,-0.67975,0 +1.1588,8.9331,-2.0807,-1.1272,0 +4.7072,8.2957,-2.5605,-1.4905,0 +-1.9667,11.8052,-0.40472,-7.8719,0 +4.0552,0.40143,1.4563,0.65343,0 +2.3678,-6.839,8.4207,-0.44829,0 +0.33565,6.8369,0.69718,-0.55691,0 +4.3398,-5.3036,3.8803,-0.70432,0 +1.5456,8.5482,0.4187,-2.1784,0 +1.4276,8.3847,-2.0995,-1.9677,0 +-0.27802,8.1881,-3.1338,-2.5276,0 +0.93611,8.6413,-1.6351,-1.3043,0 +4.6352,-3.0087,2.6773,1.212,0 +1.5268,-5.5871,8.6564,-1.722,0 +0.95626,2.4728,4.4578,0.21636,0 +-2.7914,1.7734,6.7756,-0.39915,0 +5.2032,3.5116,-1.2538,1.0129,0 +3.1836,7.2321,-1.0713,-2.5909,0 +0.65497,5.1815,1.0673,-0.42113,0 +5.6084,10.3009,-4.8003,-4.3534,0 +1.105,7.4432,0.41099,-3.0332,0 +3.9292,-2.9156,2.2129,0.30817,0 +1.1558,6.4003,1.5506,0.6961,0 +2.5581,2.6218,1.8513,0.40257,0 +2.7831,10.9796,-3.557,-4.4039,0 +3.7635,2.7811,0.66119,0.34179,0 +-2.6479,10.1374,-1.331,-5.4707,0 +1.0652,8.3682,-1.4004,-1.6509,0 +-1.4275,11.8797,0.41613,-6.9978,0 +5.7456,10.1808,-4.7857,-4.3366,0 +5.086,3.2798,-1.2701,1.1189,0 +3.4092,5.4049,-2.5228,-0.89958,0 +-0.2361,9.3221,2.1307,-4.3793,0 +3.8197,8.9951,-4.383,-4.0327,0 +-1.1391,1.8127,6.9144,0.70127,0 +4.9249,0.68906,0.77344,1.2095,0 +2.5089,6.841,-0.029423,0.44912,0 +-0.2062,9.2207,-3.7044,-6.8103,0 +3.946,6.8514,-1.5443,-0.5582,0 +-0.278,8.1881,-3.1338,-2.5276,0 +1.8592,3.2074,-0.15966,-0.26208,0 +0.56953,7.6294,1.5754,-3.2233,0 +3.4626,-4.449,3.5427,0.15429,0 +3.3951,1.1484,2.1401,2.0862,0 +5.0429,-0.52974,0.50439,1.106,0 +3.7758,7.1783,-1.5195,0.40128,0 +4.6562,7.6398,-2.4243,-1.2384,0 +4.0948,-2.9674,2.3689,0.75429,0 +1.8384,6.063,0.54723,0.51248,0 +2.0153,0.43661,4.5864,-0.3151,0 +3.5251,0.7201,1.6928,0.64438,0 +3.757,-5.4236,3.8255,-1.2526,0 +2.5989,3.5178,0.7623,0.81119,0 +1.8994,0.97462,4.2265,0.81377,0 +3.6941,-3.9482,4.2625,1.1577,0 +4.4295,-2.3507,1.7048,0.90946,0 +6.8248,5.2187,-2.5425,0.5461,0 +1.8967,-2.5163,2.8093,-0.79742,0 +2.1526,-6.1665,8.0831,-0.34355,0 +3.3004,7.0811,-1.3258,0.22283,0 +2.7213,7.05,-0.58808,0.41809,0 +3.8846,-3.0336,2.5334,0.20214,0 +4.1665,-0.4449,0.23448,0.27843,0 +0.94225,5.8561,1.8762,-0.32544,0 +5.1321,-0.031048,0.32616,1.1151,0 +0.38251,6.8121,1.8128,-0.61251,0 +3.0333,-2.5928,2.3183,0.303,0 +2.9233,6.0464,-0.11168,-0.58665,0 +1.162,10.2926,-1.2821,-4.0392,0 +3.7791,2.5762,1.3098,0.5655,0 +0.77765,5.9781,1.1941,-0.3526,0 +-0.38388,-1.0471,8.0514,0.49567,0 +0.21084,9.4359,-0.094543,-1.859,0 +2.9571,-4.5938,5.9068,0.57196,0 +4.6439,-3.3729,2.5976,0.55257,0 +3.3577,-4.3062,6.0241,0.18274,0 +3.5127,2.9073,1.0579,0.40774,0 +2.6562,10.7044,-3.3085,-4.0767,0 +-1.3612,10.694,1.7022,-2.9026,0 +-0.278,8.1881,-3.1338,-2.5276,0 +1.04,-6.9321,8.2888,-1.2991,0 +2.1881,2.7356,1.3278,-0.1832,0 +4.2756,-2.6528,2.1375,0.94437,0 +-0.11996,6.8741,0.91995,-0.6694,0 +2.9736,8.7944,-3.6359,-1.3754,0 +3.7798,-3.3109,2.6491,0.066365,0 +5.3586,3.7557,-1.7345,1.0789,0 +1.8373,6.1292,0.84027,0.55257,0 +1.2262,0.89599,5.7568,-0.11596,0 +-0.048008,-0.56078,7.7215,0.453,0 +0.5706,-0.024841,1.2421,-0.56208,0 +4.3634,0.46351,1.4281,2.0202,0 +3.482,-4.1634,3.5008,-0.078462,0 +0.51947,-3.2633,3.0895,-0.98492,0 +2.3164,-2.628,3.1529,-0.08622,0 +-1.8348,11.0334,3.1863,-4.8888,0 +1.3754,8.8793,-1.9136,-0.53751,0 +-0.16682,5.8974,0.49839,-0.70044,0 +0.29961,7.1328,-0.31475,-1.1828,0 +0.25035,9.3262,-3.6873,-6.2543,0 +2.4673,1.3926,1.7125,0.41421,0 +0.77805,6.6424,-1.1425,-1.0573,0 +3.4465,2.9508,1.0271,0.5461,0 +2.2429,-4.1427,5.2333,-0.40173,0 +3.7321,-3.884,3.3577,-0.0060486,0 +4.3365,-3.584,3.6884,0.74912,0 +-2.0759,10.8223,2.6439,-4.837,0 +4.0715,7.6398,-2.0824,-1.1698,0 +0.76163,5.8209,1.1959,-0.64613,0 +-0.53966,7.3273,0.46583,-1.4543,0 +2.6213,5.7919,0.065686,-1.5759,0 +3.0242,-3.3378,2.5865,-0.54785,0 +5.8519,5.3905,-2.4037,-0.061652,0 +0.5706,-0.0248,1.2421,-0.5621,0 +3.9771,11.1513,-3.9272,-4.3444,0 +1.5478,9.1814,-1.6326,-1.7375,0 +0.74054,0.36625,2.1992,0.48403,0 +0.49571,10.2243,-1.097,-4.0159,0 +1.645,7.8612,-0.87598,-3.5569,0 +3.6077,6.8576,-1.1622,0.28231,0 +3.2403,-3.7082,5.2804,0.41291,0 +3.9166,10.2491,-4.0926,-4.4659,0 +3.9262,6.0299,-2.0156,-0.065531,0 +5.591,10.4643,-4.3839,-4.3379,0 +3.7522,-3.6978,3.9943,1.3051,0 +1.3114,4.5462,2.2935,0.22541,0 +3.7022,6.9942,-1.8511,-0.12889,0 +4.364,-3.1039,2.3757,0.78532,0 +3.5829,1.4423,1.0219,1.4008,0 +4.65,-4.8297,3.4553,-0.25174,0 +5.1731,3.9606,-1.983,0.40774,0 +3.2692,3.4184,0.20706,-0.066824,0 +2.4012,1.6223,3.0312,0.71679,0 +1.7257,-4.4697,8.2219,-1.8073,0 +4.7965,6.9859,-1.9967,-0.35001,0 +4.0962,10.1891,-3.9323,-4.1827,0 +2.5559,3.3605,2.0321,0.26809,0 +3.4916,8.5709,-3.0326,-0.59182,0 +0.5195,-3.2633,3.0895,-0.9849,0 +2.9856,7.2673,-0.409,-2.2431,0 +4.0932,5.4132,-1.8219,0.23576,0 +1.7748,-0.76978,5.5854,1.3039,0 +5.2012,0.32694,0.17965,1.1797,0 +-0.45062,-1.3678,7.0858,-0.40303,0 +4.8451,8.1116,-2.9512,-1.4724,0 +0.74841,7.2756,1.1504,-0.5388,0 +5.1213,8.5565,-3.3917,-1.5474,0 +3.6181,-3.7454,2.8273,-0.71208,0 +0.040498,8.5234,1.4461,-3.9306,0 +-2.6479,10.1374,-1.331,-5.4707,0 +0.37984,0.70975,0.75716,-0.44441,0 +-0.95923,0.091039,6.2204,-1.4828,0 +2.8672,10.0008,-3.2049,-3.1095,0 +1.0182,9.109,-0.62064,-1.7129,0 +-2.7143,11.4535,2.1092,-3.9629,0 +3.8244,-3.1081,2.4537,0.52024,0 +2.7961,2.121,1.8385,0.38317,0 +3.5358,6.7086,-0.81857,0.47886,0 +-0.7056,8.7241,2.2215,-4.5965,0 +4.1542,7.2756,-2.4766,-1.2099,0 +0.92703,9.4318,-0.66263,-1.6728,0 +1.8216,-6.4748,8.0514,-0.41855,0 +-2.4473,12.6247,0.73573,-7.6612,0 +3.5862,-3.0957,2.8093,0.24481,0 +0.66191,9.6594,-0.28819,-1.6638,0 +4.7926,1.7071,-0.051701,1.4926,0 +4.9852,8.3516,-2.5425,-1.2823,0 +0.75736,3.0294,2.9164,-0.068117,0 +4.6499,7.6336,-1.9427,-0.37458,0 +-0.023579,7.1742,0.78457,-0.75734,0 +0.85574,0.0082678,6.6042,-0.53104,0 +0.88298,0.66009,6.0096,-0.43277,0 +4.0422,-4.391,4.7466,1.137,0 +2.2546,8.0992,-0.24877,-3.2698,0 +0.38478,6.5989,-0.3336,-0.56466,0 +3.1541,-5.1711,6.5991,0.57455,0 +2.3969,0.23589,4.8477,1.437,0 +4.7114,2.0755,-0.2702,1.2379,0 +4.0127,10.1477,-3.9366,-4.0728,0 +2.6606,3.1681,1.9619,0.18662,0 +3.931,1.8541,-0.023425,1.2314,0 +0.01727,8.693,1.3989,-3.9668,0 +3.2414,0.40971,1.4015,1.1952,0 +2.2504,3.5757,0.35273,0.2836,0 +-1.3971,3.3191,-1.3927,-1.9948,1 +0.39012,-0.14279,-0.031994,0.35084,1 +-1.6677,-7.1535,7.8929,0.96765,1 +-3.8483,-12.8047,15.6824,-1.281,1 +-3.5681,-8.213,10.083,0.96765,1 +-2.2804,-0.30626,1.3347,1.3763,1 +-1.7582,2.7397,-2.5323,-2.234,1 +-0.89409,3.1991,-1.8219,-2.9452,1 +0.3434,0.12415,-0.28733,0.14654,1 +-0.9854,-6.661,5.8245,0.5461,1 +-2.4115,-9.1359,9.3444,-0.65259,1 +-1.5252,-6.2534,5.3524,0.59912,1 +-0.61442,-0.091058,-0.31818,0.50214,1 +-0.36506,2.8928,-3.6461,-3.0603,1 +-5.9034,6.5679,0.67661,-6.6797,1 +-1.8215,2.7521,-0.72261,-2.353,1 +-0.77461,-1.8768,2.4023,1.1319,1 +-1.8187,-9.0366,9.0162,-0.12243,1 +-3.5801,-12.9309,13.1779,-2.5677,1 +-1.8219,-6.8824,5.4681,0.057313,1 +-0.3481,-0.38696,-0.47841,0.62627,1 +0.47368,3.3605,-4.5064,-4.0431,1 +-3.4083,4.8587,-0.76888,-4.8668,1 +-1.6662,-0.30005,1.4238,0.024986,1 +-2.0962,-7.1059,6.6188,-0.33708,1 +-2.6685,-10.4519,9.1139,-1.7323,1 +-0.47465,-4.3496,1.9901,0.7517,1 +1.0552,1.1857,-2.6411,0.11033,1 +1.1644,3.8095,-4.9408,-4.0909,1 +-4.4779,7.3708,-0.31218,-6.7754,1 +-2.7338,0.45523,2.4391,0.21766,1 +-2.286,-5.4484,5.8039,0.88231,1 +-1.6244,-6.3444,4.6575,0.16981,1 +0.50813,0.47799,-1.9804,0.57714,1 +1.6408,4.2503,-4.9023,-2.6621,1 +0.81583,4.84,-5.2613,-6.0823,1 +-5.4901,9.1048,-0.38758,-5.9763,1 +-3.2238,2.7935,0.32274,-0.86078,1 +-2.0631,-1.5147,1.219,0.44524,1 +-0.91318,-2.0113,-0.19565,0.066365,1 +0.6005,1.9327,-3.2888,-0.32415,1 +0.91315,3.3377,-4.0557,-1.6741,1 +-0.28015,3.0729,-3.3857,-2.9155,1 +-3.6085,3.3253,-0.51954,-3.5737,1 +-6.2003,8.6806,0.0091344,-3.703,1 +-4.2932,3.3419,0.77258,-0.99785,1 +-3.0265,-0.062088,0.68604,-0.055186,1 +-1.7015,-0.010356,-0.99337,-0.53104,1 +-0.64326,2.4748,-2.9452,-1.0276,1 +-0.86339,1.9348,-2.3729,-1.0897,1 +-2.0659,1.0512,-0.46298,-1.0974,1 +-2.1333,1.5685,-0.084261,-1.7453,1 +-1.2568,-1.4733,2.8718,0.44653,1 +-3.1128,-6.841,10.7402,-1.0172,1 +-4.8554,-5.9037,10.9818,-0.82199,1 +-2.588,3.8654,-0.3336,-1.2797,1 +0.24394,1.4733,-1.4192,-0.58535,1 +-1.5322,-5.0966,6.6779,0.17498,1 +-4.0025,-13.4979,17.6772,-3.3202,1 +-4.0173,-8.3123,12.4547,-1.4375,1 +-3.0731,-0.53181,2.3877,0.77627,1 +-1.979,3.2301,-1.3575,-2.5819,1 +-0.4294,-0.14693,0.044265,-0.15605,1 +-2.234,-7.0314,7.4936,0.61334,1 +-4.211,-12.4736,14.9704,-1.3884,1 +-3.8073,-8.0971,10.1772,0.65084,1 +-2.5912,-0.10554,1.2798,1.0414,1 +-2.2482,3.0915,-2.3969,-2.6711,1 +-1.4427,3.2922,-1.9702,-3.4392,1 +-0.39416,-0.020702,-0.066267,-0.44699,1 +-1.522,-6.6383,5.7491,-0.10691,1 +-2.8267,-9.0407,9.0694,-0.98233,1 +-1.7263,-6.0237,5.2419,0.29524,1 +-0.94255,0.039307,-0.24192,0.31593,1 +-0.89569,3.0025,-3.6067,-3.4457,1 +-6.2815,6.6651,0.52581,-7.0107,1 +-2.3211,3.166,-1.0002,-2.7151,1 +-1.3414,-2.0776,2.8093,0.60688,1 +-2.258,-9.3263,9.3727,-0.85949,1 +-3.8858,-12.8461,12.7957,-3.1353,1 +-1.8969,-6.7893,5.2761,-0.32544,1 +-0.52645,-0.24832,-0.45613,0.41938,1 +0.0096613,3.5612,-4.407,-4.4103,1 +-3.8826,4.898,-0.92311,-5.0801,1 +-2.1405,-0.16762,1.321,-0.20906,1 +-2.4824,-7.3046,6.839,-0.59053,1 +-2.9098,-10.0712,8.4156,-1.9948,1 +-0.60975,-4.002,1.8471,0.6017,1 +0.83625,1.1071,-2.4706,-0.062945,1 +0.60731,3.9544,-4.772,-4.4853,1 +-4.8861,7.0542,-0.17252,-6.959,1 +-3.1366,0.42212,2.6225,-0.064238,1 +-2.5754,-5.6574,6.103,0.65214,1 +-1.8782,-6.5865,4.8486,-0.021566,1 +0.24261,0.57318,-1.9402,0.44007,1 +1.296,4.2855,-4.8457,-2.9013,1 +0.25943,5.0097,-5.0394,-6.3862,1 +-5.873,9.1752,-0.27448,-6.0422,1 +-3.4605,2.6901,0.16165,-1.0224,1 +-2.3797,-1.4402,1.1273,0.16076,1 +-1.2424,-1.7175,-0.52553,-0.21036,1 +0.20216,1.9182,-3.2828,-0.61768,1 +0.59823,3.5012,-3.9795,-1.7841,1 +-0.77995,3.2322,-3.282,-3.1004,1 +-4.1409,3.4619,-0.47841,-3.8879,1 +-6.5084,8.7696,0.23191,-3.937,1 +-4.4996,3.4288,0.56265,-1.1672,1 +-3.3125,0.10139,0.55323,-0.2957,1 +-1.9423,0.3766,-1.2898,-0.82458,1 +-0.75793,2.5349,-3.0464,-1.2629,1 +-0.95403,1.9824,-2.3163,-1.1957,1 +-2.2173,1.4671,-0.72689,-1.1724,1 +-2.799,1.9679,-0.42357,-2.1125,1 +-1.8629,-0.84841,2.5377,0.097399,1 +-3.5916,-6.2285,10.2389,-1.1543,1 +-5.1216,-5.3118,10.3846,-1.0612,1 +-3.2854,4.0372,-0.45356,-1.8228,1 +-0.56877,1.4174,-1.4252,-1.1246,1 +-2.3518,-4.8359,6.6479,-0.060358,1 +-4.4861,-13.2889,17.3087,-3.2194,1 +-4.3876,-7.7267,11.9655,-1.4543,1 +-3.3604,-0.32696,2.1324,0.6017,1 +-1.0112,2.9984,-1.1664,-1.6185,1 +0.030219,-1.0512,1.4024,0.77369,1 +-1.6514,-8.4985,9.1122,1.2379,1 +-3.2692,-12.7406,15.5573,-0.14182,1 +-2.5701,-6.8452,8.9999,2.1353,1 +-1.3066,0.25244,0.7623,1.7758,1 +-1.6637,3.2881,-2.2701,-2.2224,1 +-0.55008,2.8659,-1.6488,-2.4319,1 +0.21431,-0.69529,0.87711,0.29653,1 +-0.77288,-7.4473,6.492,0.36119,1 +-1.8391,-9.0883,9.2416,-0.10432,1 +-0.63298,-5.1277,4.5624,1.4797,1 +0.0040545,0.62905,-0.64121,0.75817,1 +-0.28696,3.1784,-3.5767,-3.1896,1 +-5.2406,6.6258,-0.19908,-6.8607,1 +-1.4446,2.1438,-0.47241,-1.6677,1 +-0.65767,-2.8018,3.7115,0.99739,1 +-1.5449,-10.1498,9.6152,-1.2332,1 +-2.8957,-12.0205,11.9149,-2.7552,1 +-0.81479,-5.7381,4.3919,0.3211,1 +0.50225,0.65388,-1.1793,0.39998,1 +0.74521,3.6357,-4.4044,-4.1414,1 +-2.9146,4.0537,-0.45699,-4.0327,1 +-1.3907,-1.3781,2.3055,-0.021566,1 +-1.786,-8.1157,7.0858,-1.2112,1 +-1.7322,-9.2828,7.719,-1.7168,1 +0.55298,-3.4619,1.7048,1.1008,1 +2.031,1.852,-3.0121,0.003003,1 +1.2279,4.0309,-4.6435,-3.9125,1 +-4.2249,6.2699,0.15822,-5.5457,1 +-2.5346,-0.77392,3.3602,0.00171,1 +-1.749,-6.332,6.0987,0.14266,1 +-0.539,-5.167,3.4399,0.052141,1 +1.5631,0.89599,-1.9702,0.65472,1 +2.3917,4.5565,-4.9888,-2.8987,1 +0.89512,4.7738,-4.8431,-5.5909,1 +-5.4808,8.1819,0.27818,-5.0323,1 +-2.8833,1.7713,0.68946,-0.4638,1 +-1.4174,-2.2535,1.518,0.61981,1 +0.4283,-0.94981,-1.0731,0.3211,1 +1.5904,2.2121,-3.1183,-0.11725,1 +1.7425,3.6833,-4.0129,-1.7207,1 +-0.23356,3.2405,-3.0669,-2.7784,1 +-3.6227,3.9958,-0.35845,-3.9047,1 +-6.1536,7.9295,0.61663,-3.2646,1 +-3.9172,2.6652,0.78886,-0.7819,1 +-2.2214,-0.23798,0.56008,0.05602,1 +-0.49241,0.89392,-1.6283,-0.56854,1 +0.26517,2.4066,-2.8416,-0.59958,1 +-0.10234,1.8189,-2.2169,-0.56725,1 +-1.6176,1.0926,-0.35502,-0.59958,1 +-1.8448,1.254,0.27218,-1.0728,1 +-1.2786,-2.4087,4.5735,0.47627,1 +-2.902,-7.6563,11.8318,-0.84268,1 +-4.3773,-5.5167,10.939,-0.4082,1 +-2.0529,3.8385,-0.79544,-1.2138,1 +0.18868,0.70148,-0.51182,0.0055892,1 +-1.7279,-6.841,8.9494,0.68058,1 +-3.3793,-13.7731,17.9274,-2.0323,1 +-3.1273,-7.1121,11.3897,-0.083634,1 +-2.121,-0.05588,1.949,1.353,1 +-1.7697,3.4329,-1.2144,-2.3789,1 +-0.0012852,0.13863,-0.19651,0.0081754,1 +-1.682,-6.8121,7.1398,1.3323,1 +-3.4917,-12.1736,14.3689,-0.61639,1 +-3.1158,-8.6289,10.4403,0.97153,1 +-2.0891,-0.48422,1.704,1.7435,1 +-1.6936,2.7852,-2.1835,-1.9276,1 +-1.2846,3.2715,-1.7671,-3.2608,1 +-0.092194,0.39315,-0.32846,-0.13794,1 +-1.0292,-6.3879,5.5255,0.79955,1 +-2.2083,-9.1069,8.9991,-0.28406,1 +-1.0744,-6.3113,5.355,0.80472,1 +-0.51003,-0.23591,0.020273,0.76334,1 +-0.36372,3.0439,-3.4816,-2.7836,1 +-6.3979,6.4479,1.0836,-6.6176,1 +-2.2501,3.3129,-0.88369,-2.8974,1 +-1.1859,-1.2519,2.2635,0.77239,1 +-1.8076,-8.8131,8.7086,-0.21682,1 +-3.3863,-12.9889,13.0545,-2.7202,1 +-1.4106,-7.108,5.6454,0.31335,1 +-0.21394,-0.68287,0.096532,1.1965,1 +0.48797,3.5674,-4.3882,-3.8116,1 +-3.8167,5.1401,-0.65063,-5.4306,1 +-1.9555,0.20692,1.2473,-0.3707,1 +-2.1786,-6.4479,6.0344,-0.20777,1 +-2.3299,-9.9532,8.4756,-1.8733,1 +0.0031201,-4.0061,1.7956,0.91722,1 +1.3518,1.0595,-2.3437,0.39998,1 +1.2309,3.8923,-4.8277,-4.0069,1 +-5.0301,7.5032,-0.13396,-7.5034,1 +-3.0799,0.60836,2.7039,-0.23751,1 +-2.2987,-5.227,5.63,0.91722,1 +-1.239,-6.541,4.8151,-0.033204,1 +0.75896,0.29176,-1.6506,0.83834,1 +1.6799,4.2068,-4.5398,-2.3931,1 +0.63655,5.2022,-5.2159,-6.1211,1 +-6.0598,9.2952,-0.43642,-6.3694,1 +-3.518,2.8763,0.1548,-1.2086,1 +-2.0336,-1.4092,1.1582,0.36507,1 +-0.69745,-1.7672,-0.34474,-0.12372,1 +0.75108,1.9161,-3.1098,-0.20518,1 +0.84546,3.4826,-3.6307,-1.3961,1 +-0.55648,3.2136,-3.3085,-2.7965,1 +-3.6817,3.2239,-0.69347,-3.4004,1 +-6.7526,8.8172,-0.061983,-3.725,1 +-4.577,3.4515,0.66719,-0.94742,1 +-2.9883,0.31245,0.45041,0.068951,1 +-1.4781,0.14277,-1.1622,-0.48579,1 +-0.46651,2.3383,-2.9812,-1.0431,1 +-0.8734,1.6533,-2.1964,-0.78061,1 +-2.1234,1.1815,-0.55552,-0.81165,1 +-2.3142,2.0838,-0.46813,-1.6767,1 +-1.4233,-0.98912,2.3586,0.39481,1 +-3.0866,-6.6362,10.5405,-0.89182,1 +-4.7331,-6.1789,11.388,-1.0741,1 +-2.8829,3.8964,-0.1888,-1.1672,1 +-0.036127,1.525,-1.4089,-0.76121,1 +-1.7104,-4.778,6.2109,0.3974,1 +-3.8203,-13.0551,16.9583,-2.3052,1 +-3.7181,-8.5089,12.363,-0.95518,1 +-2.899,-0.60424,2.6045,1.3776,1 +-0.98193,2.7956,-1.2341,-1.5668,1 +-0.17296,-1.1816,1.3818,0.7336,1 +-1.9409,-8.6848,9.155,0.94049,1 +-3.5713,-12.4922,14.8881,-0.47027,1 +-2.9915,-6.6258,8.6521,1.8198,1 +-1.8483,0.31038,0.77344,1.4189,1 +-2.2677,3.2964,-2.2563,-2.4642,1 +-0.50816,2.868,-1.8108,-2.2612,1 +0.14329,-1.0885,1.0039,0.48791,1 +-0.90784,-7.9026,6.7807,0.34179,1 +-2.0042,-9.3676,9.3333,-0.10303,1 +-0.93587,-5.1008,4.5367,1.3866,1 +-0.40804,0.54214,-0.52725,0.6586,1 +-0.8172,3.3812,-3.6684,-3.456,1 +-4.8392,6.6755,-0.24278,-6.5775,1 +-1.2792,2.1376,-0.47584,-1.3974,1 +-0.66008,-3.226,3.8058,1.1836,1 +-1.7713,-10.7665,10.2184,-1.0043,1 +-3.0061,-12.2377,11.9552,-2.1603,1 +-1.1022,-5.8395,4.5641,0.68705,1 +0.11806,0.39108,-0.98223,0.42843,1 +0.11686,3.735,-4.4379,-4.3741,1 +-2.7264,3.9213,-0.49212,-3.6371,1 +-1.2369,-1.6906,2.518,0.51636,1 +-1.8439,-8.6475,7.6796,-0.66682,1 +-1.8554,-9.6035,7.7764,-0.97716,1 +0.16358,-3.3584,1.3749,1.3569,1 +1.5077,1.9596,-3.0584,-0.12243,1 +0.67886,4.1199,-4.569,-4.1414,1 +-3.9934,5.8333,0.54723,-4.9379,1 +-2.3898,-0.78427,3.0141,0.76205,1 +-1.7976,-6.7686,6.6753,0.89912,1 +-0.70867,-5.5602,4.0483,0.903,1 +1.0194,1.1029,-2.3,0.59395,1 +1.7875,4.78,-5.1362,-3.2362,1 +0.27331,4.8773,-4.9194,-5.8198,1 +-5.1661,8.0433,0.044265,-4.4983,1 +-2.7028,1.6327,0.83598,-0.091393,1 +-1.4904,-2.2183,1.6054,0.89394,1 +-0.014902,-1.0243,-0.94024,0.64955,1 +0.88992,2.2638,-3.1046,-0.11855,1 +1.0637,3.6957,-4.1594,-1.9379,1 +-0.8471,3.1329,-3.0112,-2.9388,1 +-3.9594,4.0289,-0.35845,-3.8957,1 +-5.8818,7.6584,0.5558,-2.9155,1 +-3.7747,2.5162,0.83341,-0.30993,1 +-2.4198,-0.24418,0.70146,0.41809,1 +-0.83535,0.80494,-1.6411,-0.19225,1 +-0.30432,2.6528,-2.7756,-0.65647,1 +-0.60254,1.7237,-2.1501,-0.77027,1 +-2.1059,1.1815,-0.53324,-0.82716,1 +-2.0441,1.2271,0.18564,-1.091,1 +-1.5621,-2.2121,4.2591,0.27972,1 +-3.2305,-7.2135,11.6433,-0.94613,1 +-4.8426,-4.9932,10.4052,-0.53104,1 +-2.3147,3.6668,-0.6969,-1.2474,1 +-0.11716,0.60422,-0.38587,-0.059065,1 +-2.0066,-6.719,9.0162,0.099985,1 +-3.6961,-13.6779,17.5795,-2.6181,1 +-3.6012,-6.5389,10.5234,-0.48967,1 +-2.6286,0.18002,1.7956,0.97282,1 +-0.82601,2.9611,-1.2864,-1.4647,1 +0.31803,-0.99326,1.0947,0.88619,1 +-1.4454,-8.4385,8.8483,0.96894,1 +-3.1423,-13.0365,15.6773,-0.66165,1 +-2.5373,-6.959,8.8054,1.5289,1 +-1.366,0.18416,0.90539,1.5806,1 +-1.7064,3.3088,-2.2829,-2.1978,1 +-0.41965,2.9094,-1.7859,-2.2069,1 +0.37637,-0.82358,0.78543,0.74524,1 +-0.55355,-7.9233,6.7156,0.74394,1 +-1.6001,-9.5828,9.4044,0.081882,1 +-0.37013,-5.554,4.7749,1.547,1 +0.12126,0.22347,-0.47327,0.97024,1 +-0.27068,3.2674,-3.5562,-3.0888,1 +-5.119,6.6486,-0.049987,-6.5206,1 +-1.3946,2.3134,-0.44499,-1.4905,1 +-0.69879,-3.3771,4.1211,1.5043,1 +-1.48,-10.5244,9.9176,-0.5026,1 +-2.6649,-12.813,12.6689,-1.9082,1 +-0.62684,-6.301,4.7843,1.106,1 +0.518,0.25865,-0.84085,0.96118,1 +0.64376,3.764,-4.4738,-4.0483,1 +-2.9821,4.1986,-0.5898,-3.9642,1 +-1.4628,-1.5706,2.4357,0.49826,1 +-1.7101,-8.7903,7.9735,-0.45475,1 +-1.5572,-9.8808,8.1088,-1.0806,1 +0.74428,-3.7723,1.6131,1.5754,1 +2.0177,1.7982,-2.9581,0.2099,1 +1.164,3.913,-4.5544,-3.8672,1 +-4.3667,6.0692,0.57208,-5.4668,1 +-2.5919,-1.0553,3.8949,0.77757,1 +-1.8046,-6.8141,6.7019,1.1681,1 +-0.71868,-5.7154,3.8298,1.0233,1 +1.4378,0.66837,-2.0267,1.0271,1 +2.1943,4.5503,-4.976,-2.7254,1 +0.7376,4.8525,-4.7986,-5.6659,1 +-5.637,8.1261,0.13081,-5.0142,1 +-3.0193,1.7775,0.73745,-0.45346,1 +-1.6706,-2.09,1.584,0.71162,1 +-0.1269,-1.1505,-0.95138,0.57843,1 +1.2198,2.0982,-3.1954,0.12843,1 +1.4501,3.6067,-4.0557,-1.5966,1 +-0.40857,3.0977,-2.9607,-2.6892,1 +-3.8952,3.8157,-0.31304,-3.8194,1 +-6.3679,8.0102,0.4247,-3.2207,1 +-4.1429,2.7749,0.68261,-0.71984,1 +-2.6864,-0.097265,0.61663,0.061192,1 +-1.0555,0.79459,-1.6968,-0.46768,1 +-0.29858,2.4769,-2.9512,-0.66165,1 +-0.49948,1.7734,-2.2469,-0.68104,1 +-1.9881,0.99945,-0.28562,-0.70044,1 +-1.9389,1.5706,0.045979,-1.122,1 +-1.4375,-1.8624,4.026,0.55127,1 +-3.1875,-7.5756,11.8678,-0.57889,1 +-4.6765,-5.6636,10.969,-0.33449,1 +-2.0285,3.8468,-0.63435,-1.175,1 +0.26637,0.73252,-0.67891,0.03533,1 +-1.7589,-6.4624,8.4773,0.31981,1 +-3.5985,-13.6593,17.6052,-2.4927,1 +-3.3582,-7.2404,11.4419,-0.57113,1 +-2.3629,-0.10554,1.9336,1.1358,1 +-2.1802,3.3791,-1.2256,-2.6621,1 +-0.40951,-0.15521,0.060545,-0.088807,1 +-2.2918,-7.257,7.9597,0.9211,1 +-4.0214,-12.8006,15.6199,-0.95647,1 +-3.3884,-8.215,10.3315,0.98187,1 +-2.0046,-0.49457,1.333,1.6543,1 +-1.7063,2.7956,-2.378,-2.3491,1 +-1.6386,3.3584,-1.7302,-3.5646,1 +-0.41645,0.32487,-0.33617,-0.36036,1 +-1.5877,-6.6072,5.8022,0.31593,1 +-2.5961,-9.349,9.7942,-0.28018,1 +-1.5228,-6.4789,5.7568,0.87325,1 +-0.53072,-0.097265,-0.21793,1.0426,1 +-0.49081,2.8452,-3.6436,-3.1004,1 +-6.5773,6.8017,0.85483,-7.5344,1 +-2.4621,2.7645,-0.62578,-2.8573,1 +-1.3995,-1.9162,2.5154,0.59912,1 +-2.3221,-9.3304,9.233,-0.79871,1 +-3.73,-12.9723,12.9817,-2.684,1 +-1.6988,-7.1163,5.7902,0.16723,1 +-0.26654,-0.64562,-0.42014,0.89136,1 +0.33325,3.3108,-4.5081,-4.012,1 +-4.2091,4.7283,-0.49126,-5.2159,1 +-2.3142,-0.68494,1.9833,-0.44829,1 +-2.4835,-7.4494,6.8964,-0.64484,1 +-2.7611,-10.5099,9.0239,-1.9547,1 +-0.36025,-4.449,2.1067,0.94308,1 +1.0117,0.9022,-2.3506,0.42714,1 +0.96708,3.8426,-4.9314,-4.1323,1 +-5.2049,7.259,0.070827,-7.3004,1 +-3.3203,-0.02691,2.9618,-0.44958,1 +-2.565,-5.7899,6.0122,0.046968,1 +-1.5951,-6.572,4.7689,-0.94354,1 +0.7049,0.17174,-1.7859,0.36119,1 +1.7331,3.9544,-4.7412,-2.5017,1 +0.6818,4.8504,-5.2133,-6.1043,1 +-6.3364,9.2848,0.014275,-6.7844,1 +-3.8053,2.4273,0.6809,-1.0871,1 +-2.1979,-2.1252,1.7151,0.45171,1 +-0.87874,-2.2121,-0.051701,0.099985,1 +0.74067,1.7299,-3.1963,-0.1457,1 +0.98296,3.4226,-3.9692,-1.7116,1 +-0.3489,3.1929,-3.4054,-3.1832,1 +-3.8552,3.5219,-0.38415,-3.8608,1 +-6.9599,8.9931,0.2182,-4.572,1 +-4.7462,3.1205,1.075,-1.2966,1 +-3.2051,-0.14279,0.97565,0.045675,1 +-1.7549,-0.080711,-0.75774,-0.3707,1 +-0.59587,2.4811,-2.8673,-0.89828,1 +-0.89542,2.0279,-2.3652,-1.2746,1 +-2.0754,1.2767,-0.64206,-1.2642,1 +-3.2778,1.8023,0.1805,-2.3931,1 +-2.2183,-1.254,2.9986,0.36378,1 +-3.5895,-6.572,10.5251,-0.16381,1 +-5.0477,-5.8023,11.244,-0.3901,1 +-3.5741,3.944,-0.07912,-2.1203,1 +-0.7351,1.7361,-1.4938,-1.1582,1 +-2.2617,-4.7428,6.3489,0.11162,1 +-4.244,-13.0634,17.1116,-2.8017,1 +-4.0218,-8.304,12.555,-1.5099,1 +-3.0201,-0.67253,2.7056,0.85774,1 +-2.4941,3.5447,-1.3721,-2.8483,1 +-0.83121,0.039307,0.05369,-0.23105,1 +-2.5665,-6.8824,7.5416,0.70774,1 +-4.4018,-12.9371,15.6559,-1.6806,1 +-3.7573,-8.2916,10.3032,0.38059,1 +-2.4725,-0.40145,1.4855,1.1189,1 +-1.9725,2.8825,-2.3086,-2.3724,1 +-2.0149,3.6874,-1.9385,-3.8918,1 +-0.82053,0.65181,-0.48869,-0.52716,1 +-1.7886,-6.3486,5.6154,0.42584,1 +-2.9138,-9.4711,9.7668,-0.60216,1 +-1.8343,-6.5907,5.6429,0.54998,1 +-0.8734,-0.033118,-0.20165,0.55774,1 +-0.70346,2.957,-3.5947,-3.1457,1 +-6.7387,6.9879,0.67833,-7.5887,1 +-2.7723,3.2777,-0.9351,-3.1457,1 +-1.6641,-1.3678,1.997,0.52283,1 +-2.4349,-9.2497,8.9922,-0.50001,1 +-3.793,-12.7095,12.7957,-2.825,1 +-1.9551,-6.9756,5.5383,-0.12889,1 +-0.69078,-0.50077,-0.35417,0.47498,1 +0.025013,3.3998,-4.4327,-4.2655,1 +-4.3967,4.9601,-0.64892,-5.4719,1 +-2.456,-0.24418,1.4041,-0.45863,1 +-2.62,-6.8555,6.2169,-0.62285,1 +-2.9662,-10.3257,8.784,-2.1138,1 +-0.71494,-4.4448,2.2241,0.49826,1 +0.6005,0.99945,-2.2126,0.097399,1 +0.61652,3.8944,-4.7275,-4.3948,1 +-5.4414,7.2363,0.10938,-7.5642,1 +-3.5798,0.45937,2.3457,-0.45734,1 +-2.7769,-5.6967,5.9179,0.37671,1 +-1.8356,-6.7562,5.0585,-0.55044,1 +0.30081,0.17381,-1.7542,0.48921,1 +1.3403,4.1323,-4.7018,-2.5987,1 +0.26877,4.987,-5.1508,-6.3913,1 +-6.5235,9.6014,-0.25392,-6.9642,1 +-4.0679,2.4955,0.79571,-1.1039,1 +-2.564,-1.7051,1.5026,0.32757,1 +-1.3414,-1.9162,-0.15538,-0.11984,1 +0.23874,2.0879,-3.3522,-0.66553,1 +0.6212,3.6771,-4.0771,-2.0711,1 +-0.77848,3.4019,-3.4859,-3.5569,1 +-4.1244,3.7909,-0.6532,-4.1802,1 +-7.0421,9.2,0.25933,-4.6832,1 +-4.9462,3.5716,0.82742,-1.4957,1 +-3.5359,0.30417,0.6569,-0.2957,1 +-2.0662,0.16967,-1.0054,-0.82975,1 +-0.88728,2.808,-3.1432,-1.2035,1 +-1.0941,2.3072,-2.5237,-1.4453,1 +-2.4458,1.6285,-0.88541,-1.4802,1 +-3.551,1.8955,0.1865,-2.4409,1 +-2.2811,-0.85669,2.7185,0.044382,1 +-3.6053,-5.974,10.0916,-0.82846,1 +-5.0676,-5.1877,10.4266,-0.86725,1 +-3.9204,4.0723,-0.23678,-2.1151,1 +-1.1306,1.8458,-1.3575,-1.3806,1 +-2.4561,-4.5566,6.4534,-0.056479,1 +-4.4775,-13.0303,17.0834,-3.0345,1 +-4.1958,-8.1819,12.1291,-1.6017,1 +-3.38,-0.7077,2.5325,0.71808,1 +-2.4365,3.6026,-1.4166,-2.8948,1 +-0.77688,0.13036,-0.031137,-0.35389,1 +-2.7083,-6.8266,7.5339,0.59007,1 +-4.5531,-12.5854,15.4417,-1.4983,1 +-3.8894,-7.8322,9.8208,0.47498,1 +-2.5084,-0.22763,1.488,1.2069,1 +-2.1652,3.0211,-2.4132,-2.4241,1 +-1.8974,3.5074,-1.7842,-3.8491,1 +-0.62043,0.5587,-0.38587,-0.66423,1 +-1.8387,-6.301,5.6506,0.19567,1 +-3,-9.1566,9.5766,-0.73018,1 +-1.9116,-6.1603,5.606,0.48533,1 +-1.005,0.084831,-0.2462,0.45688,1 +-0.87834,3.257,-3.6778,-3.2944,1 +-6.651,6.7934,0.68604,-7.5887,1 +-2.5463,3.1101,-0.83228,-3.0358,1 +-1.4377,-1.432,2.1144,0.42067,1 +-2.4554,-9.0407,8.862,-0.86983,1 +-3.9411,-12.8792,13.0597,-3.3125,1 +-2.1241,-6.8969,5.5992,-0.47156,1 +-0.74324,-0.32902,-0.42785,0.23317,1 +-0.071503,3.7412,-4.5415,-4.2526,1 +-4.2333,4.9166,-0.49212,-5.3207,1 +-2.3675,-0.43663,1.692,-0.43018,1 +-2.5526,-7.3625,6.9255,-0.66811,1 +-3.0986,-10.4602,8.9717,-2.3427,1 +-0.89809,-4.4862,2.2009,0.50731,1 +0.56232,1.0015,-2.2726,-0.0060486,1 +0.53936,3.8944,-4.8166,-4.3418,1 +-5.3012,7.3915,0.029699,-7.3987,1 +-3.3553,0.35591,2.6473,-0.37846,1 +-2.7908,-5.7133,5.953,0.45946,1 +-1.9983,-6.6072,4.8254,-0.41984,1 +0.15423,0.11794,-1.6823,0.59524,1 +1.208,4.0744,-4.7635,-2.6129,1 +0.2952,4.8856,-5.149,-6.2323,1 +-6.4247,9.5311,0.022844,-6.8517,1 +-3.9933,2.6218,0.62863,-1.1595,1 +-2.659,-1.6058,1.3647,0.16464,1 +-1.4094,-2.1252,-0.10397,-0.19225,1 +0.11032,1.9741,-3.3668,-0.65259,1 +0.52374,3.644,-4.0746,-1.9909,1 +-0.76794,3.4598,-3.4405,-3.4276,1 +-3.9698,3.6812,-0.60008,-4.0133,1 +-7.0364,9.2931,0.16594,-4.5396,1 +-4.9447,3.3005,1.063,-1.444,1 +-3.5933,0.22968,0.7126,-0.3332,1 +-2.1674,0.12415,-1.0465,-0.86208,1 +-0.9607,2.6963,-3.1226,-1.3121,1 +-1.0802,2.1996,-2.5862,-1.2759,1 +-2.3277,1.4381,-0.82114,-1.2862,1 +-3.7244,1.9037,-0.035421,-2.5095,1 +-2.5724,-0.95602,2.7073,-0.16639,1 +-3.9297,-6.0816,10.0958,-1.0147,1 +-5.2943,-5.1463,10.3332,-1.1181,1 +-3.8953,4.0392,-0.3019,-2.1836,1 +-1.2244,1.7485,-1.4801,-1.4181,1 +-2.6406,-4.4159,5.983,-0.13924,1 +-4.6338,-12.7509,16.7166,-3.2168,1 +-4.2887,-7.8633,11.8387,-1.8978,1 +-3.3458,-0.50491,2.6328,0.53705,1 +-1.1188,3.3357,-1.3455,-1.9573,1 +0.55939,-0.3104,0.18307,0.44653,1 +-1.5078,-7.3191,7.8981,1.2289,1 +-3.506,-12.5667,15.1606,-0.75216,1 +-2.9498,-8.273,10.2646,1.1629,1 +-1.6029,-0.38903,1.62,1.9103,1 +-1.2667,2.8183,-2.426,-1.8862,1 +-0.49281,3.0605,-1.8356,-2.834,1 +0.66365,-0.045533,-0.18794,0.23447,1 +-0.72068,-6.7583,5.8408,0.62369,1 +-1.9966,-9.5001,9.682,-0.12889,1 +-0.97325,-6.4168,5.6026,1.0323,1 +-0.025314,-0.17383,-0.11339,1.2198,1 +0.062525,2.9301,-3.5467,-2.6737,1 +-5.525,6.3258,0.89768,-6.6241,1 +-1.2943,2.6735,-0.84085,-2.0323,1 +-0.24037,-1.7837,2.135,1.2418,1 +-1.3968,-9.6698,9.4652,-0.34872,1 +-2.9672,-13.2869,13.4727,-2.6271,1 +-1.1005,-7.2508,6.0139,0.36895,1 +0.22432,-0.52147,-0.40386,1.2017,1 +0.90407,3.3708,-4.4987,-3.6965,1 +-2.8619,4.5193,-0.58123,-4.2629,1 +-1.0833,-0.31247,1.2815,0.41291,1 +-1.5681,-7.2446,6.5537,-0.1276,1 +-2.0545,-10.8679,9.4926,-1.4116,1 +0.2346,-4.5152,2.1195,1.4448,1 +1.581,0.86909,-2.3138,0.82412,1 +1.5514,3.8013,-4.9143,-3.7483,1 +-4.1479,7.1225,-0.083404,-6.4172,1 +-2.2625,-0.099335,2.8127,0.48662,1 +-1.7479,-5.823,5.8699,1.212,1 +-0.95923,-6.7128,4.9857,0.32886,1 +1.3451,0.23589,-1.8785,1.3258,1 +2.2279,4.0951,-4.8037,-2.1112,1 +1.2572,4.8731,-5.2861,-5.8741,1 +-5.3857,9.1214,-0.41929,-5.9181,1 +-2.9786,2.3445,0.52667,-0.40173,1 +-1.5851,-2.1562,1.7082,0.9017,1 +-0.21888,-2.2038,-0.0954,0.56421,1 +1.3183,1.9017,-3.3111,0.065071,1 +1.4896,3.4288,-4.0309,-1.4259,1 +0.11592,3.2219,-3.4302,-2.8457,1 +-3.3924,3.3564,-0.72004,-3.5233,1 +-6.1632,8.7096,-0.21621,-3.6345,1 +-4.0786,2.9239,0.87026,-0.65389,1 +-2.5899,-0.3911,0.93452,0.42972,1 +-1.0116,-0.19038,-0.90597,0.003003,1 +0.066129,2.4914,-2.9401,-0.62156,1 +-0.24745,1.9368,-2.4697,-0.80518,1 +-1.5732,1.0636,-0.71232,-0.8388,1 +-2.1668,1.5933,0.045122,-1.678,1 +-1.1667,-1.4237,2.9241,0.66119,1 +-2.8391,-6.63,10.4849,-0.42113,1 +-4.5046,-5.8126,10.8867,-0.52846,1 +-2.41,3.7433,-0.40215,-1.2953,1 +0.40614,1.3492,-1.4501,-0.55949,1 +-1.3887,-4.8773,6.4774,0.34179,1 +-3.7503,-13.4586,17.5932,-2.7771,1 +-3.5637,-8.3827,12.393,-1.2823,1 +-2.5419,-0.65804,2.6842,1.1952,1 \ No newline at end of file diff --git a/doc/LectureNotes/DataFiles/cancer.dot b/doc/LectureNotes/DataFiles/cancer.dot index 74919a956..5b4b48a9b 100644 --- a/doc/LectureNotes/DataFiles/cancer.dot +++ b/doc/LectureNotes/DataFiles/cancer.dot @@ -1,57 +1,57 @@ digraph Tree { -node [shape=box, style="filled, rounded", color="black", fontname="helvetica"] ; -edge [fontname="helvetica"] ; -0 [label="worst perimeter <= 106.05\ngini = 0.465\nsamples = 426\nvalue = [[269, 157]\n[157, 269]]", fillcolor="#fefbf9"] ; -1 [label="worst concave points <= 0.159\ngini = 0.067\nsamples = 259\nvalue = [[250, 9]\n[9, 250]]", fillcolor="#e99355"] ; +node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ; +edge [fontname=helvetica] ; +0 [label="worst perimeter <= 106.05\ngini = 0.465\nsamples = 426\nvalue = [[269, 157]\n[157, 269]]", fillcolor="#e5813908"] ; +1 [label="worst concave points <= 0.159\ngini = 0.067\nsamples = 259\nvalue = [[250, 9]\n[9, 250]]", fillcolor="#e58139db"] ; 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; -2 [label="worst concave points <= 0.135\ngini = 0.031\nsamples = 253\nvalue = [[249, 4]\n[4, 249]]", fillcolor="#e78946"] ; +2 [label="worst concave points <= 0.135\ngini = 0.031\nsamples = 253\nvalue = [[249, 4]\n[4, 249]]", fillcolor="#e58139ee"] ; 1 -> 2 ; -3 [label="radius error <= 0.643\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e5833c"] ; +3 [label="radius error <= 0.643\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e58139fb"] ; 2 -> 3 ; -4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139"] ; +4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139ff"] ; 3 -> 4 ; -5 [label="concave points error <= 0.016\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#fdf6f0"] ; +5 [label="worst symmetry <= 0.208\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#e5813913"] ; 3 -> 5 ; -6 [label="gini = 0.0\nsamples = 1\nvalue = [[0, 1]\n[1, 0]]", fillcolor="#e58139"] ; +6 [label="gini = 0.0\nsamples = 1\nvalue = [[0, 1]\n[1, 0]]", fillcolor="#e58139ff"] ; 5 -> 6 ; -7 [label="gini = 0.0\nsamples = 2\nvalue = [[2, 0]\n[0, 2]]", fillcolor="#e58139"] ; +7 [label="gini = 0.0\nsamples = 2\nvalue = [[2, 0]\n[0, 2]]", fillcolor="#e58139ff"] ; 5 -> 7 ; -8 [label="worst texture <= 29.455\ngini = 0.397\nsamples = 11\nvalue = [[8, 3]\n[3, 8]]", fillcolor="#fae9dd"] ; +8 [label="worst texture <= 29.455\ngini = 0.397\nsamples = 11\nvalue = [[8, 3]\n[3, 8]]", fillcolor="#e581392c"] ; 2 -> 8 ; -9 [label="gini = 0.0\nsamples = 8\nvalue = [[8, 0]\n[0, 8]]", fillcolor="#e58139"] ; +9 [label="gini = 0.0\nsamples = 8\nvalue = [[8, 0]\n[0, 8]]", fillcolor="#e58139ff"] ; 8 -> 9 ; -10 [label="gini = 0.0\nsamples = 3\nvalue = [[0, 3]\n[3, 0]]", fillcolor="#e58139"] ; +10 [label="gini = 0.0\nsamples = 3\nvalue = [[0, 3]\n[3, 0]]", fillcolor="#e58139ff"] ; 8 -> 10 ; -11 [label="mean texture <= 16.22\ngini = 0.278\nsamples = 6\nvalue = [[1, 5]\n[5, 1]]", fillcolor="#f4caac"] ; +11 [label="mean texture <= 16.22\ngini = 0.278\nsamples = 6\nvalue = [[1, 5]\n[5, 1]]", fillcolor="#e581396b"] ; 1 -> 11 ; -12 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ; +12 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ; 11 -> 12 ; -13 [label="gini = 0.0\nsamples = 5\nvalue = [[0, 5]\n[5, 0]]", fillcolor="#e58139"] ; +13 [label="gini = 0.0\nsamples = 5\nvalue = [[0, 5]\n[5, 0]]", fillcolor="#e58139ff"] ; 11 -> 13 ; -14 [label="worst texture <= 20.645\ngini = 0.202\nsamples = 167\nvalue = [[19, 148]\n[148, 19]]", fillcolor="#f0b68c"] ; +14 [label="worst texture <= 20.645\ngini = 0.202\nsamples = 167\nvalue = [[19, 148]\n[148, 19]]", fillcolor="#e5813994"] ; 0 -> 14 [labeldistance=2.5, labelangle=-45, headlabel="False"] ; -15 [label="worst radius <= 17.74\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#f9e3d4"] ; +15 [label="worst radius <= 17.74\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#e5813938"] ; 14 -> 15 ; -16 [label="gini = 0.0\nsamples = 11\nvalue = [[11, 0]\n[0, 11]]", fillcolor="#e58139"] ; +16 [label="gini = 0.0\nsamples = 11\nvalue = [[11, 0]\n[0, 11]]", fillcolor="#e58139ff"] ; 15 -> 16 ; -17 [label="mean texture <= 13.745\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#f6d5bd"] ; +17 [label="mean texture <= 13.745\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#e5813955"] ; 15 -> 17 ; -18 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ; +18 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ; 17 -> 18 ; -19 [label="gini = 0.0\nsamples = 4\nvalue = [[0, 4]\n[4, 0]]", fillcolor="#e58139"] ; +19 [label="gini = 0.0\nsamples = 4\nvalue = [[0, 4]\n[4, 0]]", fillcolor="#e58139ff"] ; 17 -> 19 ; -20 [label="mean concave points <= 0.049\ngini = 0.088\nsamples = 151\nvalue = [[7, 144]\n[144, 7]]", fillcolor="#ea985d"] ; +20 [label="mean concave points <= 0.049\ngini = 0.088\nsamples = 151\nvalue = [[7, 144]\n[144, 7]]", fillcolor="#e58139d0"] ; 14 -> 20 ; -21 [label="concave points error <= 0.01\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#ffffff"] ; +21 [label="concave points error <= 0.01\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#e5813900"] ; 20 -> 21 ; -22 [label="gini = 0.0\nsamples = 9\nvalue = [[0, 9]\n[9, 0]]", fillcolor="#e58139"] ; +22 [label="gini = 0.0\nsamples = 9\nvalue = [[0, 9]\n[9, 0]]", fillcolor="#e58139ff"] ; 21 -> 22 ; -23 [label="gini = 0.0\nsamples = 6\nvalue = [[6, 0]\n[0, 6]]", fillcolor="#e58139"] ; +23 [label="gini = 0.0\nsamples = 6\nvalue = [[6, 0]\n[0, 6]]", fillcolor="#e58139ff"] ; 21 -> 23 ; -24 [label="fractal dimension error <= 0.013\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e6853f"] ; +24 [label="worst smoothness <= 0.096\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e58139f7"] ; 20 -> 24 ; -25 [label="gini = 0.0\nsamples = 135\nvalue = [[0, 135]\n[135, 0]]", fillcolor="#e58139"] ; +25 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ; 24 -> 25 ; -26 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ; +26 [label="gini = 0.0\nsamples = 135\nvalue = [[0, 135]\n[135, 0]]", fillcolor="#e58139ff"] ; 24 -> 26 ; } \ No newline at end of file diff --git a/doc/LectureNotes/DataFiles/cancer.png b/doc/LectureNotes/DataFiles/cancer.png index 7666dd4ea..2ceb5e1f8 100644 Binary files a/doc/LectureNotes/DataFiles/cancer.png and b/doc/LectureNotes/DataFiles/cancer.png differ diff --git a/doc/LectureNotes/DataFiles/ensembleoverview.png b/doc/LectureNotes/DataFiles/ensembleoverview.png new file mode 100644 index 000000000..dce581ee6 Binary files /dev/null and b/doc/LectureNotes/DataFiles/ensembleoverview.png differ diff --git a/doc/LectureNotes/DataFiles/ride.csv b/doc/LectureNotes/DataFiles/ride.csv new file mode 100644 index 000000000..d03d4ca16 --- /dev/null +++ b/doc/LectureNotes/DataFiles/ride.csv @@ -0,0 +1,15 @@ +Outlook,Temperature,Humidity,Wind,Ride +0,0,0,0,0 +0,0,0,1,1 +1,0,0,0,1 +2,1,0,0,1 +2,2,1,0,1 +2,2,1,1,0 +1,2,1,1,1 +0,1,0,0,0 +0,2,1,0,1 +2,1,1,0,1 +0,1,1,1,1 +1,1,0,1,1 +1,0,1,0,1 +2,1,0,1,0 diff --git a/doc/LectureNotes/DataFiles/ride.dot b/doc/LectureNotes/DataFiles/ride.dot new file mode 100644 index 000000000..50aaa7638 --- /dev/null +++ b/doc/LectureNotes/DataFiles/ride.dot @@ -0,0 +1,13 @@ +digraph Tree { +node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ; +edge [fontname=helvetica] ; +0 [label="X[7] <= 0.5\ngini = 0.48\nsamples = 15\nvalue = [4, 10, 1]", fillcolor="#39e5818b"] ; +1 [label="X[1] <= 0.5\ngini = 0.408\nsamples = 14\nvalue = [4, 10, 0]", fillcolor="#39e58199"] ; +0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; +2 [label="gini = 0.48\nsamples = 10\nvalue = [4, 6, 0]", fillcolor="#39e58155"] ; +1 -> 2 ; +3 [label="gini = 0.0\nsamples = 4\nvalue = [0, 4, 0]", fillcolor="#39e581ff"] ; +1 -> 3 ; +4 [label="gini = 0.0\nsamples = 1\nvalue = [0, 0, 1]", fillcolor="#8139e5ff"] ; +0 -> 4 [labeldistance=2.5, labelangle=-45, headlabel="False"] ; +} \ No newline at end of file diff --git a/doc/LectureNotes/DataFiles/rideclass.csv b/doc/LectureNotes/DataFiles/rideclass.csv new file mode 100644 index 000000000..a0831ac7e --- /dev/null +++ b/doc/LectureNotes/DataFiles/rideclass.csv @@ -0,0 +1,15 @@ +Day,Outlook,Temperature,Humidity,Wind,Ride +1,Sunny,Hot,High,Weak,0 +2,Sunny,Hot,High,Strong,1 +3,Overcast,Hot,High,Weak,1 +4,Rain,Mild,High,Weak,1 +5,Rain,Cool,Normal,Weak,1 +6,Rain,Cool,Normal,Strong,0 +7,Overcast,Cool,Normal,Strong,1 +8,Sunny,Mild,High,Weak,0 +9,Sunny,Cool,Normal,Weak,1 +10,Rain,Mild,Normal,Weak,1 +11,Sunny,Mild,Normal,Strong,1 +12,Overcast,Mild,High,Strong,1 +13,Overcast,Hot,Normal,Weak,1 +14,Rain,Mild,High,Strong,0 diff --git a/doc/LectureNotes/DataFiles/zoo.csv b/doc/LectureNotes/DataFiles/zoo.csv new file mode 100644 index 000000000..ca71f7d21 --- /dev/null +++ b/doc/LectureNotes/DataFiles/zoo.csv @@ -0,0 +1,101 @@ +aardvark,1,0,0,1,0,0,1,1,1,1,0,0,4,0,0,1,1 +antelope,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +bass,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,4 +bear,1,0,0,1,0,0,1,1,1,1,0,0,4,0,0,1,1 +boar,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +buffalo,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +calf,1,0,0,1,0,0,0,1,1,1,0,0,4,1,1,1,1 +carp,0,0,1,0,0,1,0,1,1,0,0,1,0,1,1,0,4 +catfish,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,4 +cavy,1,0,0,1,0,0,0,1,1,1,0,0,4,0,1,0,1 +cheetah,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +chicken,0,1,1,0,1,0,0,0,1,1,0,0,2,1,1,0,2 +chub,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,4 +clam,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,7 +crab,0,0,1,0,0,1,1,0,0,0,0,0,4,0,0,0,7 +crayfish,0,0,1,0,0,1,1,0,0,0,0,0,6,0,0,0,7 +crow,0,1,1,0,1,0,1,0,1,1,0,0,2,1,0,0,2 +deer,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +dogfish,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,1,4 +dolphin,0,0,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1 +dove,0,1,1,0,1,0,0,0,1,1,0,0,2,1,1,0,2 +duck,0,1,1,0,1,1,0,0,1,1,0,0,2,1,0,0,2 +elephant,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +flamingo,0,1,1,0,1,0,0,0,1,1,0,0,2,1,0,1,2 +flea,0,0,1,0,0,0,0,0,0,1,0,0,6,0,0,0,6 +frog,0,0,1,0,0,1,1,1,1,1,0,0,4,0,0,0,5 +frog,0,0,1,0,0,1,1,1,1,1,1,0,4,0,0,0,5 +fruitbat,1,0,0,1,1,0,0,1,1,1,0,0,2,1,0,0,1 +giraffe,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +girl,1,0,0,1,0,0,1,1,1,1,0,0,2,0,1,1,1 +gnat,0,0,1,0,1,0,0,0,0,1,0,0,6,0,0,0,6 +goat,1,0,0,1,0,0,0,1,1,1,0,0,4,1,1,1,1 +gorilla,1,0,0,1,0,0,0,1,1,1,0,0,2,0,0,1,1 +gull,0,1,1,0,1,1,1,0,1,1,0,0,2,1,0,0,2 +haddock,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,4 +hamster,1,0,0,1,0,0,0,1,1,1,0,0,4,1,1,0,1 +hare,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,0,1 +hawk,0,1,1,0,1,0,1,0,1,1,0,0,2,1,0,0,2 +herring,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,4 +honeybee,1,0,1,0,1,0,0,0,0,1,1,0,6,0,1,0,6 +housefly,1,0,1,0,1,0,0,0,0,1,0,0,6,0,0,0,6 +kiwi,0,1,1,0,0,0,1,0,1,1,0,0,2,1,0,0,2 +ladybird,0,0,1,0,1,0,1,0,0,1,0,0,6,0,0,0,6 +lark,0,1,1,0,1,0,0,0,1,1,0,0,2,1,0,0,2 +leopard,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +lion,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +lobster,0,0,1,0,0,1,1,0,0,0,0,0,6,0,0,0,7 +lynx,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +mink,1,0,0,1,0,1,1,1,1,1,0,0,4,1,0,1,1 +mole,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,0,1 +mongoose,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +moth,1,0,1,0,1,0,0,0,0,1,0,0,6,0,0,0,6 +newt,0,0,1,0,0,1,1,1,1,1,0,0,4,1,0,0,5 +octopus,0,0,1,0,0,1,1,0,0,0,0,0,8,0,0,1,7 +opossum,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,0,1 +oryx,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,1,1 +ostrich,0,1,1,0,0,0,0,0,1,1,0,0,2,1,0,1,2 +parakeet,0,1,1,0,1,0,0,0,1,1,0,0,2,1,1,0,2 +penguin,0,1,1,0,0,1,1,0,1,1,0,0,2,1,0,1,2 +pheasant,0,1,1,0,1,0,0,0,1,1,0,0,2,1,0,0,2 +pike,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,1,4 +piranha,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,4 +pitviper,0,0,1,0,0,0,1,1,1,1,1,0,0,1,0,0,3 +platypus,1,0,1,1,0,1,1,0,1,1,0,0,4,1,0,1,1 +polecat,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +pony,1,0,0,1,0,0,0,1,1,1,0,0,4,1,1,1,1 +porpoise,0,0,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1 +puma,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +pussycat,1,0,0,1,0,0,1,1,1,1,0,0,4,1,1,1,1 +raccoon,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +reindeer,1,0,0,1,0,0,0,1,1,1,0,0,4,1,1,1,1 +rhea,0,1,1,0,0,0,1,0,1,1,0,0,2,1,0,1,2 +scorpion,0,0,0,0,0,0,1,0,0,1,1,0,8,1,0,0,7 +seahorse,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,4 +seal,1,0,0,1,0,1,1,1,1,1,0,1,0,0,0,1,1 +sealion,1,0,0,1,0,1,1,1,1,1,0,1,2,1,0,1,1 +seasnake,0,0,0,0,0,1,1,1,1,0,1,0,0,1,0,0,3 +seawasp,0,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,7 +skimmer,0,1,1,0,1,1,1,0,1,1,0,0,2,1,0,0,2 +skua,0,1,1,0,1,1,1,0,1,1,0,0,2,1,0,0,2 +slowworm,0,0,1,0,0,0,1,1,1,1,0,0,0,1,0,0,3 +slug,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,7 +sole,0,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,4 +sparrow,0,1,1,0,1,0,0,0,1,1,0,0,2,1,0,0,2 +squirrel,1,0,0,1,0,0,0,1,1,1,0,0,2,1,0,0,1 +starfish,0,0,1,0,0,1,1,0,0,0,0,0,5,0,0,0,7 +stingray,0,0,1,0,0,1,1,1,1,0,1,1,0,1,0,1,4 +swan,0,1,1,0,1,1,0,0,1,1,0,0,2,1,0,1,2 +termite,0,0,1,0,0,0,0,0,0,1,0,0,6,0,0,0,6 +toad,0,0,1,0,0,1,0,1,1,1,0,0,4,0,0,0,5 +tortoise,0,0,1,0,0,0,0,0,1,1,0,0,4,1,0,1,3 +tuatara,0,0,1,0,0,0,1,1,1,1,0,0,4,1,0,0,3 +tuna,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,1,4 +vampire,1,0,0,1,1,0,0,1,1,1,0,0,2,1,0,0,1 +vole,1,0,0,1,0,0,0,1,1,1,0,0,4,1,0,0,1 +vulture,0,1,1,0,1,0,1,0,1,1,0,0,2,1,0,1,2 +wallaby,1,0,0,1,0,0,0,1,1,1,0,0,2,1,0,1,1 +wasp,1,0,1,0,1,0,0,0,0,1,1,0,6,0,0,0,6 +wolf,1,0,0,1,0,0,1,1,1,1,0,0,4,1,0,1,1 +worm,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,7 +wren,0,1,1,0,1,0,0,0,1,1,0,0,2,1,0,0,2 diff --git a/doc/LectureNotes/week46.ipynb b/doc/LectureNotes/week46.ipynb new file mode 100644 index 000000000..5aaeebdc2 --- /dev/null +++ b/doc/LectureNotes/week46.ipynb @@ -0,0 +1,3156 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3ae913f7", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "bde4c6f5", + "metadata": { + "editable": true + }, + "source": [ + "# Week 46: Decision Trees, Ensemble methods and Random Forests\n", + "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n", + "\n", + "Date: **Week 46, November 13-17**" + ] + }, + { + "cell_type": "markdown", + "id": "9e846d96", + "metadata": { + "editable": true + }, + "source": [ + "## Plan for week 46\n", + "\n", + "**Active learning sessions on Tuesday and Wednesday.**\n", + "\n", + " * Work and Discussion of project 2\n", + "\n", + " * Discussion of project 3 as well\n", + "\n", + " \n", + "\n", + "**Material for the lecture on Thursday November 16, 2023.**\n", + "\n", + " * Thursday: Basics of decision trees, classification and regression algorithms and ensemble models \n", + "\n", + " * Readings and Videos:\n", + "\n", + " * These lecture notes\n", + "\n", + " * [Video of lecture to be added](https://youtu.be/)\n", + "\n", + " * [Video on Decision trees](https://www.youtube.com/watch?v=RmajweUFKvM&ab_channel=Simplilearn)\n", + "\n", + " * Decision Trees: Geron's chapter 6 covers decision trees while ensemble models, voting and bagging are discussed in chapter 7. See also lecture from [STK-IN4300, lecture 7](https://www.uio.no/studier/emner/matnat/math/STK-IN4300/h20/slides/lecture_7.pdf). Chapter 9.2 of Hastie et al contains also a good discussion." + ] + }, + { + "cell_type": "markdown", + "id": "b181bac8", + "metadata": { + "editable": true + }, + "source": [ + "## Decision trees, overarching aims\n", + "\n", + "We start here with the most basic algorithm, the so-called decision\n", + "tree. With this basic algorithm we can in turn build more complex\n", + "networks, spanning from homogeneous and heterogenous forests (bagging,\n", + "random forests and more) to one of the most popular supervised\n", + "algorithms nowadays, the extreme gradient boosting, or just\n", + "XGBoost. But let us start with the simplest possible ingredient.\n", + "\n", + "Decision trees are supervised learning algorithms used for both,\n", + "classification and regression tasks.\n", + "\n", + "The main idea of decision trees\n", + "is to find those descriptive features which contain the most\n", + "**information** regarding the target feature and then split the dataset\n", + "along the values of these features such that the target feature values\n", + "for the resulting underlying datasets are as pure as possible.\n", + "\n", + "The descriptive features which reproduce best the target/output features are normally said\n", + "to be the most informative ones. The process of finding the **most\n", + "informative** feature is done until we accomplish a stopping criteria\n", + "where we then finally end up in so called **leaf nodes**." + ] + }, + { + "cell_type": "markdown", + "id": "5c065b15", + "metadata": { + "editable": true + }, + "source": [ + "## Basics of a tree\n", + "\n", + "A decision tree is typically divided into a **root node**, the **interior nodes**,\n", + "and the final **leaf nodes** or just **leaves**. These entities are then connected by so-called **branches**.\n", + "\n", + "The leaf nodes\n", + "contain the predictions we will make for new query instances presented\n", + "to our trained model. This is possible since the model has \n", + "learned the underlying structure of the training data and hence can,\n", + "given some assumptions, make predictions about the target feature value\n", + "(class) of unseen query instances." + ] + }, + { + "cell_type": "markdown", + "id": "0685a1f3", + "metadata": { + "editable": true + }, + "source": [ + "## A Sketch of a Tree, Regression problem\n", + "\n", + "[See handwritten notes November 3](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2022/NotesNov32022.pdf)\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "9deb4609", + "metadata": { + "editable": true + }, + "source": [ + "## A Sketch of a Tree, Classification problem\n", + "\n", + "[See handwritten notes November 3](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2022/NotesNov32022.pdf)\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "971fbe6d", + "metadata": { + "editable": true + }, + "source": [ + "## A typical Decision Tree with its pertinent Jargon, Classification Problem\n", + "\n", + "\n", + "\n", + "\n", + "

Figure 1:

\n", + "\n", + "\n", + "This tree was produced using the Wisconsin cancer data (discussed here as well, see code examples below) using **Scikit-Learn**'s decision tree classifier. Here we have used the so-called **gini** index (see below) to split the various branches." + ] + }, + { + "cell_type": "markdown", + "id": "3c3fee0c", + "metadata": { + "editable": true + }, + "source": [ + "## General Features\n", + "\n", + "The overarching approach to decision trees is a top-down approach.\n", + "\n", + "* A leaf provides the classification of a given instance.\n", + "\n", + "* A node specifies a test of some attribute of the instance.\n", + "\n", + "* A branch corresponds to a possible values of an attribute.\n", + "\n", + "* An instance is classified by starting at the root node of the tree, testing the attribute specified by this node, then moving down the tree branch corresponding to the value of the attribute in the given example.\n", + "\n", + "This process is then repeated for the subtree rooted at the new\n", + "node." + ] + }, + { + "cell_type": "markdown", + "id": "5d7a417e", + "metadata": { + "editable": true + }, + "source": [ + "## How do we set it up?\n", + "\n", + "In simplified terms, the process of training a decision tree and\n", + "predicting the target features of query instances is as follows:\n", + "\n", + "1. Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature\n", + "\n", + "2. Train the decision tree model by continuously splitting the target feature along the values of the descriptive features using a measure of information gain during the training process\n", + "\n", + "3. Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the *predictions* we want to make for new query instances\n", + "\n", + "4. Show query instances to the tree and run down the tree until we arrive at leaf nodes\n", + "\n", + "Then we are essentially done!" + ] + }, + { + "cell_type": "markdown", + "id": "98739ae8", + "metadata": { + "editable": true + }, + "source": [ + "## Decision trees and Regression" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "2e75ab9e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "from sklearn.preprocessing import PolynomialFeatures\n", + "from sklearn.linear_model import LinearRegression\n", + "\n", + "steps=250\n", + "\n", + "distance=0\n", + "x=0\n", + "distance_list=[]\n", + "steps_list=[]\n", + "while x\n", + "\n", + "Grade Trend Hours slept Hours Studied Grade \n", + "\n", + "\n", + " Above Low High Above \n", + " Below High Low Below \n", + " Above Low High Above \n", + " Above High High Above \n", + " Below Low High Below \n", + " Above Low Low Below \n", + " Below High High Below \n", + " Below Low High Below \n", + " Above Low Low Below \n", + " Above High High Above \n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "8ba76cfd", + "metadata": { + "editable": true + }, + "source": [ + "## Computing the various Gini Indices\n", + "\n", + "In computations we will translate all classes into numbers. Being\n", + "these binary classes, they can easily be split into ones and zeros.\n", + "\n", + "**Gini index for Average trend.**\n", + "\n", + "[See handwritten notes November 3](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2022/NotesNov32022.pdf)" + ] + }, + { + "cell_type": "markdown", + "id": "a7a4d204", + "metadata": { + "editable": true + }, + "source": [ + "## Computing the various Gini Indices, Hours slept\n", + "\n", + "**Gini index for hour slept.**\n", + "\n", + "[See handwritten notes November 3](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2022/NotesNov32022.pdf)" + ] + }, + { + "cell_type": "markdown", + "id": "51de5c69", + "metadata": { + "editable": true + }, + "source": [ + "## Computing the various Gini Indices, Hours studied\n", + "\n", + "**Gini index for hour studied.**\n", + "\n", + "[See handwritten notes November 3](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2022/NotesNov32022.pdf)\n", + "\n", + "For final tree, see the above handwritten notes" + ] + }, + { + "cell_type": "markdown", + "id": "9f4bf856", + "metadata": { + "editable": true + }, + "source": [ + "## A possible code using Scikit-Learn" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "020402b2", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Common imports\n", + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.tree import export_graphviz\n", + "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n", + "from sklearn.compose import ColumnTransformer\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import os\n", + "\n", + "# Where to save the figures and data files\n", + "PROJECT_ROOT_DIR = \"Results\"\n", + "FIGURE_ID = \"Results/FigureFiles\"\n", + "DATA_ID = \"DataFiles/\"\n", + "\n", + "if not os.path.exists(PROJECT_ROOT_DIR):\n", + " os.mkdir(PROJECT_ROOT_DIR)\n", + "\n", + "if not os.path.exists(FIGURE_ID):\n", + " os.makedirs(FIGURE_ID)\n", + "\n", + "if not os.path.exists(DATA_ID):\n", + " os.makedirs(DATA_ID)\n", + "\n", + "def image_path(fig_id):\n", + " return os.path.join(FIGURE_ID, fig_id)\n", + "\n", + "def data_path(dat_id):\n", + " return os.path.join(DATA_ID, dat_id)\n", + "\n", + "def save_fig(fig_id):\n", + " plt.savefig(image_path(fig_id) + \".png\", format='png')\n", + "\n", + "infile = open(data_path(\"grades.csv\"),'r')\n", + "\n", + "# Read the experimental data with Pandas\n", + "from IPython.display import display\n", + "grades = pd.read_csv(infile)\n", + "grades = pd.DataFrame(grades)\n", + "display(grades)\n", + "# Features and targets\n", + "X = grades.loc[:, grades.columns != 'Grade'].values\n", + "y = grades.loc[:, grades.columns == 'Grade'].values\n", + "print(X)\n", + "# Then do a Classification tree\n", + "tree_clf = DecisionTreeClassifier(max_depth=2)\n", + "tree_clf.fit(X, y)\n", + "print(\"Train set accuracy with Decision Tree: {:.2f}\".format(tree_clf.score(X,y)))\n", + "#transfer to a decision tree graph\n", + "export_graphviz(\n", + " tree_clf,\n", + " out_file=\"DataFiles/grade.dot\",\n", + " rounded=True,\n", + " filled=True\n", + ")\n", + "cmd = 'dot -Tpng DataFiles/grade.dot -o DataFiles/grades.png'\n", + "os.system(cmd)" + ] + }, + { + "cell_type": "markdown", + "id": "082c7f06", + "metadata": { + "editable": true + }, + "source": [ + "## Further example: Computing the Gini index\n", + "\n", + "The next example we will look at is a classical one in many Machine\n", + "Learning applications. Based on various meteorological features, we\n", + "have several so-called attributes which decide whether we at the end\n", + "will do some outdoor activity like skiing, going for a bike ride etc\n", + "etc. The table here contains the feautures **outlook**, **temperature**,\n", + "**humidity** and **wind**. The target or output is whether we ride\n", + "(True=1) or whether we do something else that day (False=0). The\n", + "attributes for each feature are then sunny, overcast and rain for the\n", + "outlook, hot, cold and mild for temperature, high and normal for\n", + "humidity and weak and strong for wind.\n", + "\n", + "The table here summarizes the various attributes and\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
Day Outlook Temperature Humidity Wind Ride
1 Sunny Hot High Weak 0
2 Sunny Hot High Strong 1
3 Overcast Hot High Weak 1
4 Rain Mild High Weak 1
5 Rain Cool Normal Weak 1
6 Rain Cool Normal Strong 0
7 Overcast Cool Normal Strong 1
8 Sunny Mild High Weak 0
9 Sunny Cool Normal Weak 1
10 Rain Mild Normal Weak 1
11 Sunny Mild Normal Strong 1
12 Overcast Mild High Strong 1
13 Overcast Hot Normal Weak 1
14 Rain Mild High Strong 0
" + ] + }, + { + "cell_type": "markdown", + "id": "b742d7cc", + "metadata": { + "editable": true + }, + "source": [ + "## Simple Python Code to read in Data and perform Classification" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1f114a5a", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Common imports\n", + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.tree import export_graphviz\n", + "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n", + "from sklearn.compose import ColumnTransformer\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import os\n", + "\n", + "# Where to save the figures and data files\n", + "PROJECT_ROOT_DIR = \"Results\"\n", + "FIGURE_ID = \"Results/FigureFiles\"\n", + "DATA_ID = \"DataFiles/\"\n", + "\n", + "if not os.path.exists(PROJECT_ROOT_DIR):\n", + " os.mkdir(PROJECT_ROOT_DIR)\n", + "\n", + "if not os.path.exists(FIGURE_ID):\n", + " os.makedirs(FIGURE_ID)\n", + "\n", + "if not os.path.exists(DATA_ID):\n", + " os.makedirs(DATA_ID)\n", + "\n", + "def image_path(fig_id):\n", + " return os.path.join(FIGURE_ID, fig_id)\n", + "\n", + "def data_path(dat_id):\n", + " return os.path.join(DATA_ID, dat_id)\n", + "\n", + "def save_fig(fig_id):\n", + " plt.savefig(image_path(fig_id) + \".png\", format='png')\n", + "\n", + "infile = open(data_path(\"rideclass.csv\"),'r')\n", + "\n", + "# Read the experimental data with Pandas\n", + "from IPython.display import display\n", + "ridedata = pd.read_csv(infile,names = ('Outlook','Temperature','Humidity','Wind','Ride'))\n", + "ridedata = pd.DataFrame(ridedata)\n", + "\n", + "# Features and targets\n", + "X = ridedata.loc[:, ridedata.columns != 'Ride'].values\n", + "y = ridedata.loc[:, ridedata.columns == 'Ride'].values\n", + "\n", + "# Create the encoder.\n", + "encoder = OneHotEncoder(handle_unknown=\"ignore\")\n", + "# Assume for simplicity all features are categorical.\n", + "encoder.fit(X) \n", + "# Apply the encoder.\n", + "X = encoder.transform(X)\n", + "print(X)\n", + "# Then do a Classification tree\n", + "tree_clf = DecisionTreeClassifier(max_depth=2)\n", + "tree_clf.fit(X, y)\n", + "print(\"Train set accuracy with Decision Tree: {:.2f}\".format(tree_clf.score(X,y)))\n", + "#transfer to a decision tree graph\n", + "export_graphviz(\n", + " tree_clf,\n", + " out_file=\"DataFiles/ride.dot\",\n", + " rounded=True,\n", + " filled=True\n", + ")\n", + "cmd = 'dot -Tpng DataFiles/cancer.dot -o DataFiles/cancer.png'\n", + "os.system(cmd)" + ] + }, + { + "cell_type": "markdown", + "id": "3ae90db1", + "metadata": { + "editable": true + }, + "source": [ + "## Computing the Gini Factor\n", + "\n", + "The above functions (gini, entropy and misclassification error) are\n", + "important components of the so-called CART algorithm. We will discuss\n", + "this algorithm below after we have discussed the information gain\n", + "algorithm ID3.\n", + "\n", + "In the example here we have converted all our attributes into numerical values $0,1,2$ etc." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "22320738", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Split a dataset based on an attribute and an attribute value\n", + "def test_split(index, value, dataset):\n", + "\tleft, right = list(), list()\n", + "\tfor row in dataset:\n", + "\t\tif row[index] < value:\n", + "\t\t\tleft.append(row)\n", + "\t\telse:\n", + "\t\t\tright.append(row)\n", + "\treturn left, right\n", + " \n", + "# Calculate the Gini index for a split dataset\n", + "def gini_index(groups, classes):\n", + "\t# count all samples at split point\n", + "\tn_instances = float(sum([len(group) for group in groups]))\n", + "\t# sum weighted Gini index for each group\n", + "\tgini = 0.0\n", + "\tfor group in groups:\n", + "\t\tsize = float(len(group))\n", + "\t\t# avoid divide by zero\n", + "\t\tif size == 0:\n", + "\t\t\tcontinue\n", + "\t\tscore = 0.0\n", + "\t\t# score the group based on the score for each class\n", + "\t\tfor class_val in classes:\n", + "\t\t\tp = [row[-1] for row in group].count(class_val) / size\n", + "\t\t\tscore += p * p\n", + "\t\t# weight the group score by its relative size\n", + "\t\tgini += (1.0 - score) * (size / n_instances)\n", + "\treturn gini\n", + "\n", + "# Select the best split point for a dataset\n", + "def get_split(dataset):\n", + "\tclass_values = list(set(row[-1] for row in dataset))\n", + "\tb_index, b_value, b_score, b_groups = 999, 999, 999, None\n", + "\tfor index in range(len(dataset[0])-1):\n", + "\t\tfor row in dataset:\n", + "\t\t\tgroups = test_split(index, row[index], dataset)\n", + "\t\t\tgini = gini_index(groups, class_values)\n", + "\t\t\tprint('X%d < %.3f Gini=%.3f' % ((index+1), row[index], gini))\n", + "\t\t\tif gini < b_score:\n", + "\t\t\t\tb_index, b_value, b_score, b_groups = index, row[index], gini, groups\n", + "\treturn {'index':b_index, 'value':b_value, 'groups':b_groups}\n", + " \n", + "dataset = [[0,0,0,0,0],\n", + " [0,0,0,1,1],\n", + " [1,0,0,0,1],\n", + " [2,1,0,0,1],\n", + " [2,2,1,0,1],\n", + " [2,2,1,1,0],\n", + " [1,2,1,1,1],\n", + " [0,1,0,0,0],\n", + " [0,2,1,0,1],\n", + " [2,1,1,0,1],\n", + " [0,1,1,1,1],\n", + " [1,1,0,1,1],\n", + " [1,0,1,0,1],\n", + " [2,1,0,1,0]]\n", + "\n", + "split = get_split(dataset)\n", + "print('Split: [X%d < %.3f]' % ((split['index']+1), split['value']))" + ] + }, + { + "cell_type": "markdown", + "id": "ebd0ac9f", + "metadata": { + "editable": true + }, + "source": [ + "## Regression trees" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "bfdc5109", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Quadratic training set + noise\n", + "np.random.seed(42)\n", + "m = 200\n", + "X = np.random.rand(m, 1)\n", + "y = 4 * (X - 0.5) ** 2\n", + "y = y + np.random.randn(m, 1) / 10" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ab8bb0be", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.tree import DecisionTreeRegressor\n", + "\n", + "tree_reg = DecisionTreeRegressor(max_depth=2, random_state=42)\n", + "tree_reg.fit(X, y)" + ] + }, + { + "cell_type": "markdown", + "id": "b102de57", + "metadata": { + "editable": true + }, + "source": [ + "## Final regressor code" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "3aeec95d", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.tree import DecisionTreeRegressor\n", + "\n", + "tree_reg1 = DecisionTreeRegressor(random_state=42, max_depth=2)\n", + "tree_reg2 = DecisionTreeRegressor(random_state=42, max_depth=3)\n", + "tree_reg1.fit(X, y)\n", + "tree_reg2.fit(X, y)\n", + "\n", + "def plot_regression_predictions(tree_reg, X, y, axes=[0, 1, -0.2, 1], ylabel=\"$y$\"):\n", + " x1 = np.linspace(axes[0], axes[1], 500).reshape(-1, 1)\n", + " y_pred = tree_reg.predict(x1)\n", + " plt.axis(axes)\n", + " plt.xlabel(\"$x_1$\", fontsize=18)\n", + " if ylabel:\n", + " plt.ylabel(ylabel, fontsize=18, rotation=0)\n", + " plt.plot(X, y, \"b.\")\n", + " plt.plot(x1, y_pred, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n", + "\n", + "plt.figure(figsize=(11, 4))\n", + "plt.subplot(121)\n", + "plot_regression_predictions(tree_reg1, X, y)\n", + "for split, style in ((0.1973, \"k-\"), (0.0917, \"k--\"), (0.7718, \"k--\")):\n", + " plt.plot([split, split], [-0.2, 1], style, linewidth=2)\n", + "plt.text(0.21, 0.65, \"Depth=0\", fontsize=15)\n", + "plt.text(0.01, 0.2, \"Depth=1\", fontsize=13)\n", + "plt.text(0.65, 0.8, \"Depth=1\", fontsize=13)\n", + "plt.legend(loc=\"upper center\", fontsize=18)\n", + "plt.title(\"max_depth=2\", fontsize=14)\n", + "\n", + "plt.subplot(122)\n", + "plot_regression_predictions(tree_reg2, X, y, ylabel=None)\n", + "for split, style in ((0.1973, \"k-\"), (0.0917, \"k--\"), (0.7718, \"k--\")):\n", + " plt.plot([split, split], [-0.2, 1], style, linewidth=2)\n", + "for split in (0.0458, 0.1298, 0.2873, 0.9040):\n", + " plt.plot([split, split], [-0.2, 1], \"k:\", linewidth=1)\n", + "plt.text(0.3, 0.5, \"Depth=2\", fontsize=13)\n", + "plt.title(\"max_depth=3\", fontsize=14)\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "638f8ac8", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "tree_reg1 = DecisionTreeRegressor(random_state=42)\n", + "tree_reg2 = DecisionTreeRegressor(random_state=42, min_samples_leaf=10)\n", + "tree_reg1.fit(X, y)\n", + "tree_reg2.fit(X, y)\n", + "\n", + "x1 = np.linspace(0, 1, 500).reshape(-1, 1)\n", + "y_pred1 = tree_reg1.predict(x1)\n", + "y_pred2 = tree_reg2.predict(x1)\n", + "\n", + "plt.figure(figsize=(11, 4))\n", + "\n", + "plt.subplot(121)\n", + "plt.plot(X, y, \"b.\")\n", + "plt.plot(x1, y_pred1, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n", + "plt.axis([0, 1, -0.2, 1.1])\n", + "plt.xlabel(\"$x_1$\", fontsize=18)\n", + "plt.ylabel(\"$y$\", fontsize=18, rotation=0)\n", + "plt.legend(loc=\"upper center\", fontsize=18)\n", + "plt.title(\"No restrictions\", fontsize=14)\n", + "\n", + "plt.subplot(122)\n", + "plt.plot(X, y, \"b.\")\n", + "plt.plot(x1, y_pred2, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n", + "plt.axis([0, 1, -0.2, 1.1])\n", + "plt.xlabel(\"$x_1$\", fontsize=18)\n", + "plt.title(\"min_samples_leaf={}\".format(tree_reg2.min_samples_leaf), fontsize=14)\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "939c2f5c", + "metadata": { + "editable": true + }, + "source": [ + "## Pros and cons of trees, pros\n", + "\n", + "* White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)\n", + "\n", + "* Trees are very easy to explain to people. In fact, they are even easier to explain than linear regression!\n", + "\n", + "* No feature normalization needed\n", + "\n", + "* Tree models can handle both continuous and categorical data (Classification and Regression Trees)\n", + "\n", + "* Can model nonlinear relationships\n", + "\n", + "* Can model interactions between the different descriptive features\n", + "\n", + "* Trees can be displayed graphically, and are easily interpreted even by a non-expert (especially if they are small)" + ] + }, + { + "cell_type": "markdown", + "id": "121bdc13", + "metadata": { + "editable": true + }, + "source": [ + "## Disadvantages\n", + "\n", + "* Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches\n", + "\n", + "* If continuous features are used the tree may become quite large and hence less interpretable\n", + "\n", + "* Decision trees are prone to overfit the training data and hence do not well generalize the data if no stopping criteria or improvements like pruning, boosting or bagging are implemented\n", + "\n", + "* Small changes in the data may lead to a completely different tree. This issue can be addressed by using ensemble methods like bagging, boosting or random forests\n", + "\n", + "* Unbalanced datasets where some target feature values occur much more frequently than others may lead to biased trees since the frequently occurring feature values are preferred over the less frequently occurring ones. \n", + "\n", + "* If the number of features is relatively large (high dimensional) and the number of instances is relatively low, the tree might overfit the data\n", + "\n", + "* Features with many levels may be preferred over features with less levels since for them it is *more easy* to split the dataset such that the sub datasets only contain pure target feature values. This issue can be addressed by preferring for instance the information gain ratio as splitting criteria over information gain\n", + "\n", + "However, by aggregating many decision trees, using methods like\n", + "bagging, random forests, and boosting, the predictive performance of\n", + "trees can be substantially improved." + ] + }, + { + "cell_type": "markdown", + "id": "f58b9924", + "metadata": { + "editable": true + }, + "source": [ + "## Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods\n", + "\n", + "As stated above and seen in many of the examples discussed here about\n", + "a single decision tree, we often end up overfitting our training\n", + "data. This normally means that we have a high variance. Can we reduce\n", + "the variance of a statistical learning method?\n", + "\n", + "This leads us to a set of different methods that can combine different\n", + "machine learning algorithms or just use one of them to construct\n", + "forests and jungles of trees, homogeneous ones or heterogenous\n", + "ones. These methods are recognized by different names which we will\n", + "try to explain here. These are\n", + "\n", + "1. Voting classifiers\n", + "\n", + "2. Bagging and Pasting\n", + "\n", + "3. Random forests\n", + "\n", + "4. Boosting methods, from adaptive to Extreme Gradient Boosting (XGBoost)\n", + "\n", + "We discuss these methods here." + ] + }, + { + "cell_type": "markdown", + "id": "3369dc37", + "metadata": { + "editable": true + }, + "source": [ + "## An Overview of Ensemble Methods\n", + "\n", + "\n", + "\n", + "\n", + "

Figure 1:

\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "247d8e1f", + "metadata": { + "editable": true + }, + "source": [ + "## Why Voting?\n", + "\n", + "The idea behind boosting, and voting as well can be phrased as follows:\n", + "**Can a group of people somehow arrive at highly\n", + "reasoned decisions, despite the weak judgement of the individual\n", + "members?**\n", + "\n", + "The aim is to create a good classifier by combining several weak classifiers.\n", + "**A weak classifier is a classifier which is able to produce results that are only slightly better than guessing at random.**\n", + "\n", + "The basic approach is to apply repeatedly (in boosting this is done in an iterative way) a weak classifier to modifications of the data.\n", + "In voting we simply apply the law of large numbers while in boosting we give more weight to misclassified data in\n", + "each iteration. \n", + "\n", + "Decision trees play an important role as our weak classifier. They serve as the basic method." + ] + }, + { + "cell_type": "markdown", + "id": "418dee56", + "metadata": { + "editable": true + }, + "source": [ + "## Tossing coins\n", + "\n", + "The simplest case is a so-called voting ensemble. To illustrate this,\n", + "think of yourself tossing coins with a biased outcome of 51 per cent\n", + "for heads and 49% for tails. With only few tosses,\n", + "you may not clearly see this distribution for heads and tails. However, after some\n", + "thousands of tosses, there will be a clear majority of heads. With 2000 tosses\n", + "you should see approximately 1020 heads and 980 tails.\n", + "\n", + "We can then state that the outcome is a clear majority of heads. If\n", + "you do this ten thousand times, it is easy to see that there is a 97%\n", + "likelihood of a majority of heads.\n", + "\n", + "Another example would be to collect all polls before an\n", + "election. Different polls may show different likelihoods for a\n", + "candidate winning with say a majority of the popular vote. The majority vote\n", + "would then consist in many polls indicating that this candidate will\n", + "actually win.\n", + "\n", + "The example here shows how we can implement the coin tossing case,\n", + "clealry demostrating that after some tosses we see the [law of large](https://en.wikipedia.org/wiki/Law_of_large_numbers)\n", + "numbers kicking in." + ] + }, + { + "cell_type": "markdown", + "id": "81c7b4f6", + "metadata": { + "editable": true + }, + "source": [ + "## Standard imports first" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "c8635354", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Common imports\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import pandas as pd\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.tree import export_graphviz\n", + "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n", + "from sklearn.compose import ColumnTransformer\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import os\n", + "\n", + "# Where to save the figures and data files\n", + "PROJECT_ROOT_DIR = \"Results\"\n", + "FIGURE_ID = \"Results/FigureFiles\"\n", + "DATA_ID = \"DataFiles/\"\n", + "\n", + "if not os.path.exists(PROJECT_ROOT_DIR):\n", + " os.mkdir(PROJECT_ROOT_DIR)\n", + "\n", + "if not os.path.exists(FIGURE_ID):\n", + " os.makedirs(FIGURE_ID)\n", + "\n", + "if not os.path.exists(DATA_ID):\n", + " os.makedirs(DATA_ID)\n", + "\n", + "def image_path(fig_id):\n", + " return os.path.join(FIGURE_ID, fig_id)\n", + "\n", + "def data_path(dat_id):\n", + " return os.path.join(DATA_ID, dat_id)\n", + "\n", + "def save_fig(fig_id):\n", + " plt.savefig(image_path(fig_id) + \".png\", format='png')" + ] + }, + { + "cell_type": "markdown", + "id": "6945cdc1", + "metadata": { + "editable": true + }, + "source": [ + "## Simple Voting Example, head or tail" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "dbe486ef", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "# Common imports\n", + "import numpy as np\n", + "import matplotlib\n", + "import matplotlib.pyplot as plt\n", + "from matplotlib.colors import ListedColormap\n", + "plt.rcParams['axes.labelsize'] = 14\n", + "plt.rcParams['xtick.labelsize'] = 12\n", + "plt.rcParams['ytick.labelsize'] = 12\n", + "\n", + "heads_proba = 0.51\n", + "coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)\n", + "cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)\n", + "plt.figure(figsize=(8,3.5))\n", + "plt.plot(cumulative_heads_ratio)\n", + "plt.plot([0, 10000], [0.51, 0.51], \"k--\", linewidth=2, label=\"51%\")\n", + "plt.plot([0, 10000], [0.5, 0.5], \"k-\", label=\"50%\")\n", + "plt.xlabel(\"Number of coin tosses\")\n", + "plt.ylabel(\"Heads ratio\")\n", + "plt.legend(loc=\"lower right\")\n", + "plt.axis([0, 10000, 0.42, 0.58])\n", + "save_fig(\"votingsimple\")\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "31814f98", + "metadata": { + "editable": true + }, + "source": [ + "## Using the Voting Classifier\n", + "\n", + "We can use the voting classifier on other data sets, here the exciting binary case of two distinct objects using the make moons functionality of **Scikit-Learn**." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "20858a25", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "from sklearn.datasets import make_moons\n", + "\n", + "X, y = make_moons(n_samples=500, noise=0.30, random_state=42)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n", + "\n", + "from sklearn.ensemble import RandomForestClassifier\n", + "from sklearn.ensemble import VotingClassifier\n", + "from sklearn.linear_model import LogisticRegression\n", + "from sklearn.svm import SVC\n", + "\n", + "log_clf = LogisticRegression(solver=\"liblinear\", random_state=42)\n", + "rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n", + "svm_clf = SVC(gamma=\"auto\", random_state=42)\n", + "\n", + "voting_clf = VotingClassifier(\n", + " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", + " voting='hard')\n", + "\n", + "voting_clf.fit(X_train, y_train)\n", + "\n", + "from sklearn.metrics import accuracy_score\n", + "\n", + "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", + " clf.fit(X_train, y_train)\n", + " y_pred = clf.predict(X_test)\n", + " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))\n", + "\n", + "log_clf = LogisticRegression(solver=\"liblinear\", random_state=42)\n", + "rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n", + "svm_clf = SVC(gamma=\"auto\", probability=True, random_state=42)\n", + "voting_clf = VotingClassifier(\n", + " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", + " voting='soft')\n", + "voting_clf.fit(X_train, y_train)\n", + "\n", + "from sklearn.metrics import accuracy_score\n", + "\n", + "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", + " clf.fit(X_train, y_train)\n", + " y_pred = clf.predict(X_test)\n", + " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "id": "69bde19e", + "metadata": { + "editable": true + }, + "source": [ + "## Voting and Bagging" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "579fcaba", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "from sklearn.datasets import make_moons\n", + "\n", + "X, y = make_moons(n_samples=500, noise=0.30, random_state=42)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n", + "from sklearn.ensemble import RandomForestClassifier\n", + "from sklearn.ensemble import VotingClassifier\n", + "from sklearn.linear_model import LogisticRegression\n", + "from sklearn.svm import SVC\n", + "\n", + "log_clf = LogisticRegression(random_state=42)\n", + "rnd_clf = RandomForestClassifier(random_state=42)\n", + "svm_clf = SVC(random_state=42)\n", + "\n", + "voting_clf = VotingClassifier(\n", + " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", + " voting='hard')\n", + "voting_clf.fit(X_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "e19aed80", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.metrics import accuracy_score\n", + "\n", + "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", + " clf.fit(X_train, y_train)\n", + " y_pred = clf.predict(X_test)\n", + " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "5e7fff36", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "log_clf = LogisticRegression(random_state=42)\n", + "rnd_clf = RandomForestClassifier(random_state=42)\n", + "svm_clf = SVC(probability=True, random_state=42)\n", + "\n", + "voting_clf = VotingClassifier(\n", + " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", + " voting='soft')\n", + "voting_clf.fit(X_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "12a367f0", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.metrics import accuracy_score\n", + "\n", + "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", + " clf.fit(X_train, y_train)\n", + " y_pred = clf.predict(X_test)\n", + " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "id": "70753458", + "metadata": { + "editable": true + }, + "source": [ + "## Bagging\n", + "\n", + "The **plain** decision trees suffer from high\n", + "variance. This means that if we split the training data into two parts\n", + "at random, and fit a decision tree to both halves, the results that we\n", + "get could be quite different. In contrast, a procedure with low\n", + "variance will yield similar results if applied repeatedly to distinct\n", + "data sets; linear regression tends to have low variance, if the ratio\n", + "of $n$ to $p$ is moderately large. \n", + "\n", + "**Bootstrap aggregation**, or just **bagging**, is a\n", + "general-purpose procedure for reducing the variance of a statistical\n", + "learning method." + ] + }, + { + "cell_type": "markdown", + "id": "d37bbe68", + "metadata": { + "editable": true + }, + "source": [ + "## More bagging\n", + "\n", + "Bagging typically results in improved accuracy\n", + "over prediction using a single tree. Unfortunately, however, it can be\n", + "difficult to interpret the resulting model. Recall that one of the\n", + "advantages of decision trees is the attractive and easily interpreted\n", + "diagram that results.\n", + "\n", + "However, when we bag a large number of trees, it is no longer\n", + "possible to represent the resulting statistical learning procedure\n", + "using a single tree, and it is no longer clear which variables are\n", + "most important to the procedure. Thus, bagging improves prediction\n", + "accuracy at the expense of interpretability. Although the collection\n", + "of bagged trees is much more difficult to interpret than a single\n", + "tree, one can obtain an overall summary of the importance of each\n", + "predictor using the MSE (for bagging regression trees) or the Gini\n", + "index (for bagging classification trees). In the case of bagging\n", + "regression trees, we can record the total amount that the MSE is\n", + "decreased due to splits over a given predictor, averaged over all $B$ possible\n", + "trees. A large value indicates an important predictor. Similarly, in\n", + "the context of bagging classification trees, we can add up the total\n", + "amount that the Gini index is decreased by splits over a given\n", + "predictor, averaged over all $B$ trees." + ] + }, + { + "cell_type": "markdown", + "id": "498956cc", + "metadata": { + "editable": true + }, + "source": [ + "## Making your own Bootstrap: Changing the Level of the Decision Tree\n", + "\n", + "Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with\n", + "a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points $n$)." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "452de3bb", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.pipeline import make_pipeline\n", + "from sklearn.utils import resample\n", + "from sklearn.tree import DecisionTreeRegressor\n", + "\n", + "n = 100\n", + "n_boostraps = 100\n", + "maxdepth = 8\n", + "\n", + "# Make data set.\n", + "x = np.linspace(-3, 3, n).reshape(-1, 1)\n", + "y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)\n", + "error = np.zeros(maxdepth)\n", + "bias = np.zeros(maxdepth)\n", + "variance = np.zeros(maxdepth)\n", + "polydegree = np.zeros(maxdepth)\n", + "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n", + "\n", + "from sklearn.preprocessing import StandardScaler\n", + "scaler = StandardScaler()\n", + "scaler.fit(X_train)\n", + "X_train_scaled = scaler.transform(X_train)\n", + "X_test_scaled = scaler.transform(X_test)\n", + "\n", + "# we produce a simple tree first as benchmark\n", + "simpletree = DecisionTreeRegressor(max_depth=3) \n", + "simpletree.fit(X_train_scaled, y_train)\n", + "simpleprediction = simpletree.predict(X_test_scaled)\n", + "for degree in range(1,maxdepth):\n", + " model = DecisionTreeRegressor(max_depth=degree) \n", + " y_pred = np.empty((y_test.shape[0], n_boostraps))\n", + " for i in range(n_boostraps):\n", + " x_, y_ = resample(X_train_scaled, y_train)\n", + " model.fit(x_, y_)\n", + " y_pred[:, i] = model.predict(X_test_scaled)#.ravel()\n", + "\n", + " polydegree[degree] = degree\n", + " error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )\n", + " bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )\n", + " variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )\n", + " print('Polynomial degree:', degree)\n", + " print('Error:', error[degree])\n", + " print('Bias^2:', bias[degree])\n", + " print('Var:', variance[degree])\n", + " print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))\n", + " \n", + "mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2))\n", + "print(\"Simple tree:\",mse_simpletree)\n", + "plt.xlim(1,maxdepth)\n", + "plt.plot(polydegree, error, label='MSE')\n", + "plt.plot(polydegree, bias, label='bias')\n", + "plt.plot(polydegree, variance, label='Variance')\n", + "plt.legend()\n", + "save_fig(\"baggingboot\")\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "b7a39b9f", + "metadata": { + "editable": true + }, + "source": [ + "## Random forests\n", + "\n", + "Random forests provide an improvement over bagged trees by way of a\n", + "small tweak that decorrelates the trees. \n", + "\n", + "As in bagging, we build a\n", + "number of decision trees on bootstrapped training samples. But when\n", + "building these decision trees, each time a split in a tree is\n", + "considered, a random sample of $m$ predictors is chosen as split\n", + "candidates from the full set of $p$ predictors. The split is allowed to\n", + "use only one of those $m$ predictors. \n", + "\n", + "A fresh sample of $m$ predictors is\n", + "taken at each split, and typically we choose" + ] + }, + { + "cell_type": "markdown", + "id": "d39a6e13", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "m\\approx \\sqrt{p}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "42f8693b", + "metadata": { + "editable": true + }, + "source": [ + "In building a random forest, at\n", + "each split in the tree, the algorithm is not even allowed to consider\n", + "a majority of the available predictors. \n", + "\n", + "The reason for this is rather clever. Suppose that there is one very\n", + "strong predictor in the data set, along with a number of other\n", + "moderately strong predictors. Then in the collection of bagged\n", + "variable importance random forest trees, most or all of the trees will\n", + "use this strong predictor in the top split. Consequently, all of the\n", + "bagged trees will look quite similar to each other. Hence the\n", + "predictions from the bagged trees will be highly correlated.\n", + "Unfortunately, averaging many highly correlated quantities does not\n", + "lead to as large of a reduction in variance as averaging many\n", + "uncorrelated quantities. In particular, this means that bagging will\n", + "not lead to a substantial reduction in variance over a single tree in\n", + "this setting." + ] + }, + { + "cell_type": "markdown", + "id": "a25fd53e", + "metadata": { + "editable": true + }, + "source": [ + "## Random Forest Algorithm\n", + "The algorithm described here can be applied to both classification and regression problems.\n", + "\n", + "We will grow of forest of say $B$ trees.\n", + "1. For $b=1:B$\n", + "\n", + " * Draw a bootstrap sample from the training data organized in our $\\boldsymbol{X}$ matrix.\n", + "\n", + " * We grow then a random forest tree $T_b$ based on the bootstrapped data by repeating the steps outlined till we reach the maximum node size is reached\n", + "\n", + "1. we select $m \\le p$ variables at random from the $p$ predictors/features\n", + "\n", + "2. pick the best split point among the $m$ features using for example the CART algorithm and create a new node\n", + "\n", + "3. split the node into daughter nodes\n", + "\n", + "4. Output then the ensemble of trees $\\{T_b\\}_1^{B}$ and make predictions for either a regression type of problem or a classification type of problem." + ] + }, + { + "cell_type": "markdown", + "id": "c72f80ca", + "metadata": { + "editable": true + }, + "source": [ + "## Random Forests Compared with other Methods on the Cancer Data" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "9b20111b", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from sklearn.model_selection import train_test_split \n", + "from sklearn.datasets import load_breast_cancer\n", + "from sklearn.svm import SVC\n", + "from sklearn.linear_model import LogisticRegression\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.ensemble import BaggingClassifier\n", + "\n", + "# Load the data\n", + "cancer = load_breast_cancer()\n", + "\n", + "X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)\n", + "print(X_train.shape)\n", + "print(X_test.shape)\n", + "#define methods\n", + "# Logistic Regression\n", + "logreg = LogisticRegression(solver='lbfgs')\n", + "# Support vector machine\n", + "svm = SVC(gamma='auto', C=100)\n", + "# Decision Trees\n", + "deep_tree_clf = DecisionTreeClassifier(max_depth=None)\n", + "#Scale the data\n", + "from sklearn.preprocessing import StandardScaler\n", + "scaler = StandardScaler()\n", + "scaler.fit(X_train)\n", + "X_train_scaled = scaler.transform(X_train)\n", + "X_test_scaled = scaler.transform(X_test)\n", + "# Logistic Regression\n", + "logreg.fit(X_train_scaled, y_train)\n", + "print(\"Test set accuracy Logistic Regression with scaled data: {:.2f}\".format(logreg.score(X_test_scaled,y_test)))\n", + "# Support Vector Machine\n", + "svm.fit(X_train_scaled, y_train)\n", + "print(\"Test set accuracy SVM with scaled data: {:.2f}\".format(logreg.score(X_test_scaled,y_test)))\n", + "# Decision Trees\n", + "deep_tree_clf.fit(X_train_scaled, y_train)\n", + "print(\"Test set accuracy with Decision Trees and scaled data: {:.2f}\".format(deep_tree_clf.score(X_test_scaled,y_test)))\n", + "\n", + "\n", + "from sklearn.ensemble import RandomForestClassifier\n", + "from sklearn.preprocessing import LabelEncoder\n", + "from sklearn.model_selection import cross_validate\n", + "# Data set not specificied\n", + "#Instantiate the model with 500 trees and entropy as splitting criteria\n", + "Random_Forest_model = RandomForestClassifier(n_estimators=500,criterion=\"entropy\")\n", + "Random_Forest_model.fit(X_train_scaled, y_train)\n", + "#Cross validation\n", + "accuracy = cross_validate(Random_Forest_model,X_test_scaled,y_test,cv=10)['test_score']\n", + "print(accuracy)\n", + "print(\"Test set accuracy with Random Forests and scaled data: {:.2f}\".format(Random_Forest_model.score(X_test_scaled,y_test)))\n", + "\n", + "\n", + "import scikitplot as skplt\n", + "y_pred = Random_Forest_model.predict(X_test_scaled)\n", + "skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n", + "plt.show()\n", + "y_probas = Random_Forest_model.predict_proba(X_test_scaled)\n", + "skplt.metrics.plot_roc(y_test, y_probas)\n", + "plt.show()\n", + "skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "a2a69156", + "metadata": { + "editable": true + }, + "source": [ + "Recall that the cumulative gains curve shows the percentage of the\n", + "overall number of cases in a given category *gained* by targeting a\n", + "percentage of the total number of cases.\n", + "\n", + "Similarly, the receiver operating characteristic curve, or ROC curve,\n", + "displays the diagnostic ability of a binary classifier system as its\n", + "discrimination threshold is varied. It plots the true positive rate against the false positive rate." + ] + }, + { + "cell_type": "markdown", + "id": "935e5ca1", + "metadata": { + "editable": true + }, + "source": [ + "## Compare Bagging on Trees with Random Forests" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "2b6604c5", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "bag_clf = BaggingClassifier(\n", + " DecisionTreeClassifier(splitter=\"random\", max_leaf_nodes=16, random_state=42),\n", + " n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1, random_state=42)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "b6412285", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "bag_clf.fit(X_train, y_train)\n", + "y_pred = bag_clf.predict(X_test)\n", + "from sklearn.ensemble import RandomForestClassifier\n", + "rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1, random_state=42)\n", + "rnd_clf.fit(X_train, y_train)\n", + "y_pred_rf = rnd_clf.predict(X_test)\n", + "np.sum(y_pred == y_pred_rf) / len(y_pred)" + ] + }, + { + "cell_type": "markdown", + "id": "c8adc4f4", + "metadata": { + "editable": true + }, + "source": [ + "## Boosting, a Bird's Eye View\n", + "\n", + "The basic idea is to combine weak classifiers in order to create a good\n", + "classifier. With a weak classifier we often intend a classifier which\n", + "produces results which are only slightly better than we would get by\n", + "random guesses.\n", + "\n", + "This is done by applying in an iterative way a weak (or a standard\n", + "classifier like decision trees) to modify the data. In each iteration\n", + "we emphasize those observations which are misclassified by weighting\n", + "them with a factor." + ] + }, + { + "cell_type": "markdown", + "id": "e0bd3a34", + "metadata": { + "editable": true + }, + "source": [ + "## What is boosting? Additive Modelling/Iterative Fitting\n", + "\n", + "Boosting is a way of fitting an additive expansion in a set of\n", + "elementary basis functions like for example some simple polynomials.\n", + "Assume for example that we have a function" + ] + }, + { + "cell_type": "markdown", + "id": "b93c398e", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f_M(x) = \\sum_{i=1}^M \\beta_m b(x;\\gamma_m),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7fc3ae93", + "metadata": { + "editable": true + }, + "source": [ + "where $\\beta_m$ are the expansion parameters to be determined in a\n", + "minimization process and $b(x;\\gamma_m)$ are some simple functions of\n", + "the multivariable parameter $x$ which is characterized by the\n", + "parameters $\\gamma_m$.\n", + "\n", + "As an example, consider the Sigmoid function we used in logistic\n", + "regression. In that case, we can translate the function\n", + "$b(x;\\gamma_m)$ into the Sigmoid function" + ] + }, + { + "cell_type": "markdown", + "id": "e5c67b21", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\sigma(t) = \\frac{1}{1+\\exp{(-t)}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2d573725", + "metadata": { + "editable": true + }, + "source": [ + "where $t=\\gamma_0+\\gamma_1 x$ and the parameters $\\gamma_0$ and\n", + "$\\gamma_1$ were determined by the Logistic Regression fitting\n", + "algorithm.\n", + "\n", + "As another example, consider the cost function we defined for linear regression" + ] + }, + { + "cell_type": "markdown", + "id": "f8cf15d3", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C(\\boldsymbol{y},\\boldsymbol{f}) = \\frac{1}{n} \\sum_{i=0}^{n-1}(y_i-f(x_i))^2.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e734d8d4", + "metadata": { + "editable": true + }, + "source": [ + "In this case the function $f(x)$ was replaced by the design matrix\n", + "$\\boldsymbol{X}$ and the unknown linear regression parameters $\\boldsymbol{\\beta}$,\n", + "that is $\\boldsymbol{f}=\\boldsymbol{X}\\boldsymbol{\\beta}$. In linear regression we can \n", + "simply invert a matrix and obtain the parameters $\\beta$ by" + ] + }, + { + "cell_type": "markdown", + "id": "0585b995", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\boldsymbol{\\beta}=\\left(\\boldsymbol{X}^T\\boldsymbol{X}\\right)^{-1}\\boldsymbol{X}^T\\boldsymbol{y}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b983e555", + "metadata": { + "editable": true + }, + "source": [ + "In iterative fitting or additive modeling, we minimize the cost function with respect to the parameters $\\beta_m$ and $\\gamma_m$." + ] + }, + { + "cell_type": "markdown", + "id": "203a7a1c", + "metadata": { + "editable": true + }, + "source": [ + "## Iterative Fitting, Regression and Squared-error Cost Function\n", + "\n", + "The way we proceed is as follows (here we specialize to the squared-error cost function)\n", + "\n", + "1. Establish a cost function, here $C(\\boldsymbol{y},\\boldsymbol{f}) = \\frac{1}{n} \\sum_{i=0}^{n-1}(y_i-f_M(x_i))^2$ with $f_M(x) = \\sum_{i=1}^M \\beta_m b(x;\\gamma_m)$.\n", + "\n", + "2. Initialize with a guess $f_0(x)$. It could be one or even zero or some random numbers.\n", + "\n", + "3. For $m=1:M$\n", + "\n", + "a. minimize $\\sum_{i=0}^{n-1}(y_i-f_{m-1}(x_i)-\\beta b(x;\\gamma))^2$ wrt $\\gamma$ and $\\beta$\n", + "\n", + "b. This gives the optimal values $\\beta_m$ and $\\gamma_m$\n", + "\n", + "c. Determine then the new values $f_m(x)=f_{m-1}(x) +\\beta_m b(x;\\gamma_m)$\n", + "\n", + "We could use any of the algorithms we have discussed till now. If we\n", + "use trees, $\\gamma$ parameterizes the split variables and split points\n", + "at the internal nodes, and the predictions at the terminal nodes." + ] + }, + { + "cell_type": "markdown", + "id": "6d391d0c", + "metadata": { + "editable": true + }, + "source": [ + "## Squared-Error Example and Iterative Fitting\n", + "\n", + "To better understand what happens, let us develop the steps for the iterative fitting using the above squared error function.\n", + "\n", + "For simplicity we assume also that our functions $b(x;\\gamma)=1+\\gamma x$. \n", + "\n", + "This means that for every iteration $m$, we need to optimize" + ] + }, + { + "cell_type": "markdown", + "id": "3b98bb46", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "(\\beta_m,\\gamma_m) = \\mathrm{argmin}_{\\beta,\\lambda}\\hspace{0.1cm} \\sum_{i=0}^{n-1}(y_i-f_{m-1}(x_i)-\\beta b(x;\\gamma))^2=\\sum_{i=0}^{n-1}(y_i-f_{m-1}(x_i)-\\beta(1+\\gamma x_i))^2.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3d2a99d8", + "metadata": { + "editable": true + }, + "source": [ + "We start our iteration by simply setting $f_0(x)=0$. \n", + "Taking the derivatives with respect to $\\beta$ and $\\gamma$ we obtain" + ] + }, + { + "cell_type": "markdown", + "id": "3af9f679", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial {\\cal C}}{\\partial \\beta} = -2\\sum_{i}(1+\\gamma x_i)(y_i-\\beta(1+\\gamma x_i))=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "368371bc", + "metadata": { + "editable": true + }, + "source": [ + "and" + ] + }, + { + "cell_type": "markdown", + "id": "ebc23cc6", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial {\\cal C}}{\\partial \\gamma} =-2\\sum_{i}\\beta x_i(y_i-\\beta(1+\\gamma x_i))=0.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3285cd00", + "metadata": { + "editable": true + }, + "source": [ + "We can then rewrite these equations as (defining $\\boldsymbol{w}=\\boldsymbol{e}+\\gamma \\boldsymbol{x})$ with $\\boldsymbol{e}$ being the unit vector)" + ] + }, + { + "cell_type": "markdown", + "id": "420c5c35", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\gamma \\boldsymbol{w}^T(\\boldsymbol{y}-\\beta\\gamma \\boldsymbol{w})=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2a386bd3", + "metadata": { + "editable": true + }, + "source": [ + "which gives us $\\beta = \\boldsymbol{w}^T\\boldsymbol{y}/(\\boldsymbol{w}^T\\boldsymbol{w})$. Similarly we have" + ] + }, + { + "cell_type": "markdown", + "id": "cb75d383", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\beta\\gamma \\boldsymbol{x}^T(\\boldsymbol{y}-\\beta(1+\\gamma \\boldsymbol{x}))=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "d7aac8e6", + "metadata": { + "editable": true + }, + "source": [ + "which leads to $\\gamma =(\\boldsymbol{x}^T\\boldsymbol{y}-\\beta\\boldsymbol{x}^T\\boldsymbol{e})/(\\beta\\boldsymbol{x}^T\\boldsymbol{x})$. Inserting\n", + "for $\\beta$ gives us an equation for $\\gamma$. This is a non-linear equation in the unknown $\\gamma$ and has to be solved numerically. \n", + "\n", + "The solution to these two equations gives us in turn $\\beta_1$ and $\\gamma_1$ leading to the new expression for $f_1(x)$ as\n", + "$f_1(x) = \\beta_1(1+\\gamma_1x)$. Doing this $M$ times results in our final estimate for the function $f$." + ] + }, + { + "cell_type": "markdown", + "id": "8211e34f", + "metadata": { + "editable": true + }, + "source": [ + "## Iterative Fitting, Classification and AdaBoost\n", + "\n", + "Let us consider a binary classification problem with two outcomes $y_i \\in \\{-1,1\\}$ and $i=0,1,2,\\dots,n-1$ as our set of\n", + "observations. We define a classification function $G(x)$ which produces a prediction taking one or the other of the two values \n", + "$\\{-1,1\\}$.\n", + "\n", + "The error rate of the training sample is then" + ] + }, + { + "cell_type": "markdown", + "id": "0759bace", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{\\overline{err}}=\\frac{1}{n} \\sum_{i=0}^{n-1} I(y_i\\ne G(x_i)).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "6a08f8a3", + "metadata": { + "editable": true + }, + "source": [ + "The iterative procedure starts with defining a weak classifier whose\n", + "error rate is barely better than random guessing. The iterative\n", + "procedure in boosting is to sequentially apply a weak\n", + "classification algorithm to repeatedly modified versions of the data\n", + "producing a sequence of weak classifiers $G_m(x)$.\n", + "\n", + "Here we will express our function $f(x)$ in terms of $G(x)$. That is" + ] + }, + { + "cell_type": "markdown", + "id": "ea71963f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f_M(x) = \\sum_{i=1}^M \\beta_m b(x;\\gamma_m),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "42c5df3b", + "metadata": { + "editable": true + }, + "source": [ + "will be a function of" + ] + }, + { + "cell_type": "markdown", + "id": "237180f9", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "G_M(x) = \\mathrm{sign} \\sum_{i=1}^M \\alpha_m G_m(x).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2374907b", + "metadata": { + "editable": true + }, + "source": [ + "## Adaptive Boosting, AdaBoost\n", + "\n", + "In our iterative procedure we define thus" + ] + }, + { + "cell_type": "markdown", + "id": "04048caf", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f_m(x) = f_{m-1}(x)+\\beta_mG_m(x).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "1a77afe0", + "metadata": { + "editable": true + }, + "source": [ + "The simplest possible cost function which leads (also simple from a computational point of view) to the AdaBoost algorithm is the\n", + "exponential cost/loss function defined as" + ] + }, + { + "cell_type": "markdown", + "id": "981883bd", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C(\\boldsymbol{y},\\boldsymbol{f}) = \\sum_{i=0}^{n-1}\\exp{(-y_i(f_{m-1}(x_i)+\\beta G(x_i))}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3d8d3830", + "metadata": { + "editable": true + }, + "source": [ + "We optimize $\\beta$ and $G$ for each value of $m=1:M$ as we did in the regression case.\n", + "This is normally done in two steps. Let us however first rewrite the cost function as" + ] + }, + { + "cell_type": "markdown", + "id": "fe3d598c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C(\\boldsymbol{y},\\boldsymbol{f}) = \\sum_{i=0}^{n-1}w_i^{m}\\exp{(-y_i\\beta G(x_i))},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "762ac6b8", + "metadata": { + "editable": true + }, + "source": [ + "where we have defined $w_i^m= \\exp{(-y_if_{m-1}(x_i))}$." + ] + }, + { + "cell_type": "markdown", + "id": "396805d8", + "metadata": { + "editable": true + }, + "source": [ + "## Building up AdaBoost\n", + "\n", + "First, for any $\\beta > 0$, we optimize $G$ by setting" + ] + }, + { + "cell_type": "markdown", + "id": "19ca93fe", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "G_m(x) = \\mathrm{sign} \\sum_{i=0}^{n-1} w_i^m I(y_i \\ne G_(x_i)),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5b78c347", + "metadata": { + "editable": true + }, + "source": [ + "which is the classifier that minimizes the weighted error rate in predicting $y$.\n", + "\n", + "We can do this by rewriting" + ] + }, + { + "cell_type": "markdown", + "id": "742c335a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\exp{-(\\beta)}\\sum_{y_i=G(x_i)}w_i^m+\\exp{(\\beta)}\\sum_{y_i\\ne G(x_i)}w_i^m,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "766b1fdd", + "metadata": { + "editable": true + }, + "source": [ + "which can be rewritten as" + ] + }, + { + "cell_type": "markdown", + "id": "d9698851", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "(\\exp{(\\beta)}-\\exp{-(\\beta)})\\sum_{i=0}^{n-1}w_i^mI(y_i\\ne G(x_i))+\\exp{(-\\beta)}\\sum_{i=0}^{n-1}w_i^m=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "8b9dc891", + "metadata": { + "editable": true + }, + "source": [ + "which leads to" + ] + }, + { + "cell_type": "markdown", + "id": "32e16984", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\beta_m = \\frac{1}{2}\\log{\\frac{1-\\mathrm{\\overline{err}}}{\\mathrm{\\overline{err}}}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "85898ea6", + "metadata": { + "editable": true + }, + "source": [ + "where we have redefined the error as" + ] + }, + { + "cell_type": "markdown", + "id": "e9c70102", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{\\overline{err}}_m=\\frac{1}{n}\\frac{\\sum_{i=0}^{n-1}w_i^mI(y_i\\ne G(x_i)}{\\sum_{i=0}^{n-1}w_i^m},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "a00653d9", + "metadata": { + "editable": true + }, + "source": [ + "which leads to an update of" + ] + }, + { + "cell_type": "markdown", + "id": "e041fdeb", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f_m(x) = f_{m-1}(x) +\\beta_m G_m(x).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5f07c0b1", + "metadata": { + "editable": true + }, + "source": [ + "This leads to the new weights" + ] + }, + { + "cell_type": "markdown", + "id": "d13323ee", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "w_i^{m+1} = w_i^m \\exp{(-y_i\\beta_m G_m(x_i))}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c7237587", + "metadata": { + "editable": true + }, + "source": [ + "## Adaptive boosting: AdaBoost, Basic Algorithm\n", + "\n", + "The algorithm here is rather straightforward. Assume that our weak\n", + "classifier is a decision tree and we consider a binary set of outputs\n", + "with $y_i \\in \\{-1,1\\}$ and $i=0,1,2,\\dots,n-1$ as our set of\n", + "observations. Our design matrix is given in terms of the\n", + "feature/predictor vectors\n", + "$\\boldsymbol{X}=[\\boldsymbol{x}_0\\boldsymbol{x}_1\\dots\\boldsymbol{x}_{p-1}]$. Finally, we define also a\n", + "classifier determined by our data via a function $G(x)$. This function tells us how well we are able to classify our outputs/targets $\\boldsymbol{y}$. \n", + "\n", + "We have already defined the misclassification error $\\mathrm{err}$ as" + ] + }, + { + "cell_type": "markdown", + "id": "5eabf8df", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{err}=\\frac{1}{n}\\sum_{i=0}^{n-1}I(y_i\\ne G(x_i)),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "309fe485", + "metadata": { + "editable": true + }, + "source": [ + "where the function $I()$ is one if we misclassify and zero if we classify correctly." + ] + }, + { + "cell_type": "markdown", + "id": "344c2fc2", + "metadata": { + "editable": true + }, + "source": [ + "## Basic Steps of AdaBoost\n", + "\n", + "With the above definitions we are now ready to set up the algorithm for AdaBoost.\n", + "The basic idea is to set up weights which will be used to scale the correctly classified and the misclassified cases.\n", + "1. We start by initializing all weights to $w_i = 1/n$, with $i=0,1,2,\\dots n-1$. It is easy to see that we must have $\\sum_{i=0}^{n-1}w_i = 1$.\n", + "\n", + "2. We rewrite the misclassification error as" + ] + }, + { + "cell_type": "markdown", + "id": "0af051ff", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{\\overline{err}}_m=\\frac{\\sum_{i=0}^{n-1}w_i^m I(y_i\\ne G(x_i))}{\\sum_{i=0}^{n-1}w_i},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ebf99e70", + "metadata": { + "editable": true + }, + "source": [ + "1. Then we start looping over all attempts at classifying, namely we start an iterative process for $m=1:M$, where $M$ is the final number of classifications. Our given classifier could for example be a plain decision tree.\n", + "\n", + "a. Fit then a given classifier to the training set using the weights $w_i$.\n", + "\n", + "b. Compute then $\\mathrm{err}$ and figure out which events are classified properly and which are classified wrongly.\n", + "\n", + "c. Define a quantity $\\alpha_{m} = \\log{(1-\\mathrm{\\overline{err}}_m)/\\mathrm{\\overline{err}}_m}$\n", + "\n", + "d. Set the new weights to $w_i = w_i\\times \\exp{(\\alpha_m I(y_i\\ne G(x_i)}$.\n", + "\n", + "5. Compute the new classifier $G(x)= \\sum_{i=0}^{n-1}\\alpha_m I(y_i\\ne G(x_i)$.\n", + "\n", + "For the iterations with $m \\le 2$ the weights are modified\n", + "individually at each steps. The observations which were misclassified\n", + "at iteration $m-1$ have a weight which is larger than those which were\n", + "classified properly. As this proceeds, the observations which were\n", + "difficult to classifiy correctly are given a larger influence. Each\n", + "new classification step $m$ is then forced to concentrate on those\n", + "observations that are missed in the previous iterations." + ] + }, + { + "cell_type": "markdown", + "id": "38533606", + "metadata": { + "editable": true + }, + "source": [ + "## AdaBoost Examples\n", + "\n", + "Using **Scikit-Learn** it is easy to apply the adaptive boosting algorithm, as done here." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "58b8da05", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.ensemble import AdaBoostClassifier\n", + "\n", + "ada_clf = AdaBoostClassifier(\n", + " DecisionTreeClassifier(max_depth=1), n_estimators=200,\n", + " algorithm=\"SAMME.R\", learning_rate=0.5, random_state=42)\n", + "ada_clf.fit(X_train, y_train)\n", + "\n", + "from sklearn.ensemble import AdaBoostClassifier\n", + "\n", + "ada_clf = AdaBoostClassifier(\n", + " DecisionTreeClassifier(max_depth=1), n_estimators=200,\n", + " algorithm=\"SAMME.R\", learning_rate=0.5, random_state=42)\n", + "ada_clf.fit(X_train_scaled, y_train)\n", + "y_pred = ada_clf.predict(X_test_scaled)\n", + "skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n", + "plt.show()\n", + "y_probas = ada_clf.predict_proba(X_test_scaled)\n", + "skplt.metrics.plot_roc(y_test, y_probas)\n", + "plt.show()\n", + "skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n", + "plt.show()" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/Projects/2023/Project3/html/._Project3-bs000.html b/doc/Projects/2023/Project3/html/._Project3-bs000.html new file mode 100644 index 000000000..3297de220 --- /dev/null +++ b/doc/Projects/2023/Project3/html/._Project3-bs000.html @@ -0,0 +1,409 @@ + + + + + + + +Project 3 on Machine Learning, deadline December 18 (midnight), 2023 + + + + + + + + + + + + + + + + + + + + +
+

 

 

 

+ + +
+
+

Project 3 on Machine Learning, deadline December 18 (midnight), 2023

+
+ + +
+Data Analysis and Machine Learning FYS-STK3155/FYS4155 +
+ +
+Department of Physics, University of Oslo, Norway +
+
+
+

Nov 12, 2023

+
+
+ + +
+

Paths for project 3

+

Defining the data sets to analyze yourself

+ +

For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say

+
    +
  1. Kaggle
  2. +
  3. The University of California at Irvine (UCI) with its machine learning repository.
  4. +
  5. Or other sources.
  6. +
+

The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is:

+
    +
  1. Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among linear regression (including Ridge and Lasso), Logistic Regression, Neural Networks, Convolution Neural Networks, Recurrent Neural Networks, and Decision Trees, Random Forests, Bagging and Boosting. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into convolutional neural networks or recurrent neural networks, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning.
  2. +
+

For Boosting, feel also free to write your own codes.

+ +
    +
  1. For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of Scikit-Learn, Tensorflow, etc.
  2. +
  3. The estimates you used and tested in projects 1 and 2 should also be included, that is the \( R2 \)-score, MSE, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant.
  4. +
  5. Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches.
  6. +
  7. If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article?
  8. +
  9. A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include.
  10. +
+

All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc..

+ +

We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks.

+ +

This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides from week 43 and/or the textbook by Yadav et al.

+

The basic structure of your project

+ +

Here follows a set up on how to structure your report and analyze the data you have opted for.

+

Part a)

+ +

The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context.

+

Part b)

+ +

You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part.

+

Part c)

+ +

Then describe your algorithm and its implementation and tests you have performed.

+

Part d)

+ +

Then presents your results and findings, link with existing literature and more.

+

Part e)

+ +

Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature.

+

Solving partial differential equations with neural networks

+ +

For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. +

+ +

For the explicit scheme, you can study for example chapter 10 of the lecture notes in Computational Physics or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by Kristine Baluka Hein and included in the lectures of week 43 at this course are highly recommended.

+ +

For the machine learning part you can use your own code from project 2 or the functionality of for example Tensorflow/Keras..

+

Part a), setting up the problem

+ +

The physical problem can be that of the temperature gradient in a rod of length \( L=1 \) at \( x=0 \) and \( x=1 \). +We are looking at a one-dimensional +problem +

+ +$$ +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +$$ + +

with initial conditions, i.e., the conditions at \( t=0 \),

+$$ +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +$$ + +

with \( L=1 \) the length of the \( x \)-region of interest. The +boundary conditions are +

+ +$$ +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +$$ + +

The function \( u(x,t) \) can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with \( x \). +

+ +

We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in

+$$ +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} +$$ + +

Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. +

+

Part b)

+ +

Implement the explicit scheme algorithm and perform tests of the solution +for \( \Delta x=1/10 \), \( \Delta x=1/100 \) using \( \Delta t \) as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that \( \Delta t/\Delta x^2 \leq 1/2 \). +

+ +

Study the solutions at two time points \( t_1 \) and \( t_2 \) where \( u(x,t_1) \) is smooth but still significantly curved +and \( u(x,t_2) \) is almost linear, close to the stationary state. +

+

Part c) Neural networks

+ +

Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. +

+

Part d)

+ +

Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. +

+

Introduction to numerical projects

+ +

Here follows a brief recipe and recommendation on how to write a report for each +project. +

+ + +

Format for electronic delivery of report and programs

+ +

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:

+ + +

Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. +

+

Software and needed installations

+ +

If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via pip as +

+
    +
  1. pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
  2. +
+

For Python3, replace pip with pip3.

+ +

See below for a discussion of tensorflow and scikit-learn.

+ +

For OSX users we recommend also, after having installed Xcode, to install brew. Brew allows +for a seamless installation of additional software via for example +

+
    +
  1. brew install python3
  2. +
+

For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use pip as well and simply install Python as +

+
    +
  1. sudo apt-get install python3 (or python for python2.7)
  2. +
+

etc etc.

+ +

If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely

+
    +
  1. Anaconda Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system conda
  2. +
  3. Enthought canopy is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
  4. +
+

Popular software packages written in Python for ML are

+ + +

These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. +

+ +

+ +

+ +
+ + + + +
+ © 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + diff --git a/doc/Projects/2023/Project3/html/Project3-bs.html b/doc/Projects/2023/Project3/html/Project3-bs.html new file mode 100644 index 000000000..3297de220 --- /dev/null +++ b/doc/Projects/2023/Project3/html/Project3-bs.html @@ -0,0 +1,409 @@ + + + + + + + +Project 3 on Machine Learning, deadline December 18 (midnight), 2023 + + + + + + + + + + + + + + + + + + + + +
+

 

 

 

+ + +
+
+

Project 3 on Machine Learning, deadline December 18 (midnight), 2023

+
+ + +
+Data Analysis and Machine Learning FYS-STK3155/FYS4155 +
+ +
+Department of Physics, University of Oslo, Norway +
+
+
+

Nov 12, 2023

+
+
+ + +
+

Paths for project 3

+

Defining the data sets to analyze yourself

+ +

For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say

+
    +
  1. Kaggle
  2. +
  3. The University of California at Irvine (UCI) with its machine learning repository.
  4. +
  5. Or other sources.
  6. +
+

The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is:

+
    +
  1. Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among linear regression (including Ridge and Lasso), Logistic Regression, Neural Networks, Convolution Neural Networks, Recurrent Neural Networks, and Decision Trees, Random Forests, Bagging and Boosting. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into convolutional neural networks or recurrent neural networks, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning.
  2. +
+

For Boosting, feel also free to write your own codes.

+ +
    +
  1. For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of Scikit-Learn, Tensorflow, etc.
  2. +
  3. The estimates you used and tested in projects 1 and 2 should also be included, that is the \( R2 \)-score, MSE, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant.
  4. +
  5. Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches.
  6. +
  7. If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article?
  8. +
  9. A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include.
  10. +
+

All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc..

+ +

We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks.

+ +

This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides from week 43 and/or the textbook by Yadav et al.

+

The basic structure of your project

+ +

Here follows a set up on how to structure your report and analyze the data you have opted for.

+

Part a)

+ +

The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context.

+

Part b)

+ +

You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part.

+

Part c)

+ +

Then describe your algorithm and its implementation and tests you have performed.

+

Part d)

+ +

Then presents your results and findings, link with existing literature and more.

+

Part e)

+ +

Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature.

+

Solving partial differential equations with neural networks

+ +

For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. +

+ +

For the explicit scheme, you can study for example chapter 10 of the lecture notes in Computational Physics or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by Kristine Baluka Hein and included in the lectures of week 43 at this course are highly recommended.

+ +

For the machine learning part you can use your own code from project 2 or the functionality of for example Tensorflow/Keras..

+

Part a), setting up the problem

+ +

The physical problem can be that of the temperature gradient in a rod of length \( L=1 \) at \( x=0 \) and \( x=1 \). +We are looking at a one-dimensional +problem +

+ +$$ +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +$$ + +

with initial conditions, i.e., the conditions at \( t=0 \),

+$$ +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +$$ + +

with \( L=1 \) the length of the \( x \)-region of interest. The +boundary conditions are +

+ +$$ +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +$$ + +

The function \( u(x,t) \) can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with \( x \). +

+ +

We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in

+$$ +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} +$$ + +

Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. +

+

Part b)

+ +

Implement the explicit scheme algorithm and perform tests of the solution +for \( \Delta x=1/10 \), \( \Delta x=1/100 \) using \( \Delta t \) as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that \( \Delta t/\Delta x^2 \leq 1/2 \). +

+ +

Study the solutions at two time points \( t_1 \) and \( t_2 \) where \( u(x,t_1) \) is smooth but still significantly curved +and \( u(x,t_2) \) is almost linear, close to the stationary state. +

+

Part c) Neural networks

+ +

Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. +

+

Part d)

+ +

Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. +

+

Introduction to numerical projects

+ +

Here follows a brief recipe and recommendation on how to write a report for each +project. +

+ + +

Format for electronic delivery of report and programs

+ +

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:

+ + +

Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. +

+

Software and needed installations

+ +

If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via pip as +

+
    +
  1. pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
  2. +
+

For Python3, replace pip with pip3.

+ +

See below for a discussion of tensorflow and scikit-learn.

+ +

For OSX users we recommend also, after having installed Xcode, to install brew. Brew allows +for a seamless installation of additional software via for example +

+
    +
  1. brew install python3
  2. +
+

For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use pip as well and simply install Python as +

+
    +
  1. sudo apt-get install python3 (or python for python2.7)
  2. +
+

etc etc.

+ +

If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely

+
    +
  1. Anaconda Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system conda
  2. +
  3. Enthought canopy is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
  4. +
+

Popular software packages written in Python for ML are

+ + +

These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. +

+ +

+ +

+ +
+ + + + +
+ © 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + diff --git a/doc/Projects/2023/Project3/html/Project3.html b/doc/Projects/2023/Project3/html/Project3.html new file mode 100644 index 000000000..a1e9d29d5 --- /dev/null +++ b/doc/Projects/2023/Project3/html/Project3.html @@ -0,0 +1,428 @@ + + + + + + + +Project 3 on Machine Learning, deadline December 18 (midnight), 2023 + + + + + + + + + + + + + + +
+

Project 3 on Machine Learning, deadline December 18 (midnight), 2023

+
+ + +
+Data Analysis and Machine Learning FYS-STK3155/FYS4155 +
+ +
+Department of Physics, University of Oslo, Norway +
+
+
+

Nov 12, 2023

+
+
+

Paths for project 3

+

Defining the data sets to analyze yourself

+ +

For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say

+
    +
  1. Kaggle
  2. +
  3. The University of California at Irvine (UCI) with its machine learning repository.
  4. +
  5. Or other sources.
  6. +
+

The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is:

+
    +
  1. Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among linear regression (including Ridge and Lasso), Logistic Regression, Neural Networks, Convolution Neural Networks, Recurrent Neural Networks, and Decision Trees, Random Forests, Bagging and Boosting. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into convolutional neural networks or recurrent neural networks, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning.
  2. +
+

For Boosting, feel also free to write your own codes.

+ +
    +
  1. For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of Scikit-Learn, Tensorflow, etc.
  2. +
  3. The estimates you used and tested in projects 1 and 2 should also be included, that is the \( R2 \)-score, MSE, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant.
  4. +
  5. Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches.
  6. +
  7. If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article?
  8. +
  9. A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include.
  10. +
+

All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc..

+ +

We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks.

+ +

This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides from week 43 and/or the textbook by Yadav et al.

+

The basic structure of your project

+ +

Here follows a set up on how to structure your report and analyze the data you have opted for.

+

Part a)

+ +

The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context.

+

Part b)

+ +

You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part.

+

Part c)

+ +

Then describe your algorithm and its implementation and tests you have performed.

+

Part d)

+ +

Then presents your results and findings, link with existing literature and more.

+

Part e)

+ +

Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature.

+

Solving partial differential equations with neural networks

+ +

For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. +

+ +

For the explicit scheme, you can study for example chapter 10 of the lecture notes in Computational Physics or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by Kristine Baluka Hein and included in the lectures of week 43 at this course are highly recommended.

+ +

For the machine learning part you can use your own code from project 2 or the functionality of for example Tensorflow/Keras..

+

Part a), setting up the problem

+ +

The physical problem can be that of the temperature gradient in a rod of length \( L=1 \) at \( x=0 \) and \( x=1 \). +We are looking at a one-dimensional +problem +

+ +$$ +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +$$ + +

with initial conditions, i.e., the conditions at \( t=0 \),

+$$ +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +$$ + +

with \( L=1 \) the length of the \( x \)-region of interest. The +boundary conditions are +

+ +$$ +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +$$ + +

The function \( u(x,t) \) can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with \( x \). +

+ +

We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in

+$$ +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +$$ + +

and

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +$$ + +

or

+ +$$ +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} +$$ + +

Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. +

+

Part b)

+ +

Implement the explicit scheme algorithm and perform tests of the solution +for \( \Delta x=1/10 \), \( \Delta x=1/100 \) using \( \Delta t \) as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that \( \Delta t/\Delta x^2 \leq 1/2 \). +

+ +

Study the solutions at two time points \( t_1 \) and \( t_2 \) where \( u(x,t_1) \) is smooth but still significantly curved +and \( u(x,t_2) \) is almost linear, close to the stationary state. +

+

Part c) Neural networks

+ +

Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. +

+

Part d)

+ +

Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. +

+

Introduction to numerical projects

+ +

Here follows a brief recipe and recommendation on how to write a report for each +project. +

+ + +

Format for electronic delivery of report and programs

+ +

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:

+ + +

Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. +

+

Software and needed installations

+ +

If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via pip as +

+
    +
  1. pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
  2. +
+

For Python3, replace pip with pip3.

+ +

See below for a discussion of tensorflow and scikit-learn.

+ +

For OSX users we recommend also, after having installed Xcode, to install brew. Brew allows +for a seamless installation of additional software via for example +

+
    +
  1. brew install python3
  2. +
+

For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use pip as well and simply install Python as +

+
    +
  1. sudo apt-get install python3 (or python for python2.7)
  2. +
+

etc etc.

+ +

If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely

+
    +
  1. Anaconda Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system conda
  2. +
  3. Enthought canopy is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
  4. +
+

Popular software packages written in Python for ML are

+ + +

These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. +

+ + +
+ © 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + diff --git a/doc/Projects/2023/Project3/ipynb/Project3.ipynb b/doc/Projects/2023/Project3/ipynb/Project3.ipynb new file mode 100644 index 000000000..d45c511e8 --- /dev/null +++ b/doc/Projects/2023/Project3/ipynb/Project3.ipynb @@ -0,0 +1,516 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "5831c36a", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "2d774c8b", + "metadata": { + "editable": true + }, + "source": [ + "# Project 3 on Machine Learning, deadline December 18 (midnight), 2023\n", + "**[Data Analysis and Machine Learning FYS-STK3155/FYS4155](http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html)**, Department of Physics, University of Oslo, Norway\n", + "\n", + "Date: **Nov 12, 2023**\n", + "\n", + "Copyright 1999-2023, [Data Analysis and Machine Learning FYS-STK3155/FYS4155](http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html). Released under CC Attribution-NonCommercial 4.0 license" + ] + }, + { + "cell_type": "markdown", + "id": "5cbde03b", + "metadata": { + "editable": true + }, + "source": [ + "# Paths for project 3" + ] + }, + { + "cell_type": "markdown", + "id": "5170403b", + "metadata": { + "editable": true + }, + "source": [ + "## Defining the data sets to analyze yourself\n", + "\n", + "For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say\n", + "1. [Kaggle](https://www.kaggle.com/datasets) \n", + "\n", + "2. The [University of California at Irvine (UCI) with its machine learning repository](https://archive.ics.uci.edu/ml/index.php).\n", + "\n", + "3. Or other sources.\n", + "\n", + "The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is:\n", + "1. Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among **linear regression (including Ridge and Lasso)**, **Logistic Regression**, **Neural Networks**, **Convolution Neural Networks**, **Recurrent Neural Networks**, and **Decision Trees, Random Forests, Bagging and Boosting**. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into **convolutional neural networks** or **recurrent neural networks**, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning. \n", + "\n", + "For Boosting, feel also free to write your own codes.\n", + "\n", + "1. For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of **Scikit-Learn**, **Tensorflow**, etc. \n", + "\n", + "2. The estimates you used and tested in projects 1 and 2 should also be included, that is the $R2$-score, **MSE**, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant.\n", + "\n", + "3. Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches.\n", + "\n", + "4. If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article? \n", + "\n", + "5. A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include.\n", + "\n", + "All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc..\n", + "\n", + "We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks.\n", + "\n", + "This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides [from week 43](https://compphysics.github.io/MachineLearning/doc/pub/week43/html/week42.html) and/or the textbook by [Yadav et al](https://www.springer.com/gp/book/9789401798150)." + ] + }, + { + "cell_type": "markdown", + "id": "e9fc8e8e", + "metadata": { + "editable": true + }, + "source": [ + "## The basic structure of your project\n", + "\n", + "Here follows a set up on how to structure your report and analyze the data you have opted for." + ] + }, + { + "cell_type": "markdown", + "id": "ce8b52a3", + "metadata": { + "editable": true + }, + "source": [ + "### Part a)\n", + "\n", + "The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context." + ] + }, + { + "cell_type": "markdown", + "id": "eb943f7a", + "metadata": { + "editable": true + }, + "source": [ + "### Part b)\n", + "\n", + "You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part." + ] + }, + { + "cell_type": "markdown", + "id": "17447dcc", + "metadata": { + "editable": true + }, + "source": [ + "### Part c)\n", + "\n", + "Then describe your algorithm and its implementation and tests you have performed." + ] + }, + { + "cell_type": "markdown", + "id": "d9bea856", + "metadata": { + "editable": true + }, + "source": [ + "### Part d)\n", + "\n", + "Then presents your results and findings, link with existing literature and more." + ] + }, + { + "cell_type": "markdown", + "id": "5b74282b", + "metadata": { + "editable": true + }, + "source": [ + "### Part e)\n", + "\n", + "Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature." + ] + }, + { + "cell_type": "markdown", + "id": "28f082d7", + "metadata": { + "editable": true + }, + "source": [ + "## Solving partial differential equations with neural networks\n", + "\n", + "For this variant of project 3, we will assume that you have some\n", + "background in the solution of partial differential equations using\n", + "finite difference schemes. We will study the solution of the diffusion\n", + "equation in one dimension using a standard explicit scheme and neural\n", + "networks to solve the same equations.\n", + "\n", + "For the explicit scheme, you can study for example chapter 10 of the lecture notes in [Computational Physics](https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Lectures/lectures2015.pdf) or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by [Kristine Baluka Hein and included in the lectures of week 43](https://compphysics.github.io/MachineLearning/doc/pub/week42/html/week43.html) at this course are highly recommended.\n", + "\n", + "For the machine learning part you can use your own code from project 2 or the functionality of for example **Tensorflow/Keras**.." + ] + }, + { + "cell_type": "markdown", + "id": "5e855e7f", + "metadata": { + "editable": true + }, + "source": [ + "### Part a), setting up the problem\n", + "\n", + "The physical problem can be that of the temperature gradient in a rod of length $L=1$ at $x=0$ and $x=1$.\n", + "We are looking at a one-dimensional\n", + "problem" + ] + }, + { + "cell_type": "markdown", + "id": "bc4be75f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial^2 u(x,t)}{\\partial x^2} =\\frac{\\partial u(x,t)}{\\partial t}, t> 0, x\\in [0,L]\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "caa1eca4", + "metadata": { + "editable": true + }, + "source": [ + "or" + ] + }, + { + "cell_type": "markdown", + "id": "98a2bd5b", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u_{xx} = u_t,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "980b949d", + "metadata": { + "editable": true + }, + "source": [ + "with initial conditions, i.e., the conditions at $t=0$," + ] + }, + { + "cell_type": "markdown", + "id": "7401e9ec", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u(x,0)= \\sin{(\\pi x)} \\hspace{0.5cm} 0 < x < L,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e953662e", + "metadata": { + "editable": true + }, + "source": [ + "with $L=1$ the length of the $x$-region of interest. The \n", + "boundary conditions are" + ] + }, + { + "cell_type": "markdown", + "id": "52122eb7", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u(0,t)= 0 \\hspace{0.5cm} t \\ge 0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ab71a383", + "metadata": { + "editable": true + }, + "source": [ + "and" + ] + }, + { + "cell_type": "markdown", + "id": "4f886681", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u(L,t)= 0 \\hspace{0.5cm} t \\ge 0.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "83f8d12e", + "metadata": { + "editable": true + }, + "source": [ + "The function $u(x,t)$ can be the temperature gradient of a rod.\n", + "As time increases, the velocity approaches a linear variation with $x$. \n", + "\n", + "We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in" + ] + }, + { + "cell_type": "markdown", + "id": "4bcf494f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u_t\\approx \\frac{u(x,t+\\Delta t)-u(x,t)}{\\Delta t}=\\frac{u(x_i,t_j+\\Delta t)-u(x_i,t_j)}{\\Delta t}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7f95982b", + "metadata": { + "editable": true + }, + "source": [ + "and" + ] + }, + { + "cell_type": "markdown", + "id": "1ee81ac0", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u_{xx}\\approx \\frac{u(x+\\Delta x,t)-2u(x,t)+u(x-\\Delta x,t)}{\\Delta x^2},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bae7898a", + "metadata": { + "editable": true + }, + "source": [ + "or" + ] + }, + { + "cell_type": "markdown", + "id": "5de23ea9", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "u_{xx}\\approx \\frac{u(x_i+\\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\\Delta x,t_j)}{\\Delta x^2}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "4d5d56e3", + "metadata": { + "editable": true + }, + "source": [ + "Write down the algorithm and the equations you need to implement.\n", + "Find also the analytical solution to the problem." + ] + }, + { + "cell_type": "markdown", + "id": "e52523ef", + "metadata": { + "editable": true + }, + "source": [ + "### Part b)\n", + "\n", + "Implement the explicit scheme algorithm and perform tests of the solution \n", + "for $\\Delta x=1/10$, $\\Delta x=1/100$ using $\\Delta t$ as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that $\\Delta t/\\Delta x^2 \\leq 1/2$. \n", + "\n", + "Study the solutions at two time points $t_1$ and $t_2$ where $u(x,t_1)$ is smooth but still significantly curved\n", + "and $u(x,t_2)$ is almost linear, close to the stationary state." + ] + }, + { + "cell_type": "markdown", + "id": "678607d0", + "metadata": { + "editable": true + }, + "source": [ + "### Part c) Neural networks\n", + "\n", + "Study now the lecture notes on solving ODEs and PDEs with neural\n", + "network and use either your own code from project 2 or the\n", + "functionality of tensorflow/keras to solve the same equation as in\n", + "part b). Discuss your results and compare them with the standard\n", + "explicit scheme. Include also the analytical solution and compare with\n", + "that." + ] + }, + { + "cell_type": "markdown", + "id": "61d51d93", + "metadata": { + "editable": true + }, + "source": [ + "### Part d)\n", + "\n", + "Finally, present a critical assessment of the methods you have studied\n", + "and discuss the potential for the solving differential equations and\n", + "eigenvalue problems with machine learning methods." + ] + }, + { + "cell_type": "markdown", + "id": "d2163034", + "metadata": { + "editable": true + }, + "source": [ + "## Introduction to numerical projects\n", + "\n", + "Here follows a brief recipe and recommendation on how to write a report for each\n", + "project.\n", + "\n", + " * Give a short description of the nature of the problem and the eventual numerical methods you have used.\n", + "\n", + " * Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.\n", + "\n", + " * Include the source code of your program. Comment your program properly.\n", + "\n", + " * If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.\n", + "\n", + " * Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.\n", + "\n", + " * Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.\n", + "\n", + " * Try to give an interpretation of you results in your answers to the problems.\n", + "\n", + " * Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.\n", + "\n", + " * Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning." + ] + }, + { + "cell_type": "markdown", + "id": "e31290fd", + "metadata": { + "editable": true + }, + "source": [ + "## Format for electronic delivery of report and programs\n", + "\n", + "The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:\n", + "\n", + " * Use Canvas to hand in your projects, log in at with your normal UiO username and password.\n", + "\n", + " * Upload **only** the report file or the link to your GitHub/GitLab or similar typo of repos! For the source code file(s) you have developed please provide us with your link to your GitHub/GitLab or similar domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them.\n", + "\n", + " * In your GitHub/GitLab or similar repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters.\n", + "\n", + "Finally, \n", + "we encourage you to collaborate. Optimal working groups consist of \n", + "2-3 students. You can then hand in a common report." + ] + }, + { + "cell_type": "markdown", + "id": "99e78b73", + "metadata": { + "editable": true + }, + "source": [ + "## Software and needed installations\n", + "\n", + "If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, \n", + "we recommend that you install the following Python packages via **pip** as\n", + "1. pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow\n", + "\n", + "For Python3, replace **pip** with **pip3**.\n", + "\n", + "See below for a discussion of **tensorflow** and **scikit-learn**. \n", + "\n", + "For OSX users we recommend also, after having installed Xcode, to install **brew**. Brew allows \n", + "for a seamless installation of additional software via for example\n", + "1. brew install python3\n", + "\n", + "For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution\n", + "you can use **pip** as well and simply install Python as \n", + "1. sudo apt-get install python3 (or python for python2.7)\n", + "\n", + "etc etc. \n", + "\n", + "If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely\n", + "1. [Anaconda](https://docs.anaconda.com/) Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system **conda**\n", + "\n", + "2. [Enthought canopy](https://www.enthought.com/product/canopy/) is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.\n", + "\n", + "Popular software packages written in Python for ML are\n", + "\n", + "* [Scikit-learn](http://scikit-learn.org/stable/), \n", + "\n", + "* [Tensorflow](https://www.tensorflow.org/),\n", + "\n", + "* [PyTorch](http://pytorch.org/) and \n", + "\n", + "* [Keras](https://keras.io/).\n", + "\n", + "These are all freely available at their respective GitHub sites. They \n", + "encompass communities of developers in the thousands or more. And the number\n", + "of code developers and contributors keeps increasing." + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/Projects/2023/Project3/ipynb/ipynb-Project3-src.tar.gz b/doc/Projects/2023/Project3/ipynb/ipynb-Project3-src.tar.gz new file mode 100644 index 000000000..aa5f6fe8d Binary files /dev/null and b/doc/Projects/2023/Project3/ipynb/ipynb-Project3-src.tar.gz differ diff --git a/doc/Projects/2023/Project3/pdf/Project3.p.tex b/doc/Projects/2023/Project3/pdf/Project3.p.tex new file mode 100644 index 000000000..bf892f5c2 --- /dev/null +++ b/doc/Projects/2023/Project3/pdf/Project3.p.tex @@ -0,0 +1,403 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/doconce/doconce/) +%% doconce format latex Project3.do.txt --print_latex_style=trac --latex_admon=paragraph +%% +% #ifdef PTEX2TEX_EXPLANATION +%% +%% The file follows the ptex2tex extended LaTeX format, see +%% ptex2tex: https://code.google.com/p/ptex2tex/ +%% +%% Run +%% ptex2tex myfile +%% or +%% doconce ptex2tex myfile +%% +%% to turn myfile.p.tex into an ordinary LaTeX file myfile.tex. +%% (The ptex2tex program: https://code.google.com/p/ptex2tex) +%% Many preprocess options can be added to ptex2tex or doconce ptex2tex +%% +%% ptex2tex -DMINTED myfile +%% doconce ptex2tex myfile envir=minted +%% +%% ptex2tex will typeset code environments according to a global or local +%% .ptex2tex.cfg configure file. doconce ptex2tex will typeset code +%% according to options on the command line (just type doconce ptex2tex to +%% see examples). If doconce ptex2tex has envir=minted, it enables the +%% minted style without needing -DMINTED. +% #endif + +% #define PREAMBLE + +% #ifdef PREAMBLE +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE +% #endif + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project 3 on Machine Learning, deadline December 18 (midnight), 2023 +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-STK3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Nov 12, 2023 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\section{Paths for project 3} + +\subsection{Defining the data sets to analyze yourself} + +For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say +\begin{enumerate} +\item \href{{https://www.kaggle.com/datasets}}{Kaggle} + +\item The \href{{https://archive.ics.uci.edu/ml/index.php}}{University of California at Irvine (UCI) with its machine learning repository}. + +\item Or other sources. +\end{enumerate} + +\noindent +The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is: +\begin{enumerate} +\item Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among \textbf{linear regression (including Ridge and Lasso)}, \textbf{Logistic Regression}, \textbf{Neural Networks}, \textbf{Convolution Neural Networks}, \textbf{Recurrent Neural Networks}, and \textbf{Decision Trees, Random Forests, Bagging and Boosting}. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into \textbf{convolutional neural networks} or \textbf{recurrent neural networks}, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning. +\end{enumerate} + +\noindent +For Boosting, feel also free to write your own codes. + +\begin{enumerate} +\item For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of \textbf{Scikit-Learn}, \textbf{Tensorflow}, etc. + +\item The estimates you used and tested in projects 1 and 2 should also be included, that is the $R2$-score, \textbf{MSE}, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant. + +\item Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches. + +\item If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article? + +\item A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include. +\end{enumerate} + +\noindent +All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc.. + +We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks. + +This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides \href{{https://compphysics.github.io/MachineLearning/doc/pub/week43/html/week42.html}}{from week 43} and/or the textbook by \href{{https://www.springer.com/gp/book/9789401798150}}{Yadav et al}. + +\subsection{The basic structure of your project} + +Here follows a set up on how to structure your report and analyze the data you have opted for. + +\paragraph{Part a).} +The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context. + +\paragraph{Part b).} +You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part. + +\paragraph{Part c).} +Then describe your algorithm and its implementation and tests you have performed. + +\paragraph{Part d).} +Then presents your results and findings, link with existing literature and more. + +\paragraph{Part e).} +Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature. + +\subsection{Solving partial differential equations with neural networks} + +For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. + +For the explicit scheme, you can study for example chapter 10 of the lecture notes in \href{{https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Lectures/lectures2015.pdf}}{Computational Physics} or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by \href{{https://compphysics.github.io/MachineLearning/doc/pub/week42/html/week43.html}}{Kristine Baluka Hein and included in the lectures of week 43} at this course are highly recommended. + +For the machine learning part you can use your own code from project 2 or the functionality of for example \textbf{Tensorflow/Keras}.. + +\paragraph{Part a), setting up the problem.} +The physical problem can be that of the temperature gradient in a rod of length $L=1$ at $x=0$ and $x=1$. +We are looking at a one-dimensional +problem + +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +or + +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +with initial conditions, i.e., the conditions at $t=0$, +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +with $L=1$ the length of the $x$-region of interest. The +boundary conditions are + +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +and + +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +The function $u(x,t)$ can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with $x$. + +We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +and + +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +or + +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} + +Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. + +\paragraph{Part b).} +Implement the explicit scheme algorithm and perform tests of the solution +for $\Delta x=1/10$, $\Delta x=1/100$ using $\Delta t$ as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that $\Delta t/\Delta x^2 \leq 1/2$. + +Study the solutions at two time points $t_1$ and $t_2$ where $u(x,t_1)$ is smooth but still significantly curved +and $u(x,t_2)$ is almost linear, close to the stationary state. + +\paragraph{Part c) Neural networks.} +Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. + +\paragraph{Part d).} +Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. + +\subsection{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent +\subsection{Format for electronic delivery of report and programs} + +The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report: + +\begin{itemize} + \item Use Canvas to hand in your projects, log in at \href{{https://www.uio.no/english/services/it/education/canvas/}}{\nolinkurl{https://www.uio.no/english/services/it/education/canvas/}} with your normal UiO username and password. + + \item Upload \textbf{only} the report file or the link to your GitHub/GitLab or similar typo of repos! For the source code file(s) you have developed please provide us with your link to your GitHub/GitLab or similar domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them. + + \item In your GitHub/GitLab or similar repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters. +\end{itemize} + +\noindent +Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. + +\subsection{Software and needed installations} + +If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via \textbf{pip} as +\begin{enumerate} +\item pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow +\end{enumerate} + +\noindent +For Python3, replace \textbf{pip} with \textbf{pip3}. + +See below for a discussion of \textbf{tensorflow} and \textbf{scikit-learn}. + +For OSX users we recommend also, after having installed Xcode, to install \textbf{brew}. Brew allows +for a seamless installation of additional software via for example +\begin{enumerate} +\item brew install python3 +\end{enumerate} + +\noindent +For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use \textbf{pip} as well and simply install Python as +\begin{enumerate} +\item sudo apt-get install python3 (or python for python2.7) +\end{enumerate} + +\noindent +etc etc. + +If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely +\begin{enumerate} +\item \href{{https://docs.anaconda.com/}}{Anaconda} Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system \textbf{conda} + +\item \href{{https://www.enthought.com/product/canopy/}}{Enthought canopy} is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license. +\end{enumerate} + +\noindent +Popular software packages written in Python for ML are + +\begin{itemize} +\item \href{{http://scikit-learn.org/stable/}}{Scikit-learn}, + +\item \href{{https://www.tensorflow.org/}}{Tensorflow}, + +\item \href{{http://pytorch.org/}}{PyTorch} and + +\item \href{{https://keras.io/}}{Keras}. +\end{itemize} + +\noindent +These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. + + +% ------------------- end of main content --------------- + +% #ifdef PREAMBLE +\end{document} +% #endif + diff --git a/doc/Projects/2023/Project3/pdf/Project3.pdf b/doc/Projects/2023/Project3/pdf/Project3.pdf new file mode 100644 index 000000000..a39fc2eb1 Binary files /dev/null and b/doc/Projects/2023/Project3/pdf/Project3.pdf differ diff --git a/doc/Projects/2023/Project3/pdf/Project3.tex b/doc/Projects/2023/Project3/pdf/Project3.tex new file mode 100644 index 000000000..b1c1cdf88 --- /dev/null +++ b/doc/Projects/2023/Project3/pdf/Project3.tex @@ -0,0 +1,375 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/doconce/doconce/) +%% doconce format latex Project3.do.txt --print_latex_style=trac --latex_admon=paragraph +%% + + +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2023, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project 3 on Machine Learning, deadline December 18 (midnight), 2023 +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-STK3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Nov 12, 2023 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\section*{Paths for project 3} + +\subsection*{Defining the data sets to analyze yourself} + +For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say +\begin{enumerate} +\item \href{{https://www.kaggle.com/datasets}}{Kaggle} + +\item The \href{{https://archive.ics.uci.edu/ml/index.php}}{University of California at Irvine (UCI) with its machine learning repository}. + +\item Or other sources. +\end{enumerate} + +\noindent +The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is: +\begin{enumerate} +\item Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among \textbf{linear regression (including Ridge and Lasso)}, \textbf{Logistic Regression}, \textbf{Neural Networks}, \textbf{Convolution Neural Networks}, \textbf{Recurrent Neural Networks}, and \textbf{Decision Trees, Random Forests, Bagging and Boosting}. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into \textbf{convolutional neural networks} or \textbf{recurrent neural networks}, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning. +\end{enumerate} + +\noindent +For Boosting, feel also free to write your own codes. + +\begin{enumerate} +\item For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of \textbf{Scikit-Learn}, \textbf{Tensorflow}, etc. + +\item The estimates you used and tested in projects 1 and 2 should also be included, that is the $R2$-score, \textbf{MSE}, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant. + +\item Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches. + +\item If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article? + +\item A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include. +\end{enumerate} + +\noindent +All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc.. + +We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks. + +This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides \href{{https://compphysics.github.io/MachineLearning/doc/pub/week43/html/week42.html}}{from week 43} and/or the textbook by \href{{https://www.springer.com/gp/book/9789401798150}}{Yadav et al}. + +\subsection*{The basic structure of your project} + +Here follows a set up on how to structure your report and analyze the data you have opted for. + +\paragraph{Part a).} +The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context. + +\paragraph{Part b).} +You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part. + +\paragraph{Part c).} +Then describe your algorithm and its implementation and tests you have performed. + +\paragraph{Part d).} +Then presents your results and findings, link with existing literature and more. + +\paragraph{Part e).} +Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature. + +\subsection*{Solving partial differential equations with neural networks} + +For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. + +For the explicit scheme, you can study for example chapter 10 of the lecture notes in \href{{https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Lectures/lectures2015.pdf}}{Computational Physics} or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by \href{{https://compphysics.github.io/MachineLearning/doc/pub/week42/html/week43.html}}{Kristine Baluka Hein and included in the lectures of week 43} at this course are highly recommended. + +For the machine learning part you can use your own code from project 2 or the functionality of for example \textbf{Tensorflow/Keras}.. + +\paragraph{Part a), setting up the problem.} +The physical problem can be that of the temperature gradient in a rod of length $L=1$ at $x=0$ and $x=1$. +We are looking at a one-dimensional +problem + +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +or + +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +with initial conditions, i.e., the conditions at $t=0$, +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +with $L=1$ the length of the $x$-region of interest. The +boundary conditions are + +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +and + +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +The function $u(x,t)$ can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with $x$. + +We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +and + +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +or + +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} + +Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. + +\paragraph{Part b).} +Implement the explicit scheme algorithm and perform tests of the solution +for $\Delta x=1/10$, $\Delta x=1/100$ using $\Delta t$ as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that $\Delta t/\Delta x^2 \leq 1/2$. + +Study the solutions at two time points $t_1$ and $t_2$ where $u(x,t_1)$ is smooth but still significantly curved +and $u(x,t_2)$ is almost linear, close to the stationary state. + +\paragraph{Part c) Neural networks.} +Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. + +\paragraph{Part d).} +Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. + +\subsection*{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent +\subsection*{Format for electronic delivery of report and programs} + +The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report: + +\begin{itemize} + \item Use Canvas to hand in your projects, log in at \href{{https://www.uio.no/english/services/it/education/canvas/}}{\nolinkurl{https://www.uio.no/english/services/it/education/canvas/}} with your normal UiO username and password. + + \item Upload \textbf{only} the report file or the link to your GitHub/GitLab or similar typo of repos! For the source code file(s) you have developed please provide us with your link to your GitHub/GitLab or similar domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them. + + \item In your GitHub/GitLab or similar repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters. +\end{itemize} + +\noindent +Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. + +\subsection*{Software and needed installations} + +If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via \textbf{pip} as +\begin{enumerate} +\item pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow +\end{enumerate} + +\noindent +For Python3, replace \textbf{pip} with \textbf{pip3}. + +See below for a discussion of \textbf{tensorflow} and \textbf{scikit-learn}. + +For OSX users we recommend also, after having installed Xcode, to install \textbf{brew}. Brew allows +for a seamless installation of additional software via for example +\begin{enumerate} +\item brew install python3 +\end{enumerate} + +\noindent +For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use \textbf{pip} as well and simply install Python as +\begin{enumerate} +\item sudo apt-get install python3 (or python for python2.7) +\end{enumerate} + +\noindent +etc etc. + +If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely +\begin{enumerate} +\item \href{{https://docs.anaconda.com/}}{Anaconda} Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system \textbf{conda} + +\item \href{{https://www.enthought.com/product/canopy/}}{Enthought canopy} is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license. +\end{enumerate} + +\noindent +Popular software packages written in Python for ML are + +\begin{itemize} +\item \href{{http://scikit-learn.org/stable/}}{Scikit-learn}, + +\item \href{{https://www.tensorflow.org/}}{Tensorflow}, + +\item \href{{http://pytorch.org/}}{PyTorch} and + +\item \href{{https://keras.io/}}{Keras}. +\end{itemize} + +\noindent +These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. + + +% ------------------- end of main content --------------- + +\end{document} + diff --git a/doc/pub/week46/ipynb/ipynb-week46-src.tar.gz b/doc/pub/week46/ipynb/ipynb-week46-src.tar.gz index 233750ecf..3de4fc51a 100644 Binary files a/doc/pub/week46/ipynb/ipynb-week46-src.tar.gz and b/doc/pub/week46/ipynb/ipynb-week46-src.tar.gz differ diff --git a/doc/pub/week46/ipynb/week46.ipynb b/doc/pub/week46/ipynb/week46.ipynb index d892a5475..5aaeebdc2 100644 --- a/doc/pub/week46/ipynb/week46.ipynb +++ b/doc/pub/week46/ipynb/week46.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "412fa071", + "id": "3ae913f7", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "06eaa518", + "id": "bde4c6f5", "metadata": { "editable": true }, @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "f58528ba", + "id": "9e846d96", "metadata": { "editable": true }, @@ -59,7 +59,7 @@ }, { "cell_type": "markdown", - "id": "fe8b81ce", + "id": "b181bac8", "metadata": { "editable": true }, @@ -90,7 +90,7 @@ }, { "cell_type": "markdown", - "id": "55c9b460", + "id": "5c065b15", "metadata": { "editable": true }, @@ -110,7 +110,7 @@ }, { "cell_type": "markdown", - "id": "13aa8693", + "id": "0685a1f3", "metadata": { "editable": true }, @@ -124,7 +124,7 @@ }, { "cell_type": "markdown", - "id": "3fe97766", + "id": "9deb4609", "metadata": { "editable": true }, @@ -137,7 +137,7 @@ }, { "cell_type": "markdown", - "id": "1e40a285", + "id": "971fbe6d", "metadata": { "editable": true }, @@ -155,7 +155,7 @@ }, { "cell_type": "markdown", - "id": "0f039b0c", + "id": "3c3fee0c", "metadata": { "editable": true }, @@ -178,7 +178,7 @@ }, { "cell_type": "markdown", - "id": "9f2b1935", + "id": "5d7a417e", "metadata": { "editable": true }, @@ -201,7 +201,7 @@ }, { "cell_type": "markdown", - "id": "667dbac8", + "id": "98739ae8", "metadata": { "editable": true }, @@ -212,7 +212,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "224b7914", + "id": "2e75ab9e", "metadata": { "collapsed": false, "editable": true @@ -313,7 +313,7 @@ }, { "cell_type": "markdown", - "id": "61056bcf", + "id": "402d8154", "metadata": { "editable": true }, @@ -335,7 +335,7 @@ }, { "cell_type": "markdown", - "id": "a9bb3d2c", + "id": "87283414", "metadata": { "editable": true }, @@ -347,7 +347,7 @@ }, { "cell_type": "markdown", - "id": "6aa287a7", + "id": "eeb2be0a", "metadata": { "editable": true }, @@ -358,7 +358,7 @@ }, { "cell_type": "markdown", - "id": "a0290f8d", + "id": "a5e0c38b", "metadata": { "editable": true }, @@ -380,7 +380,7 @@ }, { "cell_type": "markdown", - "id": "1a243e33", + "id": "5ade0c12", "metadata": { "editable": true }, @@ -393,7 +393,7 @@ }, { "cell_type": "markdown", - "id": "c91c18ba", + "id": "71c1603e", "metadata": { "editable": true }, @@ -405,7 +405,7 @@ }, { "cell_type": "markdown", - "id": "38e620f7", + "id": "d6925e9f", "metadata": { "editable": true }, @@ -415,7 +415,7 @@ }, { "cell_type": "markdown", - "id": "f5bad1b9", + "id": "9af60147", "metadata": { "editable": true }, @@ -427,7 +427,7 @@ }, { "cell_type": "markdown", - "id": "7df632cb", + "id": "1bc203e3", "metadata": { "editable": true }, @@ -437,7 +437,7 @@ }, { "cell_type": "markdown", - "id": "1ab52a46", + "id": "76c77683", "metadata": { "editable": true }, @@ -449,7 +449,7 @@ }, { "cell_type": "markdown", - "id": "fde2c32e", + "id": "118ed843", "metadata": { "editable": true }, @@ -482,7 +482,7 @@ }, { "cell_type": "markdown", - "id": "ba37ac87", + "id": "f14ea816", "metadata": { "editable": true }, @@ -506,7 +506,7 @@ }, { "cell_type": "markdown", - "id": "fc925db6", + "id": "4640b5b4", "metadata": { "editable": true }, @@ -518,7 +518,7 @@ }, { "cell_type": "markdown", - "id": "72b12d49", + "id": "41242ad5", "metadata": { "editable": true }, @@ -530,7 +530,7 @@ }, { "cell_type": "markdown", - "id": "2579801c", + "id": "0805b924", "metadata": { "editable": true }, @@ -558,7 +558,7 @@ }, { "cell_type": "markdown", - "id": "9797b152", + "id": "4d6bda4f", "metadata": { "editable": true }, @@ -584,7 +584,7 @@ }, { "cell_type": "markdown", - "id": "4836e23f", + "id": "f4ae76f5", "metadata": { "editable": true }, @@ -607,7 +607,7 @@ }, { "cell_type": "markdown", - "id": "2e6f6a44", + "id": "14644af5", "metadata": { "editable": true }, @@ -634,7 +634,7 @@ }, { "cell_type": "markdown", - "id": "78fca099", + "id": "5b850330", "metadata": { "editable": true }, @@ -653,7 +653,7 @@ }, { "cell_type": "markdown", - "id": "a85542fc", + "id": "ad83d169", "metadata": { "editable": true }, @@ -665,7 +665,7 @@ }, { "cell_type": "markdown", - "id": "d71ed79a", + "id": "21982bff", "metadata": { "editable": true }, @@ -678,7 +678,7 @@ }, { "cell_type": "markdown", - "id": "f940a8a5", + "id": "8c9ebead", "metadata": { "editable": true }, @@ -690,7 +690,7 @@ }, { "cell_type": "markdown", - "id": "e514b953", + "id": "56e01c7f", "metadata": { "editable": true }, @@ -700,7 +700,7 @@ }, { "cell_type": "markdown", - "id": "94ee340e", + "id": "9c656bf3", "metadata": { "editable": true }, @@ -712,7 +712,7 @@ }, { "cell_type": "markdown", - "id": "5258611b", + "id": "91267d63", "metadata": { "editable": true }, @@ -722,7 +722,7 @@ }, { "cell_type": "markdown", - "id": "92aff9a1", + "id": "78e120b8", "metadata": { "editable": true }, @@ -734,7 +734,7 @@ }, { "cell_type": "markdown", - "id": "3878c118", + "id": "aeac9581", "metadata": { "editable": true }, @@ -745,7 +745,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "316a9e84", + "id": "ea1f9010", "metadata": { "collapsed": false, "editable": true @@ -789,7 +789,7 @@ }, { "cell_type": "markdown", - "id": "d9d502d0", + "id": "8235025b", "metadata": { "editable": true }, @@ -800,7 +800,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "5682ec34", + "id": "34b62194", "metadata": { "collapsed": false, "editable": true @@ -835,7 +835,7 @@ }, { "cell_type": "markdown", - "id": "c9058975", + "id": "d89175d8", "metadata": { "editable": true }, @@ -848,7 +848,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "0a31a1e8", + "id": "41d0475a", "metadata": { "collapsed": false, "editable": true @@ -866,7 +866,7 @@ }, { "cell_type": "markdown", - "id": "c4268d2b", + "id": "c1b460bb", "metadata": { "editable": true }, @@ -880,7 +880,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "28c43d52", + "id": "6f103d31", "metadata": { "collapsed": false, "editable": true @@ -899,7 +899,7 @@ }, { "cell_type": "markdown", - "id": "ba7bcbc2", + "id": "573c8314", "metadata": { "editable": true }, @@ -919,7 +919,7 @@ }, { "cell_type": "markdown", - "id": "bbeb3a76", + "id": "090434b9", "metadata": { "editable": true }, @@ -936,7 +936,7 @@ }, { "cell_type": "markdown", - "id": "087645ff", + "id": "c9a39ce1", "metadata": { "editable": true }, @@ -948,7 +948,7 @@ }, { "cell_type": "markdown", - "id": "0bfe907e", + "id": "2d631ba5", "metadata": { "editable": true }, @@ -965,7 +965,7 @@ }, { "cell_type": "markdown", - "id": "ed3a24c1", + "id": "ffd719b4", "metadata": { "editable": true }, @@ -978,7 +978,7 @@ }, { "cell_type": "markdown", - "id": "6d5fa1b2", + "id": "90f1d88b", "metadata": { "editable": true }, @@ -990,7 +990,7 @@ }, { "cell_type": "markdown", - "id": "ec7a9513", + "id": "92376037", "metadata": { "editable": true }, @@ -1000,7 +1000,7 @@ }, { "cell_type": "markdown", - "id": "a20a7523", + "id": "24d1cf8d", "metadata": { "editable": true }, @@ -1012,7 +1012,7 @@ }, { "cell_type": "markdown", - "id": "ec4a4cab", + "id": "a4216389", "metadata": { "editable": true }, @@ -1022,7 +1022,7 @@ }, { "cell_type": "markdown", - "id": "0013fe85", + "id": "ac393440", "metadata": { "editable": true }, @@ -1034,7 +1034,7 @@ }, { "cell_type": "markdown", - "id": "3ca1f119", + "id": "d251764b", "metadata": { "editable": true }, @@ -1047,7 +1047,7 @@ }, { "cell_type": "markdown", - "id": "2053ceb1", + "id": "1ab6171a", "metadata": { "editable": true }, @@ -1062,7 +1062,7 @@ }, { "cell_type": "markdown", - "id": "12e5e36e", + "id": "d0e81ec2", "metadata": { "editable": true }, @@ -1088,7 +1088,7 @@ }, { "cell_type": "markdown", - "id": "44224dcb", + "id": "c2c41db9", "metadata": { "editable": true }, @@ -1116,7 +1116,7 @@ }, { "cell_type": "markdown", - "id": "915c9bcb", + "id": "8ba76cfd", "metadata": { "editable": true }, @@ -1133,7 +1133,7 @@ }, { "cell_type": "markdown", - "id": "ed1fbcff", + "id": "a7a4d204", "metadata": { "editable": true }, @@ -1147,7 +1147,7 @@ }, { "cell_type": "markdown", - "id": "c9d28c84", + "id": "51de5c69", "metadata": { "editable": true }, @@ -1163,7 +1163,7 @@ }, { "cell_type": "markdown", - "id": "8627a53a", + "id": "9f4bf856", "metadata": { "editable": true }, @@ -1174,7 +1174,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "1aa3c92d", + "id": "020402b2", "metadata": { "collapsed": false, "editable": true @@ -1245,7 +1245,7 @@ }, { "cell_type": "markdown", - "id": "dfd62ad1", + "id": "082c7f06", "metadata": { "editable": true }, @@ -1289,7 +1289,7 @@ }, { "cell_type": "markdown", - "id": "e6306992", + "id": "b742d7cc", "metadata": { "editable": true }, @@ -1300,7 +1300,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "08cbf1ba", + "id": "1f114a5a", "metadata": { "collapsed": false, "editable": true @@ -1378,7 +1378,7 @@ }, { "cell_type": "markdown", - "id": "badaa462", + "id": "3ae90db1", "metadata": { "editable": true }, @@ -1396,7 +1396,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "d7eca4e3", + "id": "22320738", "metadata": { "collapsed": false, "editable": true @@ -1467,7 +1467,7 @@ }, { "cell_type": "markdown", - "id": "e609f3f0", + "id": "ebd0ac9f", "metadata": { "editable": true }, @@ -1478,7 +1478,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "7783ddc2", + "id": "bfdc5109", "metadata": { "collapsed": false, "editable": true @@ -1496,7 +1496,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "ef4758a4", + "id": "ab8bb0be", "metadata": { "collapsed": false, "editable": true @@ -1511,7 +1511,7 @@ }, { "cell_type": "markdown", - "id": "a4ecb5a5", + "id": "b102de57", "metadata": { "editable": true }, @@ -1522,7 +1522,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "1fd6944c", + "id": "3aeec95d", "metadata": { "collapsed": false, "editable": true @@ -1572,7 +1572,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "e9903848", + "id": "638f8ac8", "metadata": { "collapsed": false, "editable": true @@ -1611,7 +1611,7 @@ }, { "cell_type": "markdown", - "id": "736c7714", + "id": "939c2f5c", "metadata": { "editable": true }, @@ -1635,7 +1635,7 @@ }, { "cell_type": "markdown", - "id": "641c4ab7", + "id": "121bdc13", "metadata": { "editable": true }, @@ -1663,7 +1663,7 @@ }, { "cell_type": "markdown", - "id": "f2e72566", + "id": "f58b9924", "metadata": { "editable": true }, @@ -1694,7 +1694,7 @@ }, { "cell_type": "markdown", - "id": "ea107cee", + "id": "3369dc37", "metadata": { "editable": true }, @@ -1710,7 +1710,7 @@ }, { "cell_type": "markdown", - "id": "1b1c2c46", + "id": "247d8e1f", "metadata": { "editable": true }, @@ -1734,7 +1734,7 @@ }, { "cell_type": "markdown", - "id": "78671c3e", + "id": "418dee56", "metadata": { "editable": true }, @@ -1765,7 +1765,7 @@ }, { "cell_type": "markdown", - "id": "2e9572b2", + "id": "81c7b4f6", "metadata": { "editable": true }, @@ -1776,7 +1776,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "87a91216", + "id": "c8635354", "metadata": { "collapsed": false, "editable": true @@ -1824,7 +1824,7 @@ }, { "cell_type": "markdown", - "id": "ec21ddcb", + "id": "6945cdc1", "metadata": { "editable": true }, @@ -1835,7 +1835,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "7efa5983", + "id": "dbe486ef", "metadata": { "collapsed": false, "editable": true @@ -1869,7 +1869,7 @@ }, { "cell_type": "markdown", - "id": "c94fdd9e", + "id": "31814f98", "metadata": { "editable": true }, @@ -1882,7 +1882,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "1ff6b136", + "id": "20858a25", "metadata": { "collapsed": false, "editable": true @@ -1935,7 +1935,7 @@ }, { "cell_type": "markdown", - "id": "baffd70d", + "id": "69bde19e", "metadata": { "editable": true }, @@ -1946,7 +1946,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "2a1f0f0d", + "id": "579fcaba", "metadata": { "collapsed": false, "editable": true @@ -1976,7 +1976,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "81cfb49c", + "id": "e19aed80", "metadata": { "collapsed": false, "editable": true @@ -1994,7 +1994,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "ce146db7", + "id": "5e7fff36", "metadata": { "collapsed": false, "editable": true @@ -2014,7 +2014,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "3e5e5740", + "id": "12a367f0", "metadata": { "collapsed": false, "editable": true @@ -2031,7 +2031,7 @@ }, { "cell_type": "markdown", - "id": "17506d34", + "id": "70753458", "metadata": { "editable": true }, @@ -2053,7 +2053,7 @@ }, { "cell_type": "markdown", - "id": "9bf49762", + "id": "d37bbe68", "metadata": { "editable": true }, @@ -2085,7 +2085,7 @@ }, { "cell_type": "markdown", - "id": "6f765d43", + "id": "498956cc", "metadata": { "editable": true }, @@ -2099,7 +2099,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "95bad7a4", + "id": "452de3bb", "metadata": { "collapsed": false, "editable": true @@ -2168,7 +2168,7 @@ }, { "cell_type": "markdown", - "id": "ce1ddd84", + "id": "b7a39b9f", "metadata": { "editable": true }, @@ -2191,7 +2191,7 @@ }, { "cell_type": "markdown", - "id": "d26e0049", + "id": "d39a6e13", "metadata": { "editable": true }, @@ -2203,7 +2203,7 @@ }, { "cell_type": "markdown", - "id": "fa8e6b26", + "id": "42f8693b", "metadata": { "editable": true }, @@ -2228,7 +2228,7 @@ }, { "cell_type": "markdown", - "id": "c4a12917", + "id": "a25fd53e", "metadata": { "editable": true }, @@ -2254,7 +2254,7 @@ }, { "cell_type": "markdown", - "id": "e115121c", + "id": "c72f80ca", "metadata": { "editable": true }, @@ -2265,7 +2265,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "141a1555", + "id": "9b20111b", "metadata": { "collapsed": false, "editable": true @@ -2337,7 +2337,7 @@ }, { "cell_type": "markdown", - "id": "10a44818", + "id": "a2a69156", "metadata": { "editable": true }, @@ -2353,7 +2353,7 @@ }, { "cell_type": "markdown", - "id": "bfcef20a", + "id": "935e5ca1", "metadata": { "editable": true }, @@ -2364,7 +2364,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "76fd8c7c", + "id": "2b6604c5", "metadata": { "collapsed": false, "editable": true @@ -2379,7 +2379,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "7c8a970d", + "id": "b6412285", "metadata": { "collapsed": false, "editable": true @@ -2397,7 +2397,7 @@ }, { "cell_type": "markdown", - "id": "9dcc9487", + "id": "c8adc4f4", "metadata": { "editable": true }, @@ -2417,7 +2417,7 @@ }, { "cell_type": "markdown", - "id": "79076633", + "id": "e0bd3a34", "metadata": { "editable": true }, @@ -2431,7 +2431,7 @@ }, { "cell_type": "markdown", - "id": "cf4c50af", + "id": "b93c398e", "metadata": { "editable": true }, @@ -2443,7 +2443,7 @@ }, { "cell_type": "markdown", - "id": "942127e6", + "id": "7fc3ae93", "metadata": { "editable": true }, @@ -2460,7 +2460,7 @@ }, { "cell_type": "markdown", - "id": "52015fd6", + "id": "e5c67b21", "metadata": { "editable": true }, @@ -2472,7 +2472,7 @@ }, { "cell_type": "markdown", - "id": "f4963135", + "id": "2d573725", "metadata": { "editable": true }, @@ -2486,7 +2486,7 @@ }, { "cell_type": "markdown", - "id": "84a3f642", + "id": "f8cf15d3", "metadata": { "editable": true }, @@ -2498,7 +2498,7 @@ }, { "cell_type": "markdown", - "id": "d6b120ad", + "id": "e734d8d4", "metadata": { "editable": true }, @@ -2511,7 +2511,7 @@ }, { "cell_type": "markdown", - "id": "3057a800", + "id": "0585b995", "metadata": { "editable": true }, @@ -2523,7 +2523,7 @@ }, { "cell_type": "markdown", - "id": "9ce41841", + "id": "b983e555", "metadata": { "editable": true }, @@ -2533,7 +2533,7 @@ }, { "cell_type": "markdown", - "id": "e629d4f9", + "id": "203a7a1c", "metadata": { "editable": true }, @@ -2561,7 +2561,7 @@ }, { "cell_type": "markdown", - "id": "4c14092d", + "id": "6d391d0c", "metadata": { "editable": true }, @@ -2577,7 +2577,7 @@ }, { "cell_type": "markdown", - "id": "9119c6f3", + "id": "3b98bb46", "metadata": { "editable": true }, @@ -2589,7 +2589,7 @@ }, { "cell_type": "markdown", - "id": "60eb2f52", + "id": "3d2a99d8", "metadata": { "editable": true }, @@ -2600,7 +2600,7 @@ }, { "cell_type": "markdown", - "id": "5f499f04", + "id": "3af9f679", "metadata": { "editable": true }, @@ -2612,7 +2612,7 @@ }, { "cell_type": "markdown", - "id": "5bb9a88f", + "id": "368371bc", "metadata": { "editable": true }, @@ -2622,7 +2622,7 @@ }, { "cell_type": "markdown", - "id": "bdb8a471", + "id": "ebc23cc6", "metadata": { "editable": true }, @@ -2634,7 +2634,7 @@ }, { "cell_type": "markdown", - "id": "9125265b", + "id": "3285cd00", "metadata": { "editable": true }, @@ -2644,7 +2644,7 @@ }, { "cell_type": "markdown", - "id": "f9bcdf59", + "id": "420c5c35", "metadata": { "editable": true }, @@ -2656,7 +2656,7 @@ }, { "cell_type": "markdown", - "id": "f64d41da", + "id": "2a386bd3", "metadata": { "editable": true }, @@ -2666,7 +2666,7 @@ }, { "cell_type": "markdown", - "id": "60380bf4", + "id": "cb75d383", "metadata": { "editable": true }, @@ -2678,7 +2678,7 @@ }, { "cell_type": "markdown", - "id": "fb6cd261", + "id": "d7aac8e6", "metadata": { "editable": true }, @@ -2692,7 +2692,7 @@ }, { "cell_type": "markdown", - "id": "19fa1bc1", + "id": "8211e34f", "metadata": { "editable": true }, @@ -2708,7 +2708,7 @@ }, { "cell_type": "markdown", - "id": "14869eaf", + "id": "0759bace", "metadata": { "editable": true }, @@ -2720,7 +2720,7 @@ }, { "cell_type": "markdown", - "id": "b67a64c3", + "id": "6a08f8a3", "metadata": { "editable": true }, @@ -2736,7 +2736,7 @@ }, { "cell_type": "markdown", - "id": "59aca04f", + "id": "ea71963f", "metadata": { "editable": true }, @@ -2748,7 +2748,7 @@ }, { "cell_type": "markdown", - "id": "95c0f671", + "id": "42c5df3b", "metadata": { "editable": true }, @@ -2758,7 +2758,7 @@ }, { "cell_type": "markdown", - "id": "faf8e906", + "id": "237180f9", "metadata": { "editable": true }, @@ -2770,7 +2770,7 @@ }, { "cell_type": "markdown", - "id": "fdef01e7", + "id": "2374907b", "metadata": { "editable": true }, @@ -2782,7 +2782,7 @@ }, { "cell_type": "markdown", - "id": "83e67d70", + "id": "04048caf", "metadata": { "editable": true }, @@ -2794,7 +2794,7 @@ }, { "cell_type": "markdown", - "id": "3c167dc0", + "id": "1a77afe0", "metadata": { "editable": true }, @@ -2805,7 +2805,7 @@ }, { "cell_type": "markdown", - "id": "a542df10", + "id": "981883bd", "metadata": { "editable": true }, @@ -2817,7 +2817,7 @@ }, { "cell_type": "markdown", - "id": "048606f2", + "id": "3d8d3830", "metadata": { "editable": true }, @@ -2828,7 +2828,7 @@ }, { "cell_type": "markdown", - "id": "0849517c", + "id": "fe3d598c", "metadata": { "editable": true }, @@ -2840,7 +2840,7 @@ }, { "cell_type": "markdown", - "id": "22994ad7", + "id": "762ac6b8", "metadata": { "editable": true }, @@ -2850,7 +2850,7 @@ }, { "cell_type": "markdown", - "id": "ba76b5fa", + "id": "396805d8", "metadata": { "editable": true }, @@ -2862,7 +2862,7 @@ }, { "cell_type": "markdown", - "id": "dfa03d62", + "id": "19ca93fe", "metadata": { "editable": true }, @@ -2874,7 +2874,7 @@ }, { "cell_type": "markdown", - "id": "7f8af900", + "id": "5b78c347", "metadata": { "editable": true }, @@ -2886,7 +2886,7 @@ }, { "cell_type": "markdown", - "id": "c7bc96a3", + "id": "742c335a", "metadata": { "editable": true }, @@ -2898,7 +2898,7 @@ }, { "cell_type": "markdown", - "id": "3dd711b0", + "id": "766b1fdd", "metadata": { "editable": true }, @@ -2908,7 +2908,7 @@ }, { "cell_type": "markdown", - "id": "362ce9e5", + "id": "d9698851", "metadata": { "editable": true }, @@ -2920,7 +2920,7 @@ }, { "cell_type": "markdown", - "id": "f90182c3", + "id": "8b9dc891", "metadata": { "editable": true }, @@ -2930,7 +2930,7 @@ }, { "cell_type": "markdown", - "id": "785bd7b4", + "id": "32e16984", "metadata": { "editable": true }, @@ -2942,7 +2942,7 @@ }, { "cell_type": "markdown", - "id": "c84248ab", + "id": "85898ea6", "metadata": { "editable": true }, @@ -2952,7 +2952,7 @@ }, { "cell_type": "markdown", - "id": "bd2cfd71", + "id": "e9c70102", "metadata": { "editable": true }, @@ -2964,7 +2964,7 @@ }, { "cell_type": "markdown", - "id": "5e30a895", + "id": "a00653d9", "metadata": { "editable": true }, @@ -2974,7 +2974,7 @@ }, { "cell_type": "markdown", - "id": "44faac5f", + "id": "e041fdeb", "metadata": { "editable": true }, @@ -2986,7 +2986,7 @@ }, { "cell_type": "markdown", - "id": "7198891c", + "id": "5f07c0b1", "metadata": { "editable": true }, @@ -2996,7 +2996,7 @@ }, { "cell_type": "markdown", - "id": "4f8608c6", + "id": "d13323ee", "metadata": { "editable": true }, @@ -3008,7 +3008,7 @@ }, { "cell_type": "markdown", - "id": "961207e1", + "id": "c7237587", "metadata": { "editable": true }, @@ -3028,7 +3028,7 @@ }, { "cell_type": "markdown", - "id": "1ba60f77", + "id": "5eabf8df", "metadata": { "editable": true }, @@ -3040,7 +3040,7 @@ }, { "cell_type": "markdown", - "id": "f0c95019", + "id": "309fe485", "metadata": { "editable": true }, @@ -3050,7 +3050,7 @@ }, { "cell_type": "markdown", - "id": "6a3c8c3e", + "id": "344c2fc2", "metadata": { "editable": true }, @@ -3066,7 +3066,7 @@ }, { "cell_type": "markdown", - "id": "a7695af1", + "id": "0af051ff", "metadata": { "editable": true }, @@ -3078,7 +3078,7 @@ }, { "cell_type": "markdown", - "id": "da3b7d37", + "id": "ebf99e70", "metadata": { "editable": true }, @@ -3106,7 +3106,7 @@ }, { "cell_type": "markdown", - "id": "0194b994", + "id": "38533606", "metadata": { "editable": true }, @@ -3119,7 +3119,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "31180ced", + "id": "58b8da05", "metadata": { "collapsed": false, "editable": true diff --git a/doc/src/Projects/2023/Project3/Project3.do.txt b/doc/src/Projects/2023/Project3/Project3.do.txt new file mode 100644 index 000000000..8263857a4 --- /dev/null +++ b/doc/src/Projects/2023/Project3/Project3.do.txt @@ -0,0 +1,248 @@ +TITLE: Project 3 on Machine Learning, deadline December 18 (midnight), 2023 +AUTHOR: "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo, Norway +DATE: today + + +======= Paths for project 3 ======= + +===== Defining the data sets to analyze yourself ===== + +For project 3, you can propose own data sets that relate to your research interests or just use existing data sets from say +o "Kaggle":"https://www.kaggle.com/datasets" +o The "University of California at Irvine (UCI) with its machine learning repository":"https://archive.ics.uci.edu/ml/index.php". +o Or other sources. + + +The approach to the analysis of these new data sets should follow to a large extent what you did in projects 1 and 2. That is: +o Whether you end up with a regression or a classification problem, you should employ at least two of the methods we have discussed among _linear regression (including Ridge and Lasso)_, _Logistic Regression_, _Neural Networks_, _Convolution Neural Networks_, _Recurrent Neural Networks_, and _Decision Trees, Random Forests, Bagging and Boosting_. You could for example explore all of the approaches from decision trees, via bagging and voting classifiers, to random forests, boosting and finally XGboost. If you wish to venture into _convolutional neural networks_ or _recurrent neural networks_, or extensions of neural networkds, feel free to do so. You can also study unsupervised methods, although we in this course have mainly paid attention to supervised learning. + +For Boosting, feel also free to write your own codes. + +o For project 3, you should feel free to use your own codes from projects 1 and 2, eventually write your own for Decision trees/random forests/bagging/boosting' or use the available functionality of _Scikit-Learn_, _Tensorflow_, etc. + +o The estimates you used and tested in projects 1 and 2 should also be included, that is the $R2$-score, _MSE_, confusion matrix, accuracy score, information gain, ROC and Cumulative gains curves and other, cross-validation and/or bootstrap if these are relevant. + +o Similarly, feel free to explore various activations functions in deep learning and various approachs to stochastic gradient descent approaches. + +o If possible, you should link the data sets with exisiting research and analyses thereof. Scientific articles which have used Machine Learning algorithms to analyze the data are highly welcome. Perhaps you can improve previous analyses and even publish a new article? + +o A critical assessment of the methods with ditto perspectives and recommendations is also something you need to include. + +All in all, the report should follow the same pattern as the two previous ones, with abstract, introduction, methods, code, results, conclusions etc.. + +We propose also an alternative to the above. This is a project on using machine learning methods (neural networks mainly) to the solution of ordinary differential equations and partial differential equations, with a final twist on how to diagonalize a symmetric matrix with neural networks. + +This is a field with a large interest recently, spanning from studies of turbulence in fluid mechanics and meteorology to the solution of quantum mechanical systems. As reading background you can use the slides "from week 43":"https://compphysics.github.io/MachineLearning/doc/pub/week43/html/week42.html" and/or the textbook by "Yadav et al":"https://www.springer.com/gp/book/9789401798150". + + +===== The basic structure of your project ===== + +Here follows a set up on how to structure your report and analyze the data you have opted for. + +=== Part a) === + +The first part deals with structuring and reading the data, much along the same lines as done in projects 1 and 2. Explain how the data are produced and place them in a proper context. + +=== Part b) === + +You need to include at least two central algorithms, or as an alternative explore methods from decisions tree to bagging, random forests and boosting. Explain the basics of the methods you have chosen to work with. This would be your theory part. + + +=== Part c) === + +Then describe your algorithm and its implementation and tests you have performed. + +=== Part d) === + +Then presents your results and findings, link with existing literature and more. + +=== Part e) === + +Finally, here you should present a critical assessment of the methods you have studied and link your results with the existing literature. + +===== Solving partial differential equations with neural networks ===== + +For this variant of project 3, we will assume that you have some +background in the solution of partial differential equations using +finite difference schemes. We will study the solution of the diffusion +equation in one dimension using a standard explicit scheme and neural +networks to solve the same equations. + +For the explicit scheme, you can study for example chapter 10 of the lecture notes in "Computational Physics":"https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Lectures/lectures2015.pdf" or alternative sources. For the solution of ordinary and partial differential equations using neural networks, the lectures by "Kristine Baluka Hein and included in the lectures of week 43":"https://compphysics.github.io/MachineLearning/doc/pub/week42/html/week43.html" at this course are highly recommended. + +For the machine learning part you can use your own code from project 2 or the functionality of for example _Tensorflow/Keras_.. + +=== Part a), setting up the problem === + +The physical problem can be that of the temperature gradient in a rod of length $L=1$ at $x=0$ and $x=1$. +We are looking at a one-dimensional +problem + +!bt +\begin{equation*} + \frac{\partial^2 u(x,t)}{\partial x^2} =\frac{\partial u(x,t)}{\partial t}, t> 0, x\in [0,L] +\end{equation*} +!et +or + +!bt +\begin{equation*} +u_{xx} = u_t, +\end{equation*} +!et +with initial conditions, i.e., the conditions at $t=0$, +!bt +\begin{equation*} +u(x,0)= \sin{(\pi x)} \hspace{0.5cm} 0 < x < L, +\end{equation*} +!et +with $L=1$ the length of the $x$-region of interest. The +boundary conditions are + +!bt +\begin{equation*} +u(0,t)= 0 \hspace{0.5cm} t \ge 0, +\end{equation*} +!et +and + +!bt +\begin{equation*} +u(L,t)= 0 \hspace{0.5cm} t \ge 0. +\end{equation*} +!et +The function $u(x,t)$ can be the temperature gradient of a rod. +As time increases, the velocity approaches a linear variation with $x$. + +We will limit ourselves to the so-called explicit forward Euler algorithm with discretized versions of time given by a forward formula and a centered difference in space resulting in +!bt +\begin{equation*} +u_t\approx \frac{u(x,t+\Delta t)-u(x,t)}{\Delta t}=\frac{u(x_i,t_j+\Delta t)-u(x_i,t_j)}{\Delta t} +\end{equation*} +!et +and + +!bt +\begin{equation*} +u_{xx}\approx \frac{u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{\Delta x^2}, +\end{equation*} +!et +or + +!bt +\begin{equation*} +u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2}. +\end{equation*} +!et + +Write down the algorithm and the equations you need to implement. +Find also the analytical solution to the problem. + +=== Part b) === + +Implement the explicit scheme algorithm and perform tests of the solution +for $\Delta x=1/10$, $\Delta x=1/100$ using $\Delta t$ as dictated by the stability limit of the explicit scheme. The stability criterion for the explicit scheme requires that $\Delta t/\Delta x^2 \leq 1/2$. + +Study the solutions at two time points $t_1$ and $t_2$ where $u(x,t_1)$ is smooth but still significantly curved +and $u(x,t_2)$ is almost linear, close to the stationary state. + + +=== Part c) Neural networks === + +Study now the lecture notes on solving ODEs and PDEs with neural +network and use either your own code from project 2 or the +functionality of tensorflow/keras to solve the same equation as in +part b). Discuss your results and compare them with the standard +explicit scheme. Include also the analytical solution and compare with +that. + + + + +=== Part d) === + +Finally, present a critical assessment of the methods you have studied +and discuss the potential for the solving differential equations and +eigenvalue problems with machine learning methods. + + + +===== Introduction to numerical projects ===== + +Here follows a brief recipe and recommendation on how to write a report for each +project. + + * Give a short description of the nature of the problem and the eventual numerical methods you have used. + + * Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + * Include the source code of your program. Comment your program properly. + + * If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + * Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + * Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + * Try to give an interpretation of you results in your answers to the problems. + + * Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + * Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. + + + + + + +===== Format for electronic delivery of report and programs ===== + +The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report: + + * Use Canvas to hand in your projects, log in at URL:"https://www.uio.no/english/services/it/education/canvas/" with your normal UiO username and password. + + * Upload _only_ the report file or the link to your GitHub/GitLab or similar typo of repos! For the source code file(s) you have developed please provide us with your link to your GitHub/GitLab or similar domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them. + + * In your GitHub/GitLab or similar repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters. + + +Finally, +we encourage you to collaborate. Optimal working groups consist of +2-3 students. You can then hand in a common report. + + + +===== Software and needed installations ===== + +If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, +we recommend that you install the following Python packages via _pip_ as +o pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow +For Python3, replace _pip_ with _pip3_. + +See below for a discussion of _tensorflow_ and _scikit-learn_. + +For OSX users we recommend also, after having installed Xcode, to install _brew_. Brew allows +for a seamless installation of additional software via for example +o brew install python3 + +For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution +you can use _pip_ as well and simply install Python as +o sudo apt-get install python3 (or python for python2.7) +etc etc. + +If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely +o "Anaconda":"https://docs.anaconda.com/" Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system _conda_ +o "Enthought canopy":"https://www.enthought.com/product/canopy/" is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license. + +Popular software packages written in Python for ML are + +* "Scikit-learn":"http://scikit-learn.org/stable/", +* "Tensorflow":"https://www.tensorflow.org/", +* "PyTorch":"http://pytorch.org/" and +* "Keras":"https://keras.io/". +These are all freely available at their respective GitHub sites. They +encompass communities of developers in the thousands or more. And the number +of code developers and contributors keeps increasing. + + + diff --git a/doc/src/Projects/2023/Project3/clean.sh b/doc/src/Projects/2023/Project3/clean.sh new file mode 100755 index 000000000..2e5da2c72 --- /dev/null +++ b/doc/src/Projects/2023/Project3/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +doconce clean +rm -rf *.pdf *.tex ipynb*.tar.gz *.html ._*.html *~ reveal.js Trash README.txt diff --git a/doc/src/Projects/2023/Project3/make.sh b/doc/src/Projects/2023/Project3/make.sh new file mode 100755 index 000000000..0426adfca --- /dev/null +++ b/doc/src/Projects/2023/Project3/make.sh @@ -0,0 +1,87 @@ +#!/bin/sh +set -x + +function system { + "$@" + if [ $? -ne 0 ]; then + echo "make.sh: unsuccessful command $@" + echo "abort!" + exit 1 + fi +} + +if [ $# -eq 0 ]; then +echo 'bash make.sh slides1|slides2' +exit 1 +fi + +name=$1 +rm -f *.tar.gz + +opt="--encoding=utf-8" +opt= + +rm -f *.aux + + + +# Plain HTML documents +html=${name} +system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt +system doconce split_html $html.html --method=space10 + +# Bootstrap style +html=${name}-bs +system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt +system doconce split_html $html.html --method=split --pagination --nav_button=bottom + +# IPython notebook +system doconce format ipynb $name $opt + + +# Ordinary plain LaTeX document +system doconce format pdflatex $name --print_latex_style=trac --latex_admon=paragraph $opt +system doconce ptex2tex $name envir=verbatim +# Add special packages +doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex +doconce replace 'section{' 'section*{' $name.tex +pdflatex -shell-escape $name +pdflatex -shell-escape $name +mv -f $name.pdf ${name}.pdf +cp $name.tex ${name}.tex + +# Publish +dest=../../../../Projects/2023 +if [ ! -d $dest/$name ]; then +mkdir $dest/$name +mkdir $dest/$name/pdf +mkdir $dest/$name/html +mkdir $dest/$name/ipynb +fi +cp ${name}*.tex $dest/$name/pdf +cp ${name}*.pdf $dest/$name/pdf +cp -r ${name}*.html ._${name}*.html $dest/$name/html + +# Figures: cannot just copy link, need to physically copy the files +if [ -d fig-${name} ]; then +if [ ! -d $dest/$name/html/fig-$name ]; then +mkdir $dest/$name/html/fig-$name +fi +cp -r fig-${name}/* $dest/$name/html/fig-$name +fi + +cp ${name}.ipynb $dest/$name/ipynb +ipynb_tarfile=ipynb-${name}-src.tar.gz +if [ ! -f ${ipynb_tarfile} ]; then +cat > README.txt <