diff --git a/doc/LectureNotes/_build/.doctrees/chapter1.doctree b/doc/LectureNotes/_build/.doctrees/chapter1.doctree index f139420c4..94096a22c 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter1.doctree and b/doc/LectureNotes/_build/.doctrees/chapter1.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter10.doctree b/doc/LectureNotes/_build/.doctrees/chapter10.doctree index f8d0e5616..16d645706 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter10.doctree and b/doc/LectureNotes/_build/.doctrees/chapter10.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter11.doctree b/doc/LectureNotes/_build/.doctrees/chapter11.doctree index f71b9287b..93cfb0545 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter11.doctree and b/doc/LectureNotes/_build/.doctrees/chapter11.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter12.doctree b/doc/LectureNotes/_build/.doctrees/chapter12.doctree index 1436f7a9a..7734d88f4 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter12.doctree and b/doc/LectureNotes/_build/.doctrees/chapter12.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter13.doctree b/doc/LectureNotes/_build/.doctrees/chapter13.doctree index f5369aedf..d4c6bd2d1 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter13.doctree and b/doc/LectureNotes/_build/.doctrees/chapter13.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter2.doctree b/doc/LectureNotes/_build/.doctrees/chapter2.doctree index 10c950a54..10950efd1 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter2.doctree and b/doc/LectureNotes/_build/.doctrees/chapter2.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter3.doctree b/doc/LectureNotes/_build/.doctrees/chapter3.doctree index 640fcb0b0..6f64a3991 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter3.doctree and b/doc/LectureNotes/_build/.doctrees/chapter3.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter4.doctree b/doc/LectureNotes/_build/.doctrees/chapter4.doctree index 70b0099ee..c317ca283 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter4.doctree and b/doc/LectureNotes/_build/.doctrees/chapter4.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter5.doctree b/doc/LectureNotes/_build/.doctrees/chapter5.doctree index 3d8e98bc9..ed00de71e 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter5.doctree and b/doc/LectureNotes/_build/.doctrees/chapter5.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter6.doctree b/doc/LectureNotes/_build/.doctrees/chapter6.doctree index aaef2ed8c..926b2d9c9 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter6.doctree and b/doc/LectureNotes/_build/.doctrees/chapter6.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter7.doctree b/doc/LectureNotes/_build/.doctrees/chapter7.doctree index a350e223a..c27ff1e92 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter7.doctree and b/doc/LectureNotes/_build/.doctrees/chapter7.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter8.doctree b/doc/LectureNotes/_build/.doctrees/chapter8.doctree index 49ce8728c..9b344d827 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter8.doctree and b/doc/LectureNotes/_build/.doctrees/chapter8.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapter9.doctree b/doc/LectureNotes/_build/.doctrees/chapter9.doctree index bbb6e1ea3..09102cf80 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapter9.doctree and b/doc/LectureNotes/_build/.doctrees/chapter9.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/chapteroptimization.doctree b/doc/LectureNotes/_build/.doctrees/chapteroptimization.doctree index 98ee6b3cb..639d50447 100644 Binary files a/doc/LectureNotes/_build/.doctrees/chapteroptimization.doctree and b/doc/LectureNotes/_build/.doctrees/chapteroptimization.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/clustering.doctree b/doc/LectureNotes/_build/.doctrees/clustering.doctree index 2286e96aa..e2f6b1576 100644 Binary files a/doc/LectureNotes/_build/.doctrees/clustering.doctree and b/doc/LectureNotes/_build/.doctrees/clustering.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/environment.pickle b/doc/LectureNotes/_build/.doctrees/environment.pickle index 906fc9a4c..15fe89e81 100644 Binary files a/doc/LectureNotes/_build/.doctrees/environment.pickle and b/doc/LectureNotes/_build/.doctrees/environment.pickle differ diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek34.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek34.doctree index a652d192b..f90571818 100644 Binary files a/doc/LectureNotes/_build/.doctrees/exercisesweek34.doctree and b/doc/LectureNotes/_build/.doctrees/exercisesweek34.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek35.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek35.doctree index 3e8c9fa18..abb9800a1 100644 Binary files a/doc/LectureNotes/_build/.doctrees/exercisesweek35.doctree and b/doc/LectureNotes/_build/.doctrees/exercisesweek35.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek36.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek36.doctree index 9aab23cea..44e16bdf6 100644 Binary files a/doc/LectureNotes/_build/.doctrees/exercisesweek36.doctree and b/doc/LectureNotes/_build/.doctrees/exercisesweek36.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek37.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek37.doctree index dc84301e5..186f7108c 100644 Binary files a/doc/LectureNotes/_build/.doctrees/exercisesweek37.doctree and b/doc/LectureNotes/_build/.doctrees/exercisesweek37.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek38.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek38.doctree index b42810ad2..07cf47f6c 100644 Binary files a/doc/LectureNotes/_build/.doctrees/exercisesweek38.doctree and b/doc/LectureNotes/_build/.doctrees/exercisesweek38.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/intro.doctree b/doc/LectureNotes/_build/.doctrees/intro.doctree index 8d9d7609b..d4ac4aaa5 100644 Binary files a/doc/LectureNotes/_build/.doctrees/intro.doctree and b/doc/LectureNotes/_build/.doctrees/intro.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/linalg.doctree b/doc/LectureNotes/_build/.doctrees/linalg.doctree index f6cea3ffb..5af7c7c51 100644 Binary files a/doc/LectureNotes/_build/.doctrees/linalg.doctree and b/doc/LectureNotes/_build/.doctrees/linalg.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/project1.doctree b/doc/LectureNotes/_build/.doctrees/project1.doctree index a9a908212..6a4dfae02 100644 Binary files a/doc/LectureNotes/_build/.doctrees/project1.doctree and b/doc/LectureNotes/_build/.doctrees/project1.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/schedule.doctree b/doc/LectureNotes/_build/.doctrees/schedule.doctree index 631523e8a..6b4eb208a 100644 Binary files a/doc/LectureNotes/_build/.doctrees/schedule.doctree and b/doc/LectureNotes/_build/.doctrees/schedule.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/statistics.doctree b/doc/LectureNotes/_build/.doctrees/statistics.doctree index 7280a9ac4..69fad5cca 100644 Binary files a/doc/LectureNotes/_build/.doctrees/statistics.doctree and b/doc/LectureNotes/_build/.doctrees/statistics.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/teachers.doctree b/doc/LectureNotes/_build/.doctrees/teachers.doctree index 6897fc9e0..480062f27 100644 Binary files a/doc/LectureNotes/_build/.doctrees/teachers.doctree and b/doc/LectureNotes/_build/.doctrees/teachers.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/textbooks.doctree b/doc/LectureNotes/_build/.doctrees/textbooks.doctree index ba0cbe33c..b31b7ac49 100644 Binary files a/doc/LectureNotes/_build/.doctrees/textbooks.doctree and b/doc/LectureNotes/_build/.doctrees/textbooks.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/week34.doctree b/doc/LectureNotes/_build/.doctrees/week34.doctree index aba08a777..c853f3f09 100644 Binary files a/doc/LectureNotes/_build/.doctrees/week34.doctree and b/doc/LectureNotes/_build/.doctrees/week34.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/week35.doctree b/doc/LectureNotes/_build/.doctrees/week35.doctree index d2306087b..e79225edb 100644 Binary files a/doc/LectureNotes/_build/.doctrees/week35.doctree and b/doc/LectureNotes/_build/.doctrees/week35.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/week36.doctree b/doc/LectureNotes/_build/.doctrees/week36.doctree index 8c9d05557..099565660 100644 Binary files a/doc/LectureNotes/_build/.doctrees/week36.doctree and b/doc/LectureNotes/_build/.doctrees/week36.doctree differ diff --git a/doc/LectureNotes/_build/.doctrees/week37.doctree b/doc/LectureNotes/_build/.doctrees/week37.doctree index 334bf3af2..c9bd69e51 100644 Binary files a/doc/LectureNotes/_build/.doctrees/week37.doctree and b/doc/LectureNotes/_build/.doctrees/week37.doctree differ diff --git a/doc/LectureNotes/_build/html/.buildinfo b/doc/LectureNotes/_build/html/.buildinfo index 64aa33a7e..8e698d5e3 100644 --- a/doc/LectureNotes/_build/html/.buildinfo +++ b/doc/LectureNotes/_build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 73ce6691cda151d4aabc9466268ebbb7 +config: e92a03a57b79a66b55d813e5d2c5e8ea tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/doc/LectureNotes/_build/html/_images/000000.png b/doc/LectureNotes/_build/html/_images/000000.png new file mode 100644 index 000000000..6495ae016 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/000000.png differ diff --git a/doc/LectureNotes/_build/html/_images/005b82.png b/doc/LectureNotes/_build/html/_images/005b82.png new file mode 100644 index 000000000..1842c5ee3 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/005b82.png differ diff --git a/doc/LectureNotes/_build/html/_images/00622f.png b/doc/LectureNotes/_build/html/_images/00622f.png new file mode 100644 index 000000000..1226459ce Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/00622f.png differ diff --git a/doc/LectureNotes/_build/html/_images/0072b2.png b/doc/LectureNotes/_build/html/_images/0072b2.png new file mode 100644 index 000000000..03e4db02f Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/0072b2.png differ diff --git a/doc/LectureNotes/_build/html/_images/00749c.png b/doc/LectureNotes/_build/html/_images/00749c.png new file mode 100644 index 000000000..64f9a001a Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/00749c.png differ diff --git a/doc/LectureNotes/_build/html/_images/008561.png b/doc/LectureNotes/_build/html/_images/008561.png new file mode 100644 index 000000000..8c4c56b64 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/008561.png differ diff --git a/doc/LectureNotes/_build/html/_images/00e0e0.png b/doc/LectureNotes/_build/html/_images/00e0e0.png new file mode 100644 index 000000000..0ceb5bcd8 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/00e0e0.png differ diff --git a/doc/LectureNotes/_build/html/_images/023b95.png b/doc/LectureNotes/_build/html/_images/023b95.png new file mode 100644 index 000000000..8b48ae837 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/023b95.png differ diff --git a/doc/LectureNotes/_build/html/_images/024c1a.png b/doc/LectureNotes/_build/html/_images/024c1a.png new file mode 100644 index 000000000..692ad9457 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/024c1a.png differ diff --git a/doc/LectureNotes/_build/html/_images/0550ae.png b/doc/LectureNotes/_build/html/_images/0550ae.png new file mode 100644 index 000000000..b6e505fa9 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/0550ae.png differ diff --git a/doc/LectureNotes/_build/html/_images/080808.png b/doc/LectureNotes/_build/html/_images/080808.png new file mode 100644 index 000000000..ad395a689 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/080808.png differ diff --git a/doc/LectureNotes/_build/html/_images/116329.png b/doc/LectureNotes/_build/html/_images/116329.png new file mode 100644 index 000000000..55ddb67a3 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/116329.png differ diff --git a/doc/LectureNotes/_build/html/_images/116633.png b/doc/LectureNotes/_build/html/_images/116633.png new file mode 100644 index 000000000..340ef62ef Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/116633.png differ diff --git a/doc/LectureNotes/_build/html/_images/141414.png b/doc/LectureNotes/_build/html/_images/141414.png new file mode 100644 index 000000000..4aa24384e Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/141414.png differ diff --git a/doc/LectureNotes/_build/html/_images/18c1c4.png b/doc/LectureNotes/_build/html/_images/18c1c4.png new file mode 100644 index 000000000..1cfdaff04 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/18c1c4.png differ diff --git a/doc/LectureNotes/_build/html/_images/1e1e1e.png b/doc/LectureNotes/_build/html/_images/1e1e1e.png new file mode 100644 index 000000000..bd434c627 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/1e1e1e.png differ diff --git a/doc/LectureNotes/_build/html/_images/24292f.png b/doc/LectureNotes/_build/html/_images/24292f.png new file mode 100644 index 000000000..8a6e5b70d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/24292f.png differ diff --git a/doc/LectureNotes/_build/html/_images/3d73a9.png b/doc/LectureNotes/_build/html/_images/3d73a9.png new file mode 100644 index 000000000..bb65f9821 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/3d73a9.png differ diff --git a/doc/LectureNotes/_build/html/_images/437a6b.png b/doc/LectureNotes/_build/html/_images/437a6b.png new file mode 100644 index 000000000..3be95ecdd Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/437a6b.png differ diff --git a/doc/LectureNotes/_build/html/_images/515151.png b/doc/LectureNotes/_build/html/_images/515151.png new file mode 100644 index 000000000..491fc486c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/515151.png differ diff --git a/doc/LectureNotes/_build/html/_images/5391cf.png b/doc/LectureNotes/_build/html/_images/5391cf.png new file mode 100644 index 000000000..9676ecf32 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/5391cf.png differ diff --git a/doc/LectureNotes/_build/html/_images/5ca7e4.png b/doc/LectureNotes/_build/html/_images/5ca7e4.png new file mode 100644 index 000000000..b580c19ec Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/5ca7e4.png differ diff --git a/doc/LectureNotes/_build/html/_images/622cbc.png b/doc/LectureNotes/_build/html/_images/622cbc.png new file mode 100644 index 000000000..3591ab100 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/622cbc.png differ diff --git a/doc/LectureNotes/_build/html/_images/66707b.png b/doc/LectureNotes/_build/html/_images/66707b.png new file mode 100644 index 000000000..f4189a06c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/66707b.png differ diff --git a/doc/LectureNotes/_build/html/_images/66ccee.png b/doc/LectureNotes/_build/html/_images/66ccee.png new file mode 100644 index 000000000..a83dab6e2 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/66ccee.png differ diff --git a/doc/LectureNotes/_build/html/_images/66e9ec.png b/doc/LectureNotes/_build/html/_images/66e9ec.png new file mode 100644 index 000000000..1c98cea18 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/66e9ec.png differ diff --git a/doc/LectureNotes/_build/html/_images/6730c5.png b/doc/LectureNotes/_build/html/_images/6730c5.png new file mode 100644 index 000000000..38814dbc4 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/6730c5.png differ diff --git a/doc/LectureNotes/_build/html/_images/6e7781.png b/doc/LectureNotes/_build/html/_images/6e7781.png new file mode 100644 index 000000000..db5ddb9ea Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/6e7781.png differ diff --git a/doc/LectureNotes/_build/html/_images/6f98b3.png b/doc/LectureNotes/_build/html/_images/6f98b3.png new file mode 100644 index 000000000..fbaa00f2f Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/6f98b3.png differ diff --git a/doc/LectureNotes/_build/html/_images/702c00.png b/doc/LectureNotes/_build/html/_images/702c00.png new file mode 100644 index 000000000..64de65cc3 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/702c00.png differ diff --git a/doc/LectureNotes/_build/html/_images/72f088.png b/doc/LectureNotes/_build/html/_images/72f088.png new file mode 100644 index 000000000..e624bc7f6 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/72f088.png differ diff --git a/doc/LectureNotes/_build/html/_images/737373.png b/doc/LectureNotes/_build/html/_images/737373.png new file mode 100644 index 000000000..436059c52 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/737373.png differ diff --git a/doc/LectureNotes/_build/html/_images/797979.png b/doc/LectureNotes/_build/html/_images/797979.png new file mode 100644 index 000000000..5642e0e9e Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/797979.png differ diff --git a/doc/LectureNotes/_build/html/_images/7998f2.png b/doc/LectureNotes/_build/html/_images/7998f2.png new file mode 100644 index 000000000..fc8b9ec22 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/7998f2.png differ diff --git a/doc/LectureNotes/_build/html/_images/79c0ff.png b/doc/LectureNotes/_build/html/_images/79c0ff.png new file mode 100644 index 000000000..0c15a6509 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/79c0ff.png differ diff --git a/doc/LectureNotes/_build/html/_images/7ee787.png b/doc/LectureNotes/_build/html/_images/7ee787.png new file mode 100644 index 000000000..639863c5c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/7ee787.png differ diff --git a/doc/LectureNotes/_build/html/_images/7f4707.png b/doc/LectureNotes/_build/html/_images/7f4707.png new file mode 100644 index 000000000..248de1972 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/7f4707.png differ diff --git a/doc/LectureNotes/_build/html/_images/8045e5.png b/doc/LectureNotes/_build/html/_images/8045e5.png new file mode 100644 index 000000000..08ab32e85 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8045e5.png differ diff --git a/doc/LectureNotes/_build/html/_images/81b19b.png b/doc/LectureNotes/_build/html/_images/81b19b.png new file mode 100644 index 000000000..e2b23db8f Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/81b19b.png differ diff --git a/doc/LectureNotes/_build/html/_images/8250df.png b/doc/LectureNotes/_build/html/_images/8250df.png new file mode 100644 index 000000000..fd096abf0 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8250df.png differ diff --git a/doc/LectureNotes/_build/html/_images/8786ac.png b/doc/LectureNotes/_build/html/_images/8786ac.png new file mode 100644 index 000000000..995c0e551 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8786ac.png differ diff --git a/doc/LectureNotes/_build/html/_images/8a4600.png b/doc/LectureNotes/_build/html/_images/8a4600.png new file mode 100644 index 000000000..2fc6f5809 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8a4600.png differ diff --git a/doc/LectureNotes/_build/html/_images/8b949e.png b/doc/LectureNotes/_build/html/_images/8b949e.png new file mode 100644 index 000000000..ad7978584 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8b949e.png differ diff --git a/doc/LectureNotes/_build/html/_images/8c8c8c.png b/doc/LectureNotes/_build/html/_images/8c8c8c.png new file mode 100644 index 000000000..b8cd92d80 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/8c8c8c.png differ diff --git a/doc/LectureNotes/_build/html/_images/912583.png b/doc/LectureNotes/_build/html/_images/912583.png new file mode 100644 index 000000000..a71611eae Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/912583.png differ diff --git a/doc/LectureNotes/_build/html/_images/91cbff.png b/doc/LectureNotes/_build/html/_images/91cbff.png new file mode 100644 index 000000000..58e7706f7 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/91cbff.png differ diff --git a/doc/LectureNotes/_build/html/_images/953800.png b/doc/LectureNotes/_build/html/_images/953800.png new file mode 100644 index 000000000..b102d5e58 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/953800.png differ diff --git a/doc/LectureNotes/_build/html/_images/974eb7.png b/doc/LectureNotes/_build/html/_images/974eb7.png new file mode 100644 index 000000000..0cd42cd71 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/974eb7.png differ diff --git a/doc/LectureNotes/_build/html/_images/98661b.png b/doc/LectureNotes/_build/html/_images/98661b.png new file mode 100644 index 000000000..030036eaf Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/98661b.png differ diff --git a/doc/LectureNotes/_build/html/_images/996b00.png b/doc/LectureNotes/_build/html/_images/996b00.png new file mode 100644 index 000000000..1f1404f3f Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/996b00.png differ diff --git a/doc/LectureNotes/_build/html/_images/9e86c8.png b/doc/LectureNotes/_build/html/_images/9e86c8.png new file mode 100644 index 000000000..d66df7500 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/9e86c8.png differ diff --git a/doc/LectureNotes/_build/html/_images/9e8741.png b/doc/LectureNotes/_build/html/_images/9e8741.png new file mode 100644 index 000000000..53d7ec828 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/9e8741.png differ diff --git a/doc/LectureNotes/_build/html/_images/9f4e55.png b/doc/LectureNotes/_build/html/_images/9f4e55.png new file mode 100644 index 000000000..422fefee1 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/9f4e55.png differ diff --git a/doc/LectureNotes/_build/html/_images/a0111f.png b/doc/LectureNotes/_build/html/_images/a0111f.png new file mode 100644 index 000000000..dc3d2c82d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a0111f.png differ diff --git a/doc/LectureNotes/_build/html/_images/a11y-dark.png b/doc/LectureNotes/_build/html/_images/a11y-dark.png new file mode 100644 index 000000000..08447103a Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a11y-dark.png differ diff --git a/doc/LectureNotes/_build/html/_images/a11y-high-contrast-dark.png b/doc/LectureNotes/_build/html/_images/a11y-high-contrast-dark.png new file mode 100644 index 000000000..6e422ed62 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a11y-high-contrast-dark.png differ diff --git a/doc/LectureNotes/_build/html/_images/a11y-high-contrast-light.png b/doc/LectureNotes/_build/html/_images/a11y-high-contrast-light.png new file mode 100644 index 000000000..6bb19b562 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a11y-high-contrast-light.png differ diff --git a/doc/LectureNotes/_build/html/_images/a11y-light.png b/doc/LectureNotes/_build/html/_images/a11y-light.png new file mode 100644 index 000000000..7585d6db7 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a11y-light.png differ diff --git a/doc/LectureNotes/_build/html/_images/a12236.png b/doc/LectureNotes/_build/html/_images/a12236.png new file mode 100644 index 000000000..a61aa4df5 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a12236.png differ diff --git a/doc/LectureNotes/_build/html/_images/a25e53.png b/doc/LectureNotes/_build/html/_images/a25e53.png new file mode 100644 index 000000000..67d5db79c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a25e53.png differ diff --git a/doc/LectureNotes/_build/html/_images/a2bffc.png b/doc/LectureNotes/_build/html/_images/a2bffc.png new file mode 100644 index 000000000..74fd8d7fd Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a2bffc.png differ diff --git a/doc/LectureNotes/_build/html/_images/a5d6ff.png b/doc/LectureNotes/_build/html/_images/a5d6ff.png new file mode 100644 index 000000000..85dc8ab5c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/a5d6ff.png differ diff --git a/doc/LectureNotes/_build/html/_images/ab6369.png b/doc/LectureNotes/_build/html/_images/ab6369.png new file mode 100644 index 000000000..bbe790f35 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ab6369.png differ diff --git a/doc/LectureNotes/_build/html/_images/abe338.png b/doc/LectureNotes/_build/html/_images/abe338.png new file mode 100644 index 000000000..f71421dc4 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/abe338.png differ diff --git a/doc/LectureNotes/_build/html/_images/b19db4.png b/doc/LectureNotes/_build/html/_images/b19db4.png new file mode 100644 index 000000000..2bcf14bf7 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/b19db4.png differ diff --git a/doc/LectureNotes/_build/html/_images/b1bac4.png b/doc/LectureNotes/_build/html/_images/b1bac4.png new file mode 100644 index 000000000..fa99254a4 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/b1bac4.png differ diff --git a/doc/LectureNotes/_build/html/_images/b35900.png b/doc/LectureNotes/_build/html/_images/b35900.png new file mode 100644 index 000000000..af6314be1 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/b35900.png differ diff --git a/doc/LectureNotes/_build/html/_images/b89784.png b/doc/LectureNotes/_build/html/_images/b89784.png new file mode 100644 index 000000000..553c732ed Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/b89784.png differ diff --git a/doc/LectureNotes/_build/html/_images/bbbbbb.png b/doc/LectureNotes/_build/html/_images/bbbbbb.png new file mode 100644 index 000000000..45fa9bad4 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/bbbbbb.png differ diff --git a/doc/LectureNotes/_build/html/_images/bf5400.png b/doc/LectureNotes/_build/html/_images/bf5400.png new file mode 100644 index 000000000..ba4f6a062 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/bf5400.png differ diff --git a/doc/LectureNotes/_build/html/_images/blinds-dark.png b/doc/LectureNotes/_build/html/_images/blinds-dark.png new file mode 100644 index 000000000..fca57415b Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/blinds-dark.png differ diff --git a/doc/LectureNotes/_build/html/_images/blinds-light.png b/doc/LectureNotes/_build/html/_images/blinds-light.png new file mode 100644 index 000000000..c715ebf74 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/blinds-light.png differ diff --git a/doc/LectureNotes/_build/html/_images/c4a2f5.png b/doc/LectureNotes/_build/html/_images/c4a2f5.png new file mode 100644 index 000000000..815fa9a09 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/c4a2f5.png differ diff --git a/doc/LectureNotes/_build/html/_images/c5e478.png b/doc/LectureNotes/_build/html/_images/c5e478.png new file mode 100644 index 000000000..450f66bdf Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/c5e478.png differ diff --git a/doc/LectureNotes/_build/html/_images/c9d1d9.png b/doc/LectureNotes/_build/html/_images/c9d1d9.png new file mode 100644 index 000000000..56df44316 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/c9d1d9.png differ diff --git a/doc/LectureNotes/_build/html/_images/caab6d.png b/doc/LectureNotes/_build/html/_images/caab6d.png new file mode 100644 index 000000000..a20ea8967 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/caab6d.png differ diff --git a/doc/LectureNotes/_build/html/_images/cc398b.png b/doc/LectureNotes/_build/html/_images/cc398b.png new file mode 100644 index 000000000..b05f6b3f6 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/cc398b.png differ diff --git a/doc/LectureNotes/_build/html/_images/ccbb44.png b/doc/LectureNotes/_build/html/_images/ccbb44.png new file mode 100644 index 000000000..20d1da3f3 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ccbb44.png differ diff --git a/doc/LectureNotes/_build/html/_images/cf222e.png b/doc/LectureNotes/_build/html/_images/cf222e.png new file mode 100644 index 000000000..eba14bfb1 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/cf222e.png differ diff --git a/doc/LectureNotes/_build/html/_images/d166a3.png b/doc/LectureNotes/_build/html/_images/d166a3.png new file mode 100644 index 000000000..34af2ff43 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/d166a3.png differ diff --git a/doc/LectureNotes/_build/html/_images/d2a8ff.png b/doc/LectureNotes/_build/html/_images/d2a8ff.png new file mode 100644 index 000000000..d3ba734d9 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/d2a8ff.png differ diff --git a/doc/LectureNotes/_build/html/_images/d4d0ab.png b/doc/LectureNotes/_build/html/_images/d4d0ab.png new file mode 100644 index 000000000..4c7b827a4 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/d4d0ab.png differ diff --git a/doc/LectureNotes/_build/html/_images/d71835.png b/doc/LectureNotes/_build/html/_images/d71835.png new file mode 100644 index 000000000..aee961355 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/d71835.png differ diff --git a/doc/LectureNotes/_build/html/_images/d9dee3.png b/doc/LectureNotes/_build/html/_images/d9dee3.png new file mode 100644 index 000000000..61bac902b Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/d9dee3.png differ diff --git a/doc/LectureNotes/_build/html/_images/dbb7ff.png b/doc/LectureNotes/_build/html/_images/dbb7ff.png new file mode 100644 index 000000000..fe7039bd1 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/dbb7ff.png differ diff --git a/doc/LectureNotes/_build/html/_images/dcc6e0.png b/doc/LectureNotes/_build/html/_images/dcc6e0.png new file mode 100644 index 000000000..ad963c944 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/dcc6e0.png differ diff --git a/doc/LectureNotes/_build/html/_images/ec8e2c.png b/doc/LectureNotes/_build/html/_images/ec8e2c.png new file mode 100644 index 000000000..857cbbd5a Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ec8e2c.png differ diff --git a/doc/LectureNotes/_build/html/_images/ee6677.png b/doc/LectureNotes/_build/html/_images/ee6677.png new file mode 100644 index 000000000..a074ed315 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ee6677.png differ diff --git a/doc/LectureNotes/_build/html/_images/f26196.png b/doc/LectureNotes/_build/html/_images/f26196.png new file mode 100644 index 000000000..136cec902 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f26196.png differ diff --git a/doc/LectureNotes/_build/html/_images/f5a394.png b/doc/LectureNotes/_build/html/_images/f5a394.png new file mode 100644 index 000000000..4650b86f2 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f5a394.png differ diff --git a/doc/LectureNotes/_build/html/_images/f5ab35.png b/doc/LectureNotes/_build/html/_images/f5ab35.png new file mode 100644 index 000000000..5df91ee45 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f5ab35.png differ diff --git a/doc/LectureNotes/_build/html/_images/f5f5f5.png b/doc/LectureNotes/_build/html/_images/f5f5f5.png new file mode 100644 index 000000000..6703ca30c Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f5f5f5.png differ diff --git a/doc/LectureNotes/_build/html/_images/f78c6c.png b/doc/LectureNotes/_build/html/_images/f78c6c.png new file mode 100644 index 000000000..5cf8e8bcd Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f78c6c.png differ diff --git a/doc/LectureNotes/_build/html/_images/f8f8f2.png b/doc/LectureNotes/_build/html/_images/f8f8f2.png new file mode 100644 index 000000000..34d0957f3 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/f8f8f2.png differ diff --git a/doc/LectureNotes/_build/html/_images/fad000.png b/doc/LectureNotes/_build/html/_images/fad000.png new file mode 100644 index 000000000..58ac7e8bf Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/fad000.png differ diff --git a/doc/LectureNotes/_build/html/_images/fdac54.png b/doc/LectureNotes/_build/html/_images/fdac54.png new file mode 100644 index 000000000..9f681b21d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/fdac54.png differ diff --git a/doc/LectureNotes/_build/html/_images/fefeff.png b/doc/LectureNotes/_build/html/_images/fefeff.png new file mode 100644 index 000000000..ab6d16c80 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/fefeff.png differ diff --git a/doc/LectureNotes/_build/html/_images/ff7b72.png b/doc/LectureNotes/_build/html/_images/ff7b72.png new file mode 100644 index 000000000..d5a3abbcb Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ff7b72.png differ diff --git a/doc/LectureNotes/_build/html/_images/ff9492.png b/doc/LectureNotes/_build/html/_images/ff9492.png new file mode 100644 index 000000000..5368ed567 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ff9492.png differ diff --git a/doc/LectureNotes/_build/html/_images/ffa07a.png b/doc/LectureNotes/_build/html/_images/ffa07a.png new file mode 100644 index 000000000..c771ccf9d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ffa07a.png differ diff --git a/doc/LectureNotes/_build/html/_images/ffa657.png b/doc/LectureNotes/_build/html/_images/ffa657.png new file mode 100644 index 000000000..ea0e84e3d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ffa657.png differ diff --git a/doc/LectureNotes/_build/html/_images/ffb757.png b/doc/LectureNotes/_build/html/_images/ffb757.png new file mode 100644 index 000000000..cb52b6c2a Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ffb757.png differ diff --git a/doc/LectureNotes/_build/html/_images/ffd700.png b/doc/LectureNotes/_build/html/_images/ffd700.png new file mode 100644 index 000000000..86dca1571 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ffd700.png differ diff --git a/doc/LectureNotes/_build/html/_images/ffd900.png b/doc/LectureNotes/_build/html/_images/ffd900.png new file mode 100644 index 000000000..786918447 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/ffd900.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-dark-colorblind.png b/doc/LectureNotes/_build/html/_images/github-dark-colorblind.png new file mode 100644 index 000000000..96cf5944d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-dark-colorblind.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-dark-high-contrast.png b/doc/LectureNotes/_build/html/_images/github-dark-high-contrast.png new file mode 100644 index 000000000..f73c3480a Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-dark-high-contrast.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-dark.png b/doc/LectureNotes/_build/html/_images/github-dark.png new file mode 100644 index 000000000..50bac6465 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-dark.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-light-colorblind.png b/doc/LectureNotes/_build/html/_images/github-light-colorblind.png new file mode 100644 index 000000000..d20cedcaf Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-light-colorblind.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-light-high-contrast.png b/doc/LectureNotes/_build/html/_images/github-light-high-contrast.png new file mode 100644 index 000000000..9a2bd4dbe Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-light-high-contrast.png differ diff --git a/doc/LectureNotes/_build/html/_images/github-light.png b/doc/LectureNotes/_build/html/_images/github-light.png new file mode 100644 index 000000000..de457f2ba Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/github-light.png differ diff --git a/doc/LectureNotes/_build/html/_images/gotthard-dark.png b/doc/LectureNotes/_build/html/_images/gotthard-dark.png new file mode 100644 index 000000000..4976ac1d6 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/gotthard-dark.png differ diff --git a/doc/LectureNotes/_build/html/_images/gotthard-light.png b/doc/LectureNotes/_build/html/_images/gotthard-light.png new file mode 100644 index 000000000..b9c67150d Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/gotthard-light.png differ diff --git a/doc/LectureNotes/_build/html/_images/greative.png b/doc/LectureNotes/_build/html/_images/greative.png new file mode 100644 index 000000000..935a4b6cd Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/greative.png differ diff --git a/doc/LectureNotes/_build/html/_images/pitaya-smoothie.png b/doc/LectureNotes/_build/html/_images/pitaya-smoothie.png new file mode 100644 index 000000000..ce1f7ba74 Binary files /dev/null and b/doc/LectureNotes/_build/html/_images/pitaya-smoothie.png differ diff --git a/doc/LectureNotes/_build/html/_sources/exercisesweek38.ipynb b/doc/LectureNotes/_build/html/_sources/exercisesweek38.ipynb index 065cbdf95..60cc93b8e 100644 --- a/doc/LectureNotes/_build/html/_sources/exercisesweek38.ipynb +++ b/doc/LectureNotes/_build/html/_sources/exercisesweek38.ipynb @@ -6,9 +6,10 @@ "metadata": {}, "source": [ "# Exercises week 38\n", + "\n", "## September 15-19\n", "\n", - "## Resampling and the Bias-Variance Trade-off" + "## Resampling and the Bias-Variance Trade-off\n" ] }, { @@ -16,12 +17,20 @@ "id": "e9f27b0e", "metadata": {}, "source": [ - "## Learning goals\n", + "### Learning goals\n", "\n", "After completing these exercises, you will know how to\n", + "\n", "- Derive expectation and variances values related to linear regression\n", "- Compute expectation and variances values related to linear regression\n", - "- Compute and evaluate the trade-off between bias and variance of a model" + "- Compute and evaluate the trade-off between bias and variance of a model\n", + "\n", + "### Deliverables\n", + "\n", + "Complete the following exercises while working in a jupyter notebook. Then, in canvas, include\n", + "\n", + "- The jupyter notebook with the exercises completed\n", + "- An exported PDF of the notebook (https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_export-your-jupyter-notebook)\n" ] }, { @@ -29,11 +38,17 @@ "id": "984af8e3", "metadata": {}, "source": [ - "This week deals with various mean values and variances in linear regression methods (here it may be useful to look up chapter 3, equation (3.8) of [Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer](https://www.springer.com/gp/book/9780387848570)). The exercises are also a part of project 1 and can be reused in the theory part of the project.\n", + "## Use the books!\n", + "\n", + "This week deals with various mean values and variances in linear regression methods (here it may be useful to look up chapter 3, equation (3.8) of [Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer](https://www.springer.com/gp/book/9780387848570)).\n", "\n", "For more discussions on Ridge regression and calculation of expectation values, [Wessel van Wieringen's](https://arxiv.org/abs/1509.09169) article is highly recommended.\n", "\n", - "We assume that there exists a continuous function $f(\\boldsymbol{x})$ and a normal distributed error $\\boldsymbol{\\varepsilon}\\sim N(0, \\sigma^2)$ which describes our data" + "The exercises this week are also a part of project 1 and can be reused in the theory part of the project.\n", + "\n", + "### Definitions\n", + "\n", + "We assume that there exists a continuous function $f(\\boldsymbol{x})$ and a normal distributed error $\\boldsymbol{\\varepsilon}\\sim N(0, \\sigma^2)$ which describes our data\n" ] }, { @@ -43,7 +58,7 @@ "source": [ "$$\n", "\\boldsymbol{y} = f(\\boldsymbol{x})+\\boldsymbol{\\varepsilon}\n", - "$$" + "$$\n" ] }, { @@ -55,7 +70,7 @@ } }, "source": [ - "We further assume that this continous function can be modeled with a linear model $\\mathbf{\\tilde{y}}$ of some features $\\mathbf{X}$." + "We further assume that this continous function can be modeled with a linear model $\\mathbf{\\tilde{y}}$ of some features $\\mathbf{X}$.\n" ] }, { @@ -65,7 +80,7 @@ "source": [ "$$\n", "\\boldsymbol{y} = \\boldsymbol{\\tilde{y}} + \\boldsymbol{\\varepsilon} = \\boldsymbol{X}\\boldsymbol{\\beta} +\\boldsymbol{\\varepsilon}\n", - "$$" + "$$\n" ] }, { @@ -73,7 +88,7 @@ "id": "f4fca21b", "metadata": {}, "source": [ - "We therefore get that our data $\\boldsymbol{y}$ has an expectation value $\\boldsymbol{X}\\boldsymbol{\\beta}$ and variance $\\sigma^2$, that is $\\boldsymbol{y}$ follows a normal distribution with mean value $\\boldsymbol{X}\\boldsymbol{\\beta}$ and variance $\\sigma^2$." + "We therefore get that our data $\\boldsymbol{y}$ has an expectation value $\\boldsymbol{X}\\boldsymbol{\\beta}$ and variance $\\sigma^2$, that is $\\boldsymbol{y}$ follows a normal distribution with mean value $\\boldsymbol{X}\\boldsymbol{\\beta}$ and variance $\\sigma^2$.\n" ] }, { @@ -81,7 +96,7 @@ "id": "5de0c7e6", "metadata": {}, "source": [ - "## Exercise 1: Expectation values for ordinary least squares expressions" + "## Exercise 1: Expectation values for ordinary least squares expressions\n" ] }, { @@ -89,7 +104,7 @@ "id": "d878c699", "metadata": {}, "source": [ - "**a)** With the expressions for the optimal parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$ show that" + "**a)** With the expressions for the optimal parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$ show that\n" ] }, { @@ -99,7 +114,7 @@ "source": [ "$$\n", "\\mathbb{E}(\\boldsymbol{\\hat{\\beta}_{OLS}}) = \\boldsymbol{\\beta}.\n", - "$$" + "$$\n" ] }, { @@ -107,7 +122,7 @@ "id": "46e93394", "metadata": {}, "source": [ - "**b)** Show that the variance of $\\boldsymbol{\\hat{\\beta}_{OLS}}$ is" + "**b)** Show that the variance of $\\boldsymbol{\\hat{\\beta}_{OLS}}$ is\n" ] }, { @@ -117,7 +132,7 @@ "source": [ "$$\n", "\\mathbf{Var}(\\boldsymbol{\\hat{\\beta}_{OLS}}) = \\sigma^2 \\, (\\mathbf{X}^{T} \\mathbf{X})^{-1}.\n", - "$$" + "$$\n" ] }, { @@ -125,8 +140,8 @@ "id": "d2143684", "metadata": {}, "source": [ - "We can use the last expression when we define a [confidence interval](https://en.wikipedia.org/wiki/Confidence_interval) for the parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$. \n", - "A given parameter ${\\boldsymbol{\\hat{\\beta}_{OLS}}}_j$ is given by the diagonal matrix element of the above matrix." + "We can use the last expression when we define a [confidence interval](https://en.wikipedia.org/wiki/Confidence_interval) for the parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$.\n", + "A given parameter ${\\boldsymbol{\\hat{\\beta}_{OLS}}}_j$ is given by the diagonal matrix element of the above matrix.\n" ] }, { @@ -134,7 +149,7 @@ "id": "f5c2dc22", "metadata": {}, "source": [ - "## Exercise 2: Expectation values for Ridge regression" + "## Exercise 2: Expectation values for Ridge regression\n" ] }, { @@ -142,7 +157,7 @@ "id": "3893e3e7", "metadata": {}, "source": [ - "**a)** With the expressions for the optimal parameters $\\boldsymbol{\\hat{\\beta}_{Ridge}}$ show that" + "**a)** With the expressions for the optimal parameters $\\boldsymbol{\\hat{\\beta}_{Ridge}}$ show that\n" ] }, { @@ -152,7 +167,7 @@ "source": [ "$$\n", "\\mathbb{E} \\big[ \\hat{\\boldsymbol{\\beta}}^{\\mathrm{Ridge}} \\big]=(\\mathbf{X}^{T} \\mathbf{X} + \\lambda \\mathbf{I}_{pp})^{-1} (\\mathbf{X}^{\\top} \\mathbf{X})\\boldsymbol{\\beta}\n", - "$$" + "$$\n" ] }, { @@ -160,7 +175,7 @@ "id": "028209a1", "metadata": {}, "source": [ - "We see that $\\mathbb{E} \\big[ \\hat{\\boldsymbol{\\beta}}^{\\mathrm{Ridge}} \\big] \\not= \\mathbb{E} \\big[\\hat{\\boldsymbol{\\beta}}^{\\mathrm{OLS}}\\big ]$ for any $\\lambda > 0$." + "We see that $\\mathbb{E} \\big[ \\hat{\\boldsymbol{\\beta}}^{\\mathrm{Ridge}} \\big] \\not= \\mathbb{E} \\big[\\hat{\\boldsymbol{\\beta}}^{\\mathrm{OLS}}\\big ]$ for any $\\lambda > 0$.\n" ] }, { @@ -168,7 +183,7 @@ "id": "65f6f914", "metadata": {}, "source": [ - "**b)** Why do we say that Ridge regression gives a biased estimate? Is this a problem?" + "**b)** Why do we say that Ridge regression gives a biased estimate? Is this a problem?\n" ] }, { @@ -176,7 +191,7 @@ "id": "b4e721fc", "metadata": {}, "source": [ - "**c)** Show that the variance is" + "**c)** Show that the variance is\n" ] }, { @@ -186,7 +201,7 @@ "source": [ "$$\n", "\\mathbf{Var}[\\hat{\\boldsymbol{\\beta}}^{\\mathrm{Ridge}}]=\\sigma^2[ \\mathbf{X}^{T} \\mathbf{X} + \\lambda \\mathbf{I} ]^{-1} \\mathbf{X}^{T}\\mathbf{X} \\{ [ \\mathbf{X}^{\\top} \\mathbf{X} + \\lambda \\mathbf{I} ]^{-1}\\}^{T}\n", - "$$" + "$$\n" ] }, { @@ -194,7 +209,7 @@ "id": "6b8e8697", "metadata": {}, "source": [ - "We see that if the parameter $\\lambda$ goes to infinity then the variance of the Ridge parameters $\\boldsymbol{\\beta}$ goes to zero." + "We see that if the parameter $\\lambda$ goes to infinity then the variance of the Ridge parameters $\\boldsymbol{\\beta}$ goes to zero.\n" ] }, { @@ -202,7 +217,7 @@ "id": "74bc300b", "metadata": {}, "source": [ - "## Exercise 3: Deriving the expression for the Bias-Variance Trade-off" + "## Exercise 3: Deriving the expression for the Bias-Variance Trade-off\n" ] }, { @@ -212,7 +227,7 @@ "source": [ "The aim of this exercise is to derive the equations for the bias-variance tradeoff to be used in project 1.\n", "\n", - "The parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$ are found by optimizing the mean squared error via the so-called cost function" + "The parameters $\\boldsymbol{\\hat{\\beta}_{OLS}}$ are found by optimizing the mean squared error via the so-called cost function\n" ] }, { @@ -222,7 +237,7 @@ "source": [ "$$\n", "C(\\boldsymbol{X},\\boldsymbol{\\beta}) =\\frac{1}{n}\\sum_{i=0}^{n-1}(y_i-\\tilde{y}_i)^2=\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]\n", - "$$" + "$$\n" ] }, { @@ -230,9 +245,9 @@ "id": "831db06c", "metadata": {}, "source": [ - "**a)** Show that you can rewrite this in terms of a term which contains the variance of the model itself (the so-called variance term), a\n", + "**a)** Show that you can rewrite this in terms of a term which contains the variance of the model itself (the so-called variance term), a\n", "term which measures the deviation from the true data and the mean value of the model (the bias term) and finally the variance of the noise Note that in order to be able to evaluate the bias them, you will need to approximate the function $f$ with the model ${\\bf y}$.\n", - "show that" + "show that\n" ] }, { @@ -242,7 +257,7 @@ "source": [ "$$\n", "\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]=\\mathrm{Bias}[\\tilde{y}]+\\mathrm{var}[\\tilde{y}]+\\sigma^2,\n", - "$$" + "$$\n" ] }, { @@ -250,7 +265,7 @@ "id": "8cb50416", "metadata": {}, "source": [ - "with" + "with\n" ] }, { @@ -260,7 +275,7 @@ "source": [ "$$\n", "\\mathrm{Bias}[\\tilde{y}]=\\mathbb{E}\\left[\\left(\\boldsymbol{y}-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right]\\right)^2\\right],\n", - "$$" + "$$\n" ] }, { @@ -268,7 +283,7 @@ "id": "eca5554a", "metadata": {}, "source": [ - "and" + "and\n" ] }, { @@ -278,7 +293,7 @@ "source": [ "$$\n", "\\mathrm{var}[\\tilde{y}]=\\mathbb{E}\\left[\\left(\\tilde{\\boldsymbol{y}}-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right]\\right)^2\\right]=\\frac{1}{n}\\sum_i(\\tilde{y}_i-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right])^2.\n", - "$$" + "$$\n" ] }, { @@ -286,7 +301,7 @@ "id": "70fbfcd7", "metadata": {}, "source": [ - "**b)** Explain what the terms mean and discuss their interpretations." + "**b)** Explain what the terms mean and discuss their interpretations.\n" ] }, { @@ -294,7 +309,7 @@ "id": "b8f8b9d1", "metadata": {}, "source": [ - "## Exercise 4: Computing the Bias and Variance" + "## Exercise 4: Computing the Bias and Variance\n" ] }, { @@ -304,7 +319,7 @@ "source": [ "Before you compute the bias and variance of a real model for different complexities, let's for now assume that you have sampled predictions and targets for a single model complexity using bootstrap resampling.\n", "\n", - "**a)** Using the expression above, compute the mean squared error, bias and variance of the given data. Check that the sum of the bias and variance correctly gives (approximately) the mean squared error." + "**a)** Using the expression above, compute the mean squared error, bias and variance of the given data. Check that the sum of the bias and variance correctly gives (approximately) the mean squared error.\n" ] }, { @@ -334,7 +349,7 @@ "source": [ "**b)** Change the prediction values in some way to increase the bias while decreasing the variance.\n", "\n", - "**c)** Change the prediction values in some way to increase the variance while decreasing the bias." + "**c)** Change the prediction values in some way to increase the variance while decreasing the bias.\n" ] }, { @@ -342,19 +357,21 @@ "id": "8da63362", "metadata": {}, "source": [ - "**d)** Perform a bias-variance analysis of a polynomial OLS model fit to a one-dimensional function by computing and plotting the bias and variances values as a function of the polynomial degree of your model." + "**d)** Perform a bias-variance analysis of a polynomial OLS model fit to a one-dimensional function by computing and plotting the bias and variances values as a function of the polynomial degree of your model.\n" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "id": "dd5855e4", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "from sklearn.preprocessing import PolynomialFeatures # use the fit_transform method of the created object!\n", + "from sklearn.preprocessing import (\n", + " PolynomialFeatures,\n", + ") # use the fit_transform method of the created object!\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.metrics import mean_squared_error\n", "from sklearn.model_selection import train_test_split\n", @@ -372,13 +389,13 @@ "bootstraps = 1000\n", "\n", "x = np.linspace(-3, 3, n)\n", - "y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1)\n", + "y = np.exp(-(x**2)) + 1.5 * np.exp(-((x - 2) ** 2)) + np.random.normal(0, 0.1)\n", "\n", "biases = []\n", "variances = []\n", "mses = []\n", "\n", - "#for p in range(1, 5):\n", + "# for p in range(1, 5):\n", "# predictions = ...\n", "# targets = ...\n", "# for b in range(bootstraps):\n", @@ -386,9 +403,9 @@ "# X = ...\n", "# X_train, X_test, y_train, y_test = ...\n", "#\n", - "# predictions[b, :] = \n", - "# targets[b, :] = \n", - "# \n", + "# predictions[b, :] =\n", + "# targets[b, :] =\n", + "#\n", "# biases.append(...)\n", "# variances.append(...)\n", "# mses.append(...)" @@ -401,7 +418,43 @@ "source": [ "**e)** Discuss the bias-variance trade-off as function of your model complexity (the degree of the polynomial).\n", "\n", - "**f)** Compute and discuss the bias and variance as function of the number of data points (choose a suitable polynomial degree to show something interesiting)." + "**f)** Compute and discuss the bias and variance as function of the number of data points (choose a suitable polynomial degree to show something interesiting).\n" + ] + }, + { + "cell_type": "markdown", + "id": "46250fbc", + "metadata": {}, + "source": [ + "## Exercise 5: Interpretation of scaling and metrics\n" + ] + }, + { + "cell_type": "markdown", + "id": "5af53055", + "metadata": {}, + "source": [ + "In this course, we often ask you to scale data and compute various metrics. Although these practices are \"standard\" in the field, we will require you to demonstrate an understanding of _why_ you need to scale data and use these metrics. Both so that you can make better arguements about your results, and so that you will hopefully make fewer mistakes.\n", + "\n", + "First, a few reminders: In this course you should always scale the columns of the feature matrix, and sometimes scale the target data, when it is worth the effort. By scaling, we mean subtracting the mean and dividing by the standard deviation, though there are many other ways to scale data. When scaling either the feature matrix or the target data, the intercept becomes a bit harder to implement and understand, so take care.\n", + "\n", + "Briefly answer the following:\n", + "\n", + "**a)** Why do we scale data?\n", + "\n", + "**b)** Why does the OLS method give practically equivelent models on scaled and unscaled data?\n", + "\n", + "**c)** Why does the Ridge method **not** give practically equivelent models on scaled and unscaled data? Why do we only consider the model on scaled data correct?\n", + "\n", + "**d)** Why do we say that the Ridge method gives a biased model?\n", + "\n", + "**e)** Is the MSE of the OLS method affected by scaling of the feature matrix? Is it affected by scaling of the target data?\n", + "\n", + "**f)** Read about the R2 score, a metric we will ask you to use a lot later in the course. Is the R2 score of the OLS method affected by scaling of the feature matrix? Is it affected by scaling of the target data?\n", + "\n", + "**g)** Give interpretations of the following R2 scores: 0, 0.5, 1.\n", + "\n", + "**h)** What is an advantage of the R2 score over the MSE?\n" ] } ], diff --git a/doc/LectureNotes/_build/html/_static/pygments.css b/doc/LectureNotes/_build/html/_static/pygments.css index 012e6a00a..d7dd57783 100644 --- a/doc/LectureNotes/_build/html/_static/pygments.css +++ b/doc/LectureNotes/_build/html/_static/pygments.css @@ -6,11 +6,11 @@ html[data-theme="light"] .highlight span.linenos.special { color: #000000; backg html[data-theme="light"] .highlight .hll { background-color: #fae4c2 } html[data-theme="light"] .highlight { background: #fefefe; color: #080808 } html[data-theme="light"] .highlight .c { color: #515151 } /* Comment */ -html[data-theme="light"] .highlight .err { color: #a12236 } /* Error */ -html[data-theme="light"] .highlight .k { color: #6730c5 } /* Keyword */ -html[data-theme="light"] .highlight .l { color: #7f4707 } /* Literal */ +html[data-theme="light"] .highlight .err { color: #A12236 } /* Error */ +html[data-theme="light"] .highlight .k { color: #6730C5 } /* Keyword */ +html[data-theme="light"] .highlight .l { color: #7F4707 } /* Literal */ html[data-theme="light"] .highlight .n { color: #080808 } /* Name */ -html[data-theme="light"] .highlight .o { color: #00622f } /* Operator */ +html[data-theme="light"] .highlight .o { color: #00622F } /* Operator */ html[data-theme="light"] .highlight .p { color: #080808 } /* Punctuation */ html[data-theme="light"] .highlight .ch { color: #515151 } /* Comment.Hashbang */ html[data-theme="light"] .highlight .cm { color: #515151 } /* Comment.Multiline */ @@ -18,135 +18,135 @@ html[data-theme="light"] .highlight .cp { color: #515151 } /* Comment.Preproc */ html[data-theme="light"] .highlight .cpf { color: #515151 } /* Comment.PreprocFile */ html[data-theme="light"] .highlight .c1 { color: #515151 } /* Comment.Single */ html[data-theme="light"] .highlight .cs { color: #515151 } /* Comment.Special */ -html[data-theme="light"] .highlight .gd { color: #005b82 } /* Generic.Deleted */ +html[data-theme="light"] .highlight .gd { color: #005B82 } /* Generic.Deleted */ html[data-theme="light"] .highlight .ge { font-style: italic } /* Generic.Emph */ -html[data-theme="light"] .highlight .gh { color: #005b82 } /* Generic.Heading */ +html[data-theme="light"] .highlight .gh { color: #005B82 } /* Generic.Heading */ html[data-theme="light"] .highlight .gs { font-weight: bold } /* Generic.Strong */ -html[data-theme="light"] .highlight .gu { color: #005b82 } /* Generic.Subheading */ -html[data-theme="light"] .highlight .kc { color: #6730c5 } /* Keyword.Constant */ -html[data-theme="light"] .highlight .kd { color: #6730c5 } /* Keyword.Declaration */ -html[data-theme="light"] .highlight .kn { color: #6730c5 } /* Keyword.Namespace */ -html[data-theme="light"] .highlight .kp { color: #6730c5 } /* Keyword.Pseudo */ -html[data-theme="light"] .highlight .kr { color: #6730c5 } /* Keyword.Reserved */ -html[data-theme="light"] .highlight .kt { color: #7f4707 } /* Keyword.Type */ -html[data-theme="light"] .highlight .ld { color: #7f4707 } /* Literal.Date */ -html[data-theme="light"] .highlight .m { color: #7f4707 } /* Literal.Number */ -html[data-theme="light"] .highlight .s { color: #00622f } /* Literal.String */ +html[data-theme="light"] .highlight .gu { color: #005B82 } /* Generic.Subheading */ +html[data-theme="light"] .highlight .kc { color: #6730C5 } /* Keyword.Constant */ +html[data-theme="light"] .highlight .kd { color: #6730C5 } /* Keyword.Declaration */ +html[data-theme="light"] .highlight .kn { color: #6730C5 } /* Keyword.Namespace */ +html[data-theme="light"] .highlight .kp { color: #6730C5 } /* Keyword.Pseudo */ +html[data-theme="light"] .highlight .kr { color: #6730C5 } /* Keyword.Reserved */ +html[data-theme="light"] .highlight .kt { color: #7F4707 } /* Keyword.Type */ +html[data-theme="light"] .highlight .ld { color: #7F4707 } /* Literal.Date */ +html[data-theme="light"] .highlight .m { color: #7F4707 } /* Literal.Number */ +html[data-theme="light"] .highlight .s { color: #00622F } /* Literal.String */ html[data-theme="light"] .highlight .na { color: #912583 } /* Name.Attribute */ -html[data-theme="light"] .highlight .nb { color: #7f4707 } /* Name.Builtin */ -html[data-theme="light"] .highlight .nc { color: #005b82 } /* Name.Class */ -html[data-theme="light"] .highlight .no { color: #005b82 } /* Name.Constant */ -html[data-theme="light"] .highlight .nd { color: #7f4707 } /* Name.Decorator */ -html[data-theme="light"] .highlight .ni { color: #00622f } /* Name.Entity */ -html[data-theme="light"] .highlight .ne { color: #6730c5 } /* Name.Exception */ -html[data-theme="light"] .highlight .nf { color: #005b82 } /* Name.Function */ -html[data-theme="light"] .highlight .nl { color: #7f4707 } /* Name.Label */ +html[data-theme="light"] .highlight .nb { color: #7F4707 } /* Name.Builtin */ +html[data-theme="light"] .highlight .nc { color: #005B82 } /* Name.Class */ +html[data-theme="light"] .highlight .no { color: #005B82 } /* Name.Constant */ +html[data-theme="light"] .highlight .nd { color: #7F4707 } /* Name.Decorator */ +html[data-theme="light"] .highlight .ni { color: #00622F } /* Name.Entity */ +html[data-theme="light"] .highlight .ne { color: #6730C5 } /* Name.Exception */ +html[data-theme="light"] .highlight .nf { color: #005B82 } /* Name.Function */ +html[data-theme="light"] .highlight .nl { color: #7F4707 } /* Name.Label */ html[data-theme="light"] .highlight .nn { color: #080808 } /* Name.Namespace */ html[data-theme="light"] .highlight .nx { color: #080808 } /* Name.Other */ -html[data-theme="light"] .highlight .py { color: #005b82 } /* Name.Property */ -html[data-theme="light"] .highlight .nt { color: #005b82 } /* Name.Tag */ -html[data-theme="light"] .highlight .nv { color: #a12236 } /* Name.Variable */ -html[data-theme="light"] .highlight .ow { color: #6730c5 } /* Operator.Word */ +html[data-theme="light"] .highlight .py { color: #005B82 } /* Name.Property */ +html[data-theme="light"] .highlight .nt { color: #005B82 } /* Name.Tag */ +html[data-theme="light"] .highlight .nv { color: #A12236 } /* Name.Variable */ +html[data-theme="light"] .highlight .ow { color: #6730C5 } /* Operator.Word */ html[data-theme="light"] .highlight .pm { color: #080808 } /* Punctuation.Marker */ html[data-theme="light"] .highlight .w { color: #080808 } /* Text.Whitespace */ -html[data-theme="light"] .highlight .mb { color: #7f4707 } /* Literal.Number.Bin */ -html[data-theme="light"] .highlight .mf { color: #7f4707 } /* Literal.Number.Float */ -html[data-theme="light"] .highlight .mh { color: #7f4707 } /* Literal.Number.Hex */ -html[data-theme="light"] .highlight .mi { color: #7f4707 } /* Literal.Number.Integer */ -html[data-theme="light"] .highlight .mo { color: #7f4707 } /* Literal.Number.Oct */ -html[data-theme="light"] .highlight .sa { color: #00622f } /* Literal.String.Affix */ -html[data-theme="light"] .highlight .sb { color: #00622f } /* Literal.String.Backtick */ -html[data-theme="light"] .highlight .sc { color: #00622f } /* Literal.String.Char */ -html[data-theme="light"] .highlight .dl { color: #00622f } /* Literal.String.Delimiter */ -html[data-theme="light"] .highlight .sd { color: #00622f } /* Literal.String.Doc */ -html[data-theme="light"] .highlight .s2 { color: #00622f } /* Literal.String.Double */ -html[data-theme="light"] .highlight .se { color: #00622f } /* Literal.String.Escape */ -html[data-theme="light"] .highlight .sh { color: #00622f } /* Literal.String.Heredoc */ -html[data-theme="light"] .highlight .si { color: #00622f } /* Literal.String.Interpol */ -html[data-theme="light"] .highlight .sx { color: #00622f } /* Literal.String.Other */ -html[data-theme="light"] .highlight .sr { color: #a12236 } /* Literal.String.Regex */ -html[data-theme="light"] .highlight .s1 { color: #00622f } /* Literal.String.Single */ -html[data-theme="light"] .highlight .ss { color: #005b82 } /* Literal.String.Symbol */ -html[data-theme="light"] .highlight .bp { color: #7f4707 } /* Name.Builtin.Pseudo */ -html[data-theme="light"] .highlight .fm { color: #005b82 } /* Name.Function.Magic */ -html[data-theme="light"] .highlight .vc { color: #a12236 } /* Name.Variable.Class */ -html[data-theme="light"] .highlight .vg { color: #a12236 } /* Name.Variable.Global */ -html[data-theme="light"] .highlight .vi { color: #a12236 } /* Name.Variable.Instance */ -html[data-theme="light"] .highlight .vm { color: #7f4707 } /* Name.Variable.Magic */ -html[data-theme="light"] .highlight .il { color: #7f4707 } /* Literal.Number.Integer.Long */ +html[data-theme="light"] .highlight .mb { color: #7F4707 } /* Literal.Number.Bin */ +html[data-theme="light"] .highlight .mf { color: #7F4707 } /* Literal.Number.Float */ +html[data-theme="light"] .highlight .mh { color: #7F4707 } /* Literal.Number.Hex */ +html[data-theme="light"] .highlight .mi { color: #7F4707 } /* Literal.Number.Integer */ +html[data-theme="light"] .highlight .mo { color: #7F4707 } /* Literal.Number.Oct */ +html[data-theme="light"] .highlight .sa { color: #00622F } /* Literal.String.Affix */ +html[data-theme="light"] .highlight .sb { color: #00622F } /* Literal.String.Backtick */ +html[data-theme="light"] .highlight .sc { color: #00622F } /* Literal.String.Char */ +html[data-theme="light"] .highlight .dl { color: #00622F } /* Literal.String.Delimiter */ +html[data-theme="light"] .highlight .sd { color: #00622F } /* Literal.String.Doc */ +html[data-theme="light"] .highlight .s2 { color: #00622F } /* Literal.String.Double */ +html[data-theme="light"] .highlight .se { color: #00622F } /* Literal.String.Escape */ +html[data-theme="light"] .highlight .sh { color: #00622F } /* Literal.String.Heredoc */ +html[data-theme="light"] .highlight .si { color: #00622F } /* Literal.String.Interpol */ +html[data-theme="light"] .highlight .sx { color: #00622F } /* Literal.String.Other */ +html[data-theme="light"] .highlight .sr { color: #A12236 } /* Literal.String.Regex */ +html[data-theme="light"] .highlight .s1 { color: #00622F } /* Literal.String.Single */ +html[data-theme="light"] .highlight .ss { color: #005B82 } /* Literal.String.Symbol */ +html[data-theme="light"] .highlight .bp { color: #7F4707 } /* Name.Builtin.Pseudo */ +html[data-theme="light"] .highlight .fm { color: #005B82 } /* Name.Function.Magic */ +html[data-theme="light"] .highlight .vc { color: #A12236 } /* Name.Variable.Class */ +html[data-theme="light"] .highlight .vg { color: #A12236 } /* Name.Variable.Global */ +html[data-theme="light"] .highlight .vi { color: #A12236 } /* Name.Variable.Instance */ +html[data-theme="light"] .highlight .vm { color: #7F4707 } /* Name.Variable.Magic */ +html[data-theme="light"] .highlight .il { color: #7F4707 } /* Literal.Number.Integer.Long */ html[data-theme="dark"] .highlight pre { line-height: 125%; } html[data-theme="dark"] .highlight td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } html[data-theme="dark"] .highlight span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } html[data-theme="dark"] .highlight td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } html[data-theme="dark"] .highlight span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } html[data-theme="dark"] .highlight .hll { background-color: #ffd9002e } -html[data-theme="dark"] .highlight { background: #2b2b2b; color: #f8f8f2 } -html[data-theme="dark"] .highlight .c { color: #ffd900 } /* Comment */ -html[data-theme="dark"] .highlight .err { color: #ffa07a } /* Error */ -html[data-theme="dark"] .highlight .k { color: #dcc6e0 } /* Keyword */ -html[data-theme="dark"] .highlight .l { color: #ffd900 } /* Literal */ -html[data-theme="dark"] .highlight .n { color: #f8f8f2 } /* Name */ -html[data-theme="dark"] .highlight .o { color: #abe338 } /* Operator */ -html[data-theme="dark"] .highlight .p { color: #f8f8f2 } /* Punctuation */ -html[data-theme="dark"] .highlight .ch { color: #ffd900 } /* Comment.Hashbang */ -html[data-theme="dark"] .highlight .cm { color: #ffd900 } /* Comment.Multiline */ -html[data-theme="dark"] .highlight .cp { color: #ffd900 } /* Comment.Preproc */ -html[data-theme="dark"] .highlight .cpf { color: #ffd900 } /* Comment.PreprocFile */ -html[data-theme="dark"] .highlight .c1 { color: #ffd900 } /* Comment.Single */ -html[data-theme="dark"] .highlight .cs { color: #ffd900 } /* Comment.Special */ -html[data-theme="dark"] .highlight .gd { color: #00e0e0 } /* Generic.Deleted */ +html[data-theme="dark"] .highlight { background: #2b2b2b; color: #F8F8F2 } +html[data-theme="dark"] .highlight .c { color: #FFD900 } /* Comment */ +html[data-theme="dark"] .highlight .err { color: #FFA07A } /* Error */ +html[data-theme="dark"] .highlight .k { color: #DCC6E0 } /* Keyword */ +html[data-theme="dark"] .highlight .l { color: #FFD900 } /* Literal */ +html[data-theme="dark"] .highlight .n { color: #F8F8F2 } /* Name */ +html[data-theme="dark"] .highlight .o { color: #ABE338 } /* Operator */ +html[data-theme="dark"] .highlight .p { color: #F8F8F2 } /* Punctuation */ +html[data-theme="dark"] .highlight .ch { color: #FFD900 } /* Comment.Hashbang */ +html[data-theme="dark"] .highlight .cm { color: #FFD900 } /* Comment.Multiline */ +html[data-theme="dark"] .highlight .cp { color: #FFD900 } /* Comment.Preproc */ +html[data-theme="dark"] .highlight .cpf { color: #FFD900 } /* Comment.PreprocFile */ +html[data-theme="dark"] .highlight .c1 { color: #FFD900 } /* Comment.Single */ +html[data-theme="dark"] .highlight .cs { color: #FFD900 } /* Comment.Special */ +html[data-theme="dark"] .highlight .gd { color: #00E0E0 } /* Generic.Deleted */ html[data-theme="dark"] .highlight .ge { font-style: italic } /* Generic.Emph */ -html[data-theme="dark"] .highlight .gh { color: #00e0e0 } /* Generic.Heading */ +html[data-theme="dark"] .highlight .gh { color: #00E0E0 } /* Generic.Heading */ html[data-theme="dark"] .highlight .gs { font-weight: bold } /* Generic.Strong */ -html[data-theme="dark"] .highlight .gu { color: #00e0e0 } /* Generic.Subheading */ -html[data-theme="dark"] .highlight .kc { color: #dcc6e0 } /* Keyword.Constant */ -html[data-theme="dark"] .highlight .kd { color: #dcc6e0 } /* Keyword.Declaration */ -html[data-theme="dark"] .highlight .kn { color: #dcc6e0 } /* Keyword.Namespace */ -html[data-theme="dark"] .highlight .kp { color: #dcc6e0 } /* Keyword.Pseudo */ -html[data-theme="dark"] .highlight .kr { color: #dcc6e0 } /* Keyword.Reserved */ -html[data-theme="dark"] .highlight .kt { color: #ffd900 } /* Keyword.Type */ -html[data-theme="dark"] .highlight .ld { color: #ffd900 } /* Literal.Date */ -html[data-theme="dark"] .highlight .m { color: #ffd900 } /* Literal.Number */ -html[data-theme="dark"] .highlight .s { color: #abe338 } /* Literal.String */ -html[data-theme="dark"] .highlight .na { color: #ffd900 } /* Name.Attribute */ -html[data-theme="dark"] .highlight .nb { color: #ffd900 } /* Name.Builtin */ -html[data-theme="dark"] .highlight .nc { color: #00e0e0 } /* Name.Class */ -html[data-theme="dark"] .highlight .no { color: #00e0e0 } /* Name.Constant */ -html[data-theme="dark"] .highlight .nd { color: #ffd900 } /* Name.Decorator */ -html[data-theme="dark"] .highlight .ni { color: #abe338 } /* Name.Entity */ -html[data-theme="dark"] .highlight .ne { color: #dcc6e0 } /* Name.Exception */ -html[data-theme="dark"] .highlight .nf { color: #00e0e0 } /* Name.Function */ -html[data-theme="dark"] .highlight .nl { color: #ffd900 } /* Name.Label */ -html[data-theme="dark"] .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ -html[data-theme="dark"] .highlight .nx { color: #f8f8f2 } /* Name.Other */ -html[data-theme="dark"] .highlight .py { color: #00e0e0 } /* Name.Property */ -html[data-theme="dark"] .highlight .nt { color: #00e0e0 } /* Name.Tag */ -html[data-theme="dark"] .highlight .nv { color: #ffa07a } /* Name.Variable */ -html[data-theme="dark"] .highlight .ow { color: #dcc6e0 } /* Operator.Word */ -html[data-theme="dark"] .highlight .pm { color: #f8f8f2 } /* Punctuation.Marker */ -html[data-theme="dark"] .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ -html[data-theme="dark"] .highlight .mb { color: #ffd900 } /* Literal.Number.Bin */ -html[data-theme="dark"] .highlight .mf { color: #ffd900 } /* Literal.Number.Float */ -html[data-theme="dark"] .highlight .mh { color: #ffd900 } /* Literal.Number.Hex */ -html[data-theme="dark"] .highlight .mi { color: #ffd900 } /* Literal.Number.Integer */ -html[data-theme="dark"] .highlight .mo { color: #ffd900 } /* Literal.Number.Oct */ -html[data-theme="dark"] .highlight .sa { color: #abe338 } /* Literal.String.Affix */ -html[data-theme="dark"] .highlight .sb { color: #abe338 } /* Literal.String.Backtick */ -html[data-theme="dark"] .highlight .sc { color: #abe338 } /* Literal.String.Char */ -html[data-theme="dark"] .highlight .dl { color: #abe338 } /* Literal.String.Delimiter */ -html[data-theme="dark"] .highlight .sd { color: #abe338 } /* Literal.String.Doc */ -html[data-theme="dark"] .highlight .s2 { color: #abe338 } /* Literal.String.Double */ -html[data-theme="dark"] .highlight .se { color: #abe338 } /* Literal.String.Escape */ -html[data-theme="dark"] .highlight .sh { color: #abe338 } /* Literal.String.Heredoc */ -html[data-theme="dark"] .highlight .si { color: #abe338 } /* Literal.String.Interpol */ -html[data-theme="dark"] .highlight .sx { color: #abe338 } /* Literal.String.Other */ -html[data-theme="dark"] .highlight .sr { color: #ffa07a } /* Literal.String.Regex */ -html[data-theme="dark"] .highlight .s1 { color: #abe338 } /* Literal.String.Single */ -html[data-theme="dark"] .highlight .ss { color: #00e0e0 } /* Literal.String.Symbol */ -html[data-theme="dark"] .highlight .bp { color: #ffd900 } /* Name.Builtin.Pseudo */ -html[data-theme="dark"] .highlight .fm { color: #00e0e0 } /* Name.Function.Magic */ -html[data-theme="dark"] .highlight .vc { color: #ffa07a } /* Name.Variable.Class */ -html[data-theme="dark"] .highlight .vg { color: #ffa07a } /* Name.Variable.Global */ -html[data-theme="dark"] .highlight .vi { color: #ffa07a } /* Name.Variable.Instance */ -html[data-theme="dark"] .highlight .vm { color: #ffd900 } /* Name.Variable.Magic */ -html[data-theme="dark"] .highlight .il { color: #ffd900 } /* Literal.Number.Integer.Long */ \ No newline at end of file +html[data-theme="dark"] .highlight .gu { color: #00E0E0 } /* Generic.Subheading */ +html[data-theme="dark"] .highlight .kc { color: #DCC6E0 } /* Keyword.Constant */ +html[data-theme="dark"] .highlight .kd { color: #DCC6E0 } /* Keyword.Declaration */ +html[data-theme="dark"] .highlight .kn { color: #DCC6E0 } /* Keyword.Namespace */ +html[data-theme="dark"] .highlight .kp { color: #DCC6E0 } /* Keyword.Pseudo */ +html[data-theme="dark"] .highlight .kr { color: #DCC6E0 } /* Keyword.Reserved */ +html[data-theme="dark"] .highlight .kt { color: #FFD900 } /* Keyword.Type */ +html[data-theme="dark"] .highlight .ld { color: #FFD900 } /* Literal.Date */ +html[data-theme="dark"] .highlight .m { color: #FFD900 } /* Literal.Number */ +html[data-theme="dark"] .highlight .s { color: #ABE338 } /* Literal.String */ +html[data-theme="dark"] .highlight .na { color: #FFD900 } /* Name.Attribute */ +html[data-theme="dark"] .highlight .nb { color: #FFD900 } /* Name.Builtin */ +html[data-theme="dark"] .highlight .nc { color: #00E0E0 } /* Name.Class */ +html[data-theme="dark"] .highlight .no { color: #00E0E0 } /* Name.Constant */ +html[data-theme="dark"] .highlight .nd { color: #FFD900 } /* Name.Decorator */ +html[data-theme="dark"] .highlight .ni { color: #ABE338 } /* Name.Entity */ +html[data-theme="dark"] .highlight .ne { color: #DCC6E0 } /* Name.Exception */ +html[data-theme="dark"] .highlight .nf { color: #00E0E0 } /* Name.Function */ +html[data-theme="dark"] .highlight .nl { color: #FFD900 } /* Name.Label */ +html[data-theme="dark"] .highlight .nn { color: #F8F8F2 } /* Name.Namespace */ +html[data-theme="dark"] .highlight .nx { color: #F8F8F2 } /* Name.Other */ +html[data-theme="dark"] .highlight .py { color: #00E0E0 } /* Name.Property */ +html[data-theme="dark"] .highlight .nt { color: #00E0E0 } /* Name.Tag */ +html[data-theme="dark"] .highlight .nv { color: #FFA07A } /* Name.Variable */ +html[data-theme="dark"] .highlight .ow { color: #DCC6E0 } /* Operator.Word */ +html[data-theme="dark"] .highlight .pm { color: #F8F8F2 } /* Punctuation.Marker */ +html[data-theme="dark"] .highlight .w { color: #F8F8F2 } /* Text.Whitespace */ +html[data-theme="dark"] .highlight .mb { color: #FFD900 } /* Literal.Number.Bin */ +html[data-theme="dark"] .highlight .mf { color: #FFD900 } /* Literal.Number.Float */ +html[data-theme="dark"] .highlight .mh { color: #FFD900 } /* Literal.Number.Hex */ +html[data-theme="dark"] .highlight .mi { color: #FFD900 } /* Literal.Number.Integer */ +html[data-theme="dark"] .highlight .mo { color: #FFD900 } /* Literal.Number.Oct */ +html[data-theme="dark"] .highlight .sa { color: #ABE338 } /* Literal.String.Affix */ +html[data-theme="dark"] .highlight .sb { color: #ABE338 } /* Literal.String.Backtick */ +html[data-theme="dark"] .highlight .sc { color: #ABE338 } /* Literal.String.Char */ +html[data-theme="dark"] .highlight .dl { color: #ABE338 } /* Literal.String.Delimiter */ +html[data-theme="dark"] .highlight .sd { color: #ABE338 } /* Literal.String.Doc */ +html[data-theme="dark"] .highlight .s2 { color: #ABE338 } /* Literal.String.Double */ +html[data-theme="dark"] .highlight .se { color: #ABE338 } /* Literal.String.Escape */ +html[data-theme="dark"] .highlight .sh { color: #ABE338 } /* Literal.String.Heredoc */ +html[data-theme="dark"] .highlight .si { color: #ABE338 } /* Literal.String.Interpol */ +html[data-theme="dark"] .highlight .sx { color: #ABE338 } /* Literal.String.Other */ +html[data-theme="dark"] .highlight .sr { color: #FFA07A } /* Literal.String.Regex */ +html[data-theme="dark"] .highlight .s1 { color: #ABE338 } /* Literal.String.Single */ +html[data-theme="dark"] .highlight .ss { color: #00E0E0 } /* Literal.String.Symbol */ +html[data-theme="dark"] .highlight .bp { color: #FFD900 } /* Name.Builtin.Pseudo */ +html[data-theme="dark"] .highlight .fm { color: #00E0E0 } /* Name.Function.Magic */ +html[data-theme="dark"] .highlight .vc { color: #FFA07A } /* Name.Variable.Class */ +html[data-theme="dark"] .highlight .vg { color: #FFA07A } /* Name.Variable.Global */ +html[data-theme="dark"] .highlight .vi { color: #FFA07A } /* Name.Variable.Instance */ +html[data-theme="dark"] .highlight .vm { color: #FFD900 } /* Name.Variable.Magic */ +html[data-theme="dark"] .highlight .il { color: #FFD900 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/doc/LectureNotes/_build/html/chapter1.html b/doc/LectureNotes/_build/html/chapter1.html index 8fca775a2..ade1d03f6 100644 --- a/doc/LectureNotes/_build/html/chapter1.html +++ b/doc/LectureNotes/_build/html/chapter1.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter10.html b/doc/LectureNotes/_build/html/chapter10.html index 6ec417b1f..288d09ee9 100644 --- a/doc/LectureNotes/_build/html/chapter10.html +++ b/doc/LectureNotes/_build/html/chapter10.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter11.html b/doc/LectureNotes/_build/html/chapter11.html index 88738e241..ae7f7eb73 100644 --- a/doc/LectureNotes/_build/html/chapter11.html +++ b/doc/LectureNotes/_build/html/chapter11.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter12.html b/doc/LectureNotes/_build/html/chapter12.html index d39624f88..8d18565ef 100644 --- a/doc/LectureNotes/_build/html/chapter12.html +++ b/doc/LectureNotes/_build/html/chapter12.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter13.html b/doc/LectureNotes/_build/html/chapter13.html index e5581a940..55b2f892f 100644 --- a/doc/LectureNotes/_build/html/chapter13.html +++ b/doc/LectureNotes/_build/html/chapter13.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter2.html b/doc/LectureNotes/_build/html/chapter2.html index 5e1e5205e..bd3b80769 100644 --- a/doc/LectureNotes/_build/html/chapter2.html +++ b/doc/LectureNotes/_build/html/chapter2.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter3.html b/doc/LectureNotes/_build/html/chapter3.html index 0ad5ef3cd..6e0056b22 100644 --- a/doc/LectureNotes/_build/html/chapter3.html +++ b/doc/LectureNotes/_build/html/chapter3.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter4.html b/doc/LectureNotes/_build/html/chapter4.html index 08b3066d0..fd9a23a22 100644 --- a/doc/LectureNotes/_build/html/chapter4.html +++ b/doc/LectureNotes/_build/html/chapter4.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter5.html b/doc/LectureNotes/_build/html/chapter5.html index 5bb6c31ed..a5f08388f 100644 --- a/doc/LectureNotes/_build/html/chapter5.html +++ b/doc/LectureNotes/_build/html/chapter5.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter6.html b/doc/LectureNotes/_build/html/chapter6.html index d83af1cd3..105ec70f3 100644 --- a/doc/LectureNotes/_build/html/chapter6.html +++ b/doc/LectureNotes/_build/html/chapter6.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter7.html b/doc/LectureNotes/_build/html/chapter7.html index ee67eddbf..4975f05be 100644 --- a/doc/LectureNotes/_build/html/chapter7.html +++ b/doc/LectureNotes/_build/html/chapter7.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter8.html b/doc/LectureNotes/_build/html/chapter8.html index 6121f71b7..c3607b538 100644 --- a/doc/LectureNotes/_build/html/chapter8.html +++ b/doc/LectureNotes/_build/html/chapter8.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapter9.html b/doc/LectureNotes/_build/html/chapter9.html index 6394a7849..0865f4e0d 100644 --- a/doc/LectureNotes/_build/html/chapter9.html +++ b/doc/LectureNotes/_build/html/chapter9.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/chapteroptimization.html b/doc/LectureNotes/_build/html/chapteroptimization.html index 2afbdae59..9f2680360 100644 --- a/doc/LectureNotes/_build/html/chapteroptimization.html +++ b/doc/LectureNotes/_build/html/chapteroptimization.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/clustering.html b/doc/LectureNotes/_build/html/clustering.html index deef36280..1292b0fc9 100644 --- a/doc/LectureNotes/_build/html/clustering.html +++ b/doc/LectureNotes/_build/html/clustering.html @@ -28,7 +28,7 @@ - + diff --git a/doc/LectureNotes/_build/html/exercisesweek34.html b/doc/LectureNotes/_build/html/exercisesweek34.html index b7a9613b3..6b949390f 100644 --- a/doc/LectureNotes/_build/html/exercisesweek34.html +++ b/doc/LectureNotes/_build/html/exercisesweek34.html @@ -28,7 +28,7 @@ - + @@ -477,11 +477,11 @@ document.write(`
b) Compute the mean square error for the line model and for the second degree polynomial model.
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.preprocessing import PolynomialFeatures # use the fit_transform method of the created object!
-from sklearn.linear_model import LinearRegression
-from sklearn.metrics import mean_squared_error
+import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.preprocessing import PolynomialFeatures # use the fit_transform method of the created object!
+from sklearn.linear_model import LinearRegression
+from sklearn.metrics import mean_squared_error
Hopefully your model fit the data quite well, but to know how well the model actually generalizes to unseen data, which is most often what we care about, we need to split our data into training and testing data.
from sklearn.model_selection import train_test_split
+from sklearn.model_selection import train_test_split
We calculate the optimal intercept by including a feature with the constant value of 1 in our model, which is then multplied by some parameter \(\theta_0\) from the OLS method into the optimal intercept value (which will be \(\theta_0\)). In practice, we include the intercept in our model by adding a column of ones to the start of our feature matrix.
import numpy as np
+import numpy as np
b) Use the expression from 3d) to find the optimal parameters \(\boldsymbol{\hat{\beta}_{OLS}}\) for predicting spending based on these features. Create a function for this operation, as you are going to need to use it a lot.
def OLS_parameters(X, y):
+def OLS_parameters(X, y):
return ...
#beta = OLS_parameters(X, y)
@@ -567,7 +567,7 @@ f_i =\sum_{j=0}^{n-1}a_{ij}x_j,
a) Create a feature matrix \(\boldsymbol{X}\) for the features \(x, x^2, x^3, x^4, x^5\), including an intercept column of ones at the start. Make this into a function, as you will do this a lot over the next weeks.
-def polynomial_features(x, p):
+def polynomial_features(x, p):
n = len(x)
X = np.zeros((n, p + 1))
#X[:, 0] = ...
@@ -591,7 +591,7 @@ f_i =\sum_{j=0}^{n-1}a_{ij}x_j,
c) Like in exercise 4 last week, split your feature matrix and target data into a training split and test split.
-from sklearn.model_selection import train_test_split
+from sklearn.model_selection import train_test_split
#X_train, X_test, y_train, y_test = ...
diff --git a/doc/LectureNotes/_build/html/exercisesweek36.html b/doc/LectureNotes/_build/html/exercisesweek36.html
index 751e6cabd..533249336 100644
--- a/doc/LectureNotes/_build/html/exercisesweek36.html
+++ b/doc/LectureNotes/_build/html/exercisesweek36.html
@@ -28,7 +28,7 @@
-
+
@@ -465,10 +465,10 @@ defining a new cost function to be optimized, that is
Exercise 3 - Scaling data#
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import train_test_split
-from sklearn.preprocessing import StandardScaler
+import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.model_selection import train_test_split
+from sklearn.preprocessing import StandardScaler
@@ -485,7 +485,7 @@ defining a new cost function to be optimized, that is
a) Adapt your function from last week to only include the intercept column if the boolean argument intercept is set to true.
-def polynomial_features(x, p, intercept=False):
+def polynomial_features(x, p, intercept=False):
n = len(x)
X = np.zeros((n, p + 1))
#X[:, 0] = ...
@@ -498,7 +498,7 @@ defining a new cost function to be optimized, that is
-def polynomial_features(x, p, intercept=False):
+def polynomial_features(x, p, intercept=False):
n = len(x)
X = np.zeros((n, p))
X[:, 0] = x[:]
@@ -544,7 +544,7 @@ defining a new cost function to be optimized, that is
a) Implement a function for computing the optimal Ridge parameters using the expression from 2a).
-def Ridge_parameters(X, y):
+def Ridge_parameters(X, y):
# Assumes X is scaled and has no intercept column
return np.linalg.inv(X.T @ X) @ X.T @ y
diff --git a/doc/LectureNotes/_build/html/exercisesweek37.html b/doc/LectureNotes/_build/html/exercisesweek37.html
index 541dd9132..57fd8df99 100644
--- a/doc/LectureNotes/_build/html/exercisesweek37.html
+++ b/doc/LectureNotes/_build/html/exercisesweek37.html
@@ -28,7 +28,7 @@
-
+
diff --git a/doc/LectureNotes/_build/html/exercisesweek38.html b/doc/LectureNotes/_build/html/exercisesweek38.html
index d6dbb2009..4afe575f5 100644
--- a/doc/LectureNotes/_build/html/exercisesweek38.html
+++ b/doc/LectureNotes/_build/html/exercisesweek38.html
@@ -28,7 +28,7 @@
-
+
@@ -385,12 +385,20 @@ document.write(`
@@ -409,17 +417,31 @@ document.write(`
Resampling and the Bias-Variance Trade-off#
-
-Learning goals#
+Learning goals#
After completing these exercises, you will know how to
Derive expectation and variances values related to linear regression
Compute expectation and variances values related to linear regression
Compute and evaluate the trade-off between bias and variance of a model
-This week deals with various mean values and variances in linear regression methods (here it may be useful to look up chapter 3, equation (3.8) of Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer). The exercises are also a part of project 1 and can be reused in the theory part of the project.
+
+
+Deliverables#
+Complete the following exercises while working in a jupyter notebook. Then, in canvas, include
+
+The jupyter notebook with the exercises completed
+An exported PDF of the notebook (https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_export-your-jupyter-notebook)
+
+
+
+
+Use the books!#
+This week deals with various mean values and variances in linear regression methods (here it may be useful to look up chapter 3, equation (3.8) of Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer).
For more discussions on Ridge regression and calculation of expectation values, Wessel van Wieringen’s article is highly recommended.
+The exercises this week are also a part of project 1 and can be reused in the theory part of the project.
+
+Definitions#
We assume that there exists a continuous function \(f(\boldsymbol{x})\) and a normal distributed error \(\boldsymbol{\varepsilon}\sim N(0, \sigma^2)\) which describes our data
\[
@@ -432,6 +454,7 @@ document.write(`
\]
We therefore get that our data \(\boldsymbol{y}\) has an expectation value \(\boldsymbol{X}\boldsymbol{\beta}\) and variance \(\sigma^2\), that is \(\boldsymbol{y}\) follows a normal distribution with mean value \(\boldsymbol{X}\boldsymbol{\beta}\) and variance \(\sigma^2\).
+
Exercise 1: Expectation values for ordinary least squares expressions#
a) With the expressions for the optimal parameters \(\boldsymbol{\hat{\beta}_{OLS}}\) show that
@@ -471,7 +494,7 @@ A given parameter \({\boldsymbol{\hat
\[
C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]
\]
-a) Show that you can rewrite this in terms of a term which contains the variance of the model itself (the so-called variance term), a
+
a) Show that you can rewrite this in terms of a term which contains the variance of the model itself (the so-called variance term), a
term which measures the deviation from the true data and the mean value of the model (the bias term) and finally the variance of the noise Note that in order to be able to evaluate the bias them, you will need to approximate the function \(f\) with the model \({\bf y}\).
show that
@@ -496,7 +519,7 @@ show that
a) Using the expression above, compute the mean squared error, bias and variance of the given data. Check that the sum of the bias and variance correctly gives (approximately) the mean squared error.
-import numpy as np
+import numpy as np
n = 100
bootstraps = 1000
@@ -516,13 +539,15 @@ show that
d) Perform a bias-variance analysis of a polynomial OLS model fit to a one-dimensional function by computing and plotting the bias and variances values as a function of the polynomial degree of your model.
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.preprocessing import PolynomialFeatures # use the fit_transform method of the created object!
-from sklearn.linear_model import LinearRegression
-from sklearn.metrics import mean_squared_error
-from sklearn.model_selection import train_test_split
-from sklearn.utils import resample
+import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.preprocessing import (
+ PolynomialFeatures,
+) # use the fit_transform method of the created object!
+from sklearn.linear_model import LinearRegression
+from sklearn.metrics import mean_squared_error
+from sklearn.model_selection import train_test_split
+from sklearn.utils import resample
@@ -533,13 +558,13 @@ show that
bootstraps = 1000
x = np.linspace(-3, 3, n)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1)
+y = np.exp(-(x**2)) + 1.5 * np.exp(-((x - 2) ** 2)) + np.random.normal(0, 0.1)
biases = []
variances = []
mses = []
-#for p in range(1, 5):
+# for p in range(1, 5):
# predictions = ...
# targets = ...
# for b in range(bootstraps):
@@ -547,9 +572,9 @@ show that
# X = ...
# X_train, X_test, y_train, y_test = ...
#
-# predictions[b, :] =
-# targets[b, :] =
-#
+# predictions[b, :] =
+# targets[b, :] =
+#
# biases.append(...)
# variances.append(...)
# mses.append(...)
@@ -560,6 +585,20 @@ show that
e) Discuss the bias-variance trade-off as function of your model complexity (the degree of the polynomial).
f) Compute and discuss the bias and variance as function of the number of data points (choose a suitable polynomial degree to show something interesiting).
+
+Exercise 5: Interpretation of scaling and metrics#
+In this course, we often ask you to scale data and compute various metrics. Although these practices are “standard” in the field, we will require you to demonstrate an understanding of why you need to scale data and use these metrics. Both so that you can make better arguements about your results, and so that you will hopefully make fewer mistakes.
+First, a few reminders: In this course you should always scale the columns of the feature matrix, and sometimes scale the target data, when it is worth the effort. By scaling, we mean subtracting the mean and dividing by the standard deviation, though there are many other ways to scale data. When scaling either the feature matrix or the target data, the intercept becomes a bit harder to implement and understand, so take care.
+Briefly answer the following:
+a) Why do we scale data?
+b) Why does the OLS method give practically equivelent models on scaled and unscaled data?
+c) Why does the Ridge method not give practically equivelent models on scaled and unscaled data? Why do we only consider the model on scaled data correct?
+d) Why do we say that the Ridge method gives a biased model?
+e) Is the MSE of the OLS method affected by scaling of the feature matrix? Is it affected by scaling of the target data?
+f) Read about the R2 score, a metric we will ask you to use a lot later in the course. Is the R2 score of the OLS method affected by scaling of the feature matrix? Is it affected by scaling of the target data?
+g) Give interpretations of the following R2 scores: 0, 0.5, 1.
+h) What is an advantage of the R2 score over the MSE?
+