Skip to content

Commit 47c5089

Browse files
committed
2 parents 36e1cfb + 87f79fe commit 47c5089

File tree

5 files changed

+854
-0
lines changed

5 files changed

+854
-0
lines changed

source-code/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ to create it. There is some material not covered in the presentation as well.
3030
* [`pandas`](pandas): illustrations of using pandas and seaborn.
3131
* [`regexes`](regexes): illustrations of using regular expressions for validation
3232
and information extraction from textual data.
33+
* [1seaborn`]:(seaborn): illustrations of using Seaborn to create plots.
3334
* [`web-scraping`](web-scraping): illustration of web scraping using beautiful soup
3435
and graph representation using networkx.

source-code/seaborn/Data/data.txt

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
gaussian,poisson,label,x,y,x1,y1,x2,y2,binary,x3,y3
2+
1.35305412622401,6,A,0.0,-4.9241509784457165,1,3.973594636362365,1.349306480932574,5.67456343562764,no,1.349306480932574,0.5396940969900734
3+
0.4895324202650435,5,A,1.0101010101010102,5.485990647911073,4,5.298557080616259,1.5443569119913727,2.9819277153479637,yes,1.5443569119913727,4.290551784831006
4+
1.254377208674345,6,B,2.0202020202020203,-14.351716978316517,7,10.142074944849044,1.8925541096090202,3.0522223433106523,yes,1.8925541096090202,4.114756002986303
5+
1.6725687116893209,4,C,3.0303030303030303,4.616520832076883,2,3.054494217086992,2.9225596815878365,5.231501868720706,yes,2.9225596815878365,5.372270276604683
6+
4.231064539258242,6,C,4.040404040404041,8.658513061585253,6,7.822945723378931,2.9741049009737126,5.282150007884247,no,2.9741049009737126,4.714831810805004
7+
1.2619372096574972,6,B,5.050505050505051,-11.212944956821474,3,6.734756178497494,3.2227902656245906,8.804327753519782,yes,3.2227902656245906,6.32550757361621
8+
-1.0423227007368756,1,A,6.0606060606060606,8.577684745557237,8,10.234197154958048,3.2591996786269797,7.346598670219549,no,3.2591996786269797,5.272779222021495
9+
2.855702317343387,5,B,7.070707070707071,6.688047004842842,1,2.545889760802656,3.851367985397735,6.927470682458317,no,3.851367985397735,5.499774920535783
10+
2.424821608160163,6,D,8.080808080808081,15.212187642153882,7,12.201709934000492,4.086618218715554,6.091493686183943,yes,4.086618218715554,5.80740265050133
11+
5.143447964360778,7,C,9.090909090909092,19.385931625207764,1,4.119618192003367,4.130950582973014,8.173664816025381,yes,4.130950582973014,8.787594926083187
12+
2.9356684836478344,2,C,10.101010101010102,20.685857138472883,4,8.560257679034567,4.2305843573191035,8.220440422267298,no,4.2305843573191035,6.999827592076169
13+
5.439690482064671,7,C,11.111111111111112,14.372014477908845,8,12.841031867975422,4.346302966657089,9.474389289113311,yes,4.346302966657089,6.759763340995737
14+
1.589232831090709,4,D,12.121212121212121,11.842250277576484,2,4.224399295508096,4.471046220485407,8.113972368819079,no,4.471046220485407,8.23791206637176
15+
5.922921719431893,6,C,13.131313131313131,8.437982643434413,5,8.245488342838646,5.069103403877452,8.426945285296174,no,5.069103403877452,9.842488325663666
16+
1.788504635591139,5,D,14.141414141414142,22.88852795207213,3,7.22955903608773,5.414692448402981,9.08222782154281,no,5.414692448402981,8.466415628910891
17+
3.368249993584243,5,C,15.151515151515152,19.604182531841953,3,6.827895169995264,5.5836981458272925,10.560390681587016,no,5.5836981458272925,10.773345678134715
18+
2.9683688813415428,8,B,16.161616161616163,8.135056862232894,4,6.398587930332959,5.588276403341707,9.364522633401206,yes,5.588276403341707,10.202471290738579
19+
3.0153599092483856,7,C,17.171717171717173,14.837600961588159,8,10.066077502176098,5.67205028627793,9.783554928679152,no,5.67205028627793,8.154865116153633
20+
2.747406882969411,3,B,18.181818181818183,26.569542562080798,8,13.894052326818985,5.805684056740608,8.372651864305915,yes,5.805684056740608,11.14174782732908
21+
0.11408117913568128,2,C,19.191919191919194,22.82703465753191,9,14.224309890037725,6.357751713856747,11.52204749561465,no,6.357751713856747,9.994918418439894
22+
5.662540339718982,6,A,20.202020202020204,31.323147582688183,4,6.592544503158518,6.367610803595117,10.809012166010431,yes,6.367610803595117,9.83654032212162
23+
2.5471314901205657,4,C,21.212121212121215,14.322219371869204,4,8.448600068154033,6.403876227545249,11.104512033256764,no,6.403876227545249,11.654026161816814
24+
3.8704485657287058,6,B,22.222222222222225,31.46759580148254,5,5.813507610102725,6.423724882338449,10.465719039259785,yes,6.423724882338449,9.957837046344997
25+
-0.2902426300106038,3,B,23.232323232323235,33.732486684761824,7,11.092201575997855,6.465843935876414,11.047868607643313,yes,6.465843935876414,10.191593836497825
26+
-1.9988405500952946,6,D,24.242424242424242,29.03213612774119,3,5.146702584827808,6.497934742730864,10.552381759179331,yes,6.497934742730864,9.59252582992709
27+
0.8611858744177364,4,B,25.252525252525253,39.82986087958473,6,8.00572282297371,6.658392622749934,9.50205673703379,no,6.658392622749934,11.624375646218267
28+
1.7066626900552453,8,D,26.262626262626263,34.0238741434979,3,7.899334120374588,6.697202832623668,12.55003796095679,yes,6.697202832623668,11.335477307404325
29+
3.94598379924845,7,C,27.272727272727273,35.43603611130469,7,13.233417245865162,7.1320496533428415,10.249733101970538,no,7.1320496533428415,14.52768022034478
30+
1.4027046226406321,7,A,28.282828282828284,37.51326236730171,6,10.34449110181566,7.312241021291383,10.794089189250045,yes,7.312241021291383,10.608591778533054
31+
0.03307674936227789,6,A,29.292929292929294,45.426629040649736,1,4.75208056518466,7.355600530173356,12.714112714224392,no,7.355600530173356,13.385725088776086
32+
-0.48922974636881444,8,A,30.303030303030305,50.941203342426036,5,9.581418878269488,7.390283951801159,10.490120793791013,no,7.390283951801159,12.548663702035109
33+
5.421064127638989,9,A,31.313131313131315,52.32831540341658,7,8.796836222229972,7.402480404105772,11.748608683240457,yes,7.402480404105772,10.733820805240878
34+
1.5905115487484383,5,C,32.323232323232325,57.4734516260446,2,3.0124052480604098,7.600373220510218,14.809850295786536,yes,7.600373220510218,11.435212202822004
35+
0.7556640263393346,3,C,33.333333333333336,40.12017316378248,9,11.873012150473746,7.780821913777251,10.392731803347763,yes,7.780821913777251,13.082709604807814
36+
-0.39657495608395577,2,B,34.343434343434346,46.18422014146775,9,16.482875880428804,8.022893894445762,13.988601840437251,no,8.022893894445762,15.122961426935845
37+
3.5487464166243083,2,D,35.35353535353536,51.81889057909559,6,8.496603501911649,8.039481640931411,11.038545913135218,yes,8.039481640931411,13.03917799591521
38+
0.9655811378191299,6,B,36.36363636363637,41.83227869980686,4,9.00363613237883,8.153631917759505,11.823287902745498,yes,8.153631917759505,13.096640694641035
39+
-1.8554350833890156,4,B,37.37373737373738,43.26840117452935,7,10.81953658953414,8.409473819876368,14.55711564225936,no,8.409473819876368,14.133182770473315
40+
4.696262827049088,6,A,38.38383838383839,55.90257816801837,3,7.617625070076504,8.454027306252778,12.917127592480242,yes,8.454027306252778,14.202324634133518
41+
4.79174912372992,1,D,39.3939393939394,39.600797725100705,7,10.642373609735346,8.988051892180644,14.324696057630952,no,8.988051892180644,16.001710622943097
42+
3.241690350383881,9,B,40.40404040404041,43.44834918844673,3,5.212804914417689,9.352440537973482,13.48927296012409,no,9.352440537973482,16.37040965710135
43+
2.3998854036846717,3,C,41.41414141414142,59.96462153005665,8,11.794809628786217,9.369799317292628,13.370331030513718,yes,9.369799317292628,13.061461574714745
44+
2.805649492050467,5,C,42.42424242424243,67.40531580731228,1,3.8560488992766113,9.451718114785546,12.971799915331747,yes,9.451718114785546,13.841851442955281
45+
-1.532815509187135,4,B,43.43434343434344,49.598882272225794,3,6.037518831145281,9.612557164588615,16.02974186655398,no,9.612557164588615,18.599860151029837
46+
4.5926886935894276,6,B,44.44444444444445,72.16034934494057,8,10.988312953827766,9.737333273820237,14.383917558042587,no,9.737333273820237,15.186503591408082
47+
0.07864323427702535,3,B,45.45454545454546,68.80669335560268,6,12.737521903610359,9.794623469679525,15.081813375620175,no,9.794623469679525,17.743442144265618
48+
-0.4257946227711069,4,A,46.46464646464647,74.18012945565019,6,9.716664543182798,9.856256275297525,14.093557692974958,yes,9.856256275297525,16.061865403514574
49+
2.586805133590047,6,C,47.47474747474748,69.58076335399,1,3.5432385659325605,10.032747053619346,15.026341892070574,no,10.032747053619346,18.189811167842848
50+
4.085474836267062,6,D,48.484848484848484,57.61330409793538,9,12.37368036797113,10.0329710339341,13.470905671165923,no,10.0329710339341,19.006933982063764
51+
2.9711614866022638,5,A,49.494949494949495,76.5580364495509,1,3.3632338116244123,10.239832976963399,15.505642949555304,no,10.239832976963399,19.015803752102123
52+
-1.2591971759896938,4,C,50.505050505050505,65.15736859007941,2,2.4619071331550457,10.242792159486392,14.604669072165164,yes,10.242792159486392,15.666133478956864
53+
1.042049353423812,4,B,51.515151515151516,61.426418581715176,1,2.9398601276162917,10.344177223140434,18.704375307268634,yes,10.344177223140434,16.291499913971162
54+
1.1488692473361146,3,A,52.525252525252526,65.2143063804011,3,2.795180426385681,10.438425222147702,18.149153225685573,yes,10.438425222147702,16.36057274506675
55+
1.6249717721343386,3,C,53.535353535353536,79.34739453130466,6,10.52006931967205,10.628573825689212,13.872331941789401,no,10.628573825689212,18.03886066470642
56+
2.6762570013663316,4,C,54.54545454545455,73.56846208586784,8,13.735031358970078,10.772604217353607,13.860896139580195,no,10.772604217353607,20.59957724694341
57+
-1.4756832736674572,5,C,55.55555555555556,63.571955996087844,6,6.283550448475701,11.09465821550791,15.783363739509713,no,11.09465821550791,20.07088207284391
58+
3.273392167458116,11,C,56.56565656565657,75.34230727306877,2,2.953120575954027,11.747649366960061,15.29541666520134,yes,11.747649366960061,17.373404162911104
59+
0.11142535692578281,5,A,57.57575757575758,75.3321181781797,7,12.61232222140962,11.799528652126542,15.01734928893206,yes,11.799528652126542,16.262095724509454
60+
0.7162223371825257,3,A,58.58585858585859,86.78901765766157,6,10.126680029027483,12.748575516871925,18.7680298739712,no,12.748575516871925,23.357058891032374
61+
1.1498635916749533,11,A,59.5959595959596,87.73034887739048,3,8.86711912493541,12.860817670069963,19.549285546112735,no,12.860817670069963,23.491488929704257
62+
3.7434966773242406,4,B,60.60606060606061,85.8265646224205,4,9.459726026762663,12.884876487668912,17.9378019950319,yes,12.884876487668912,18.587199707172214
63+
-2.917503091042162,6,D,61.61616161616162,80.47812731696314,2,3.1438678989039524,13.044318176040544,19.984011994901994,no,13.044318176040544,24.394623356003134
64+
2.540653241874381,4,C,62.62626262626263,90.66542948332483,7,10.726836313766691,13.131216138116793,18.814889636705587,yes,13.131216138116793,18.705520800593685
65+
5.470477442017843,8,C,63.63636363636364,96.64326929644879,9,16.26682461447068,13.163262936468408,20.24728069553427,no,13.163262936468408,25.539185345572655
66+
0.9732920998911705,6,D,64.64646464646465,76.00287863227578,7,11.486717231434353,13.223288888353434,18.38139420150577,yes,13.223288888353434,17.82047535894562
67+
-1.5893539028898238,5,C,65.65656565656566,96.84937295008459,7,9.592698482501142,13.474555922771339,18.21458833540762,yes,13.474555922771339,19.456262435517793
68+
2.4586907775285045,3,D,66.66666666666667,88.46672357924257,2,6.548272868587285,14.371623410011077,21.014506831762752,yes,14.371623410011077,19.724651934585136
69+
-1.7478309446462963,2,C,67.67676767676768,89.93578244589136,7,14.188355624684753,14.412542182667476,19.63945244453223,yes,14.412542182667476,21.931414904511072
70+
-0.27286734998780116,5,A,68.68686868686869,97.01032530398702,7,12.436953217757612,14.489724577463246,21.384238985911274,yes,14.489724577463246,21.385098009172108
71+
0.6883174864425133,6,A,69.6969696969697,94.46397808269244,5,9.332239224948255,14.50597243545302,20.325614567719928,yes,14.50597243545302,20.424282813232434
72+
3.499986275519379,4,A,70.70707070707071,82.20654352578593,3,6.4311843974977725,14.843238146714171,19.63345644368227,no,14.843238146714171,27.410454581374868
73+
-1.0710584798856835,3,A,71.71717171717172,109.31144494957117,5,9.4007770048362,15.13520902274749,22.728842564259956,no,15.13520902274749,27.020568095332123
74+
2.5574900327154406,3,B,72.72727272727273,95.70439566102807,9,14.824908451116002,15.27942414995523,22.988447914195955,no,15.27942414995523,29.219856332311924
75+
-1.64906237130837,9,B,73.73737373737374,98.91600969483645,3,8.455298702312396,15.554417039169012,19.31105655772121,no,15.554417039169012,27.616113076447633
76+
5.424458685025318,10,C,74.74747474747475,101.38409088107808,8,11.694716303635,15.658735296091926,19.66990387491316,no,15.658735296091926,29.822991776341322
77+
-0.16571558245344775,1,C,75.75757575757576,92.15862283008143,5,9.105400922815683,15.765882562099403,22.021011237702396,yes,15.765882562099403,23.899508430721944
78+
-0.8996344860820584,2,D,76.76767676767678,101.74599346394541,9,12.156973005154676,15.770889514574778,21.692950868424454,no,15.770889514574778,29.887312942837784
79+
-0.6085111135303731,2,C,77.77777777777779,111.60518773355021,1,5.612766545069755,15.790654670064962,23.21610206238696,no,15.790654670064962,29.35882034114632
80+
1.4326377176142868,5,A,78.7878787878788,108.15246516360946,4,9.284889566021969,15.942182725788046,23.448433825548474,no,15.942182725788046,27.453657051325234
81+
1.2593135389896994,9,C,79.7979797979798,104.15957423911843,6,11.33668137039501,16.549115785358786,24.073610887047025,no,16.549115785358786,28.254241427704223
82+
0.9865508776202444,5,D,80.80808080808082,107.66244710791543,4,8.175321166877941,16.653870837163666,21.107481608525276,yes,16.653870837163666,23.301474751648097
83+
4.0947128803813,6,D,81.81818181818183,101.54863173656989,9,13.878964316360051,16.860915098384577,23.665231961830045,yes,16.860915098384577,23.40882785007789
84+
5.030992787116027,7,A,82.82828282828284,101.13072069496623,9,15.289547560200292,16.903191310850165,22.735016087442872,no,16.903191310850165,31.57519066893908
85+
2.7263881368435037,4,D,83.83838383838385,106.13172745695302,2,7.328682601507472,16.906214953807883,28.245859665261914,yes,16.906214953807883,26.318661422752513
86+
0.04758939810751217,2,A,84.84848484848486,116.17848223456606,5,10.484718394910011,17.130397519248117,22.10432142311893,yes,17.130397519248117,22.669950014599117
87+
-0.5319816296704487,4,D,85.85858585858587,116.01536985241785,7,10.231772945829492,17.557122004780545,23.857789416966337,no,17.557122004780545,30.950597278503466
88+
1.234076843328702,6,B,86.86868686868688,121.83406323267239,4,7.856950761507069,17.924928531471053,25.858971710242866,no,17.924928531471053,33.17701870548341
89+
1.5710931299364927,5,C,87.87878787878789,100.68673787407428,1,2.591541130003901,19.29772491925523,25.061138014465644,yes,19.29772491925523,24.521305650646074
90+
1.279649826429768,11,B,88.8888888888889,120.80673031466338,4,7.552947328029697,19.69977829106859,26.277822681902663,yes,19.69977829106859,25.868220597837002
91+
0.7432540212211144,9,D,89.89898989898991,115.33930492793681,6,8.641039567825386,22.41439757742217,30.891255569683928,no,22.41439757742217,42.58033063222204
92+
-1.4359057944221312,3,A,90.90909090909092,125.59144905824697,1,3.476036064977983,22.791114640755083,30.8581743903827,no,22.791114640755083,42.44561188890053
93+
-2.7993489873160327,4,C,91.91919191919193,130.0565025293372,8,9.909531115227043,23.6609156939325,34.051792302534935,no,23.6609156939325,43.356843795896104
94+
0.3465853106405965,5,D,92.92929292929294,123.18575148120183,6,10.873928184790742,24.525338108329493,34.359023238575666,yes,24.525338108329493,33.30951976996188
95+
-1.069520641303999,5,A,93.93939393939395,105.78445027295604,5,7.331542866812035,24.73000305454744,32.84987557388648,yes,24.73000305454744,33.349022720551154
96+
2.573751499409207,3,C,94.94949494949496,129.2232623843063,3,6.055369054669791,25.454573703086858,34.76184185218843,yes,25.454573703086858,36.75583751220707
97+
4.356577800568363,4,B,95.95959595959597,121.78587654612798,7,10.747770150179093,25.497032307080126,35.316746015865604,no,25.497032307080126,45.83356852795664
98+
4.592962774039928,7,B,96.96969696969697,126.17029953502812,8,13.282944366356293,27.7322621891691,38.763517880525214,yes,27.7322621891691,39.76902160710851
99+
2.061500595080339,4,D,97.97979797979798,134.62394251373738,3,7.694736106020759,29.04606943146414,39.347952605560124,no,29.04606943146414,52.14976494762348
100+
2.7351310775052284,5,C,98.98989898989899,138.34121319759547,7,13.030464370472856,33.68805232005014,45.62630766131095,yes,33.68805232005014,45.49223712289746
101+
3.612831101031076,5,C,100.0,111.93644113968989,2,3.8084689341018767,36.94348673796553,48.170160545634886,no,36.94348673796553,69.1743364684049

source-code/seaborn/READNE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Seaborn
2+
Seaborn works on top of matplotlib, and is especially strong for plotting
3+
data and its statistical properties.
4+
5+
## What is it?
6+
1. `seaborn.ipynb`: Jupyter notebook that illustrates a number of Seaborn
7+
features.
8+
1. `generate_data.py`: script to generate example data.
9+
1. `Data`: directory containing example data.

source-code/seaborn/generate_data.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
3+
import numpy as np
4+
5+
nr_data = 100
6+
gaussian = np.random.normal(loc=1.5, scale=2.0, size=nr_data)
7+
poisson = np.random.poisson(lam=5.0, size=nr_data)
8+
labels = np.random.choice(['A', 'B', 'C', 'D'], size=nr_data)
9+
x = np.linspace(0.0, 100.0, nr_data)
10+
y = 1.3*x + 2.0 + np.random.normal(scale=8, size=nr_data)
11+
x1 = np.random.choice(np.arange(1, 10, 1), size=nr_data)
12+
y1 = 1.3*x1 + 2.0 + np.random.normal(scale=1.5, size=nr_data)
13+
x2 = np.sort(np.random.gamma(3, scale=4, size=nr_data))
14+
y2 = 1.3*x2 + 2.0 + np.random.normal(scale=1.5, size=nr_data)
15+
binary = np.random.choice(np.array(['yes', 'no']), size=nr_data)
16+
x3 = x2.copy()
17+
y3 = np.where(binary == 'yes', 1.3, 1.9)*x3 + \
18+
np.where(binary == 'yes', 2.0, -1.0) + \
19+
np.random.normal(size=nr_data)
20+
with open('Data/data.txt', 'w') as file:
21+
print('gaussian,poisson,label,x,y,x1,y1,x2,y2,binary,x3,y3',file=file)
22+
for i in range(nr_data):
23+
print(f'{gaussian[i]},{poisson[i]},{labels[i]},{x[i]},{y[i]},'
24+
f'{x1[i]},{y1[i]},{x2[i]},{y2[i]},{binary[i]},'
25+
f'{x3[i]},{y3[i]}',
26+
file=file)

0 commit comments

Comments
 (0)