├── .gitignore ├── LICENSE ├── README.md ├── data_science_basics └── BasicPythonSupport │ ├── .ipynb_checkpoints │ └── Python_basics-checkpoint.ipynb │ ├── Boxplot.png │ ├── Python_basics.ipynb │ ├── titanic.csv │ ├── uforeports.csv │ └── uforeports_excel.xls ├── lecture_10 ├── .ipynb_checkpoints │ └── Lecture10-checkpoint.ipynb ├── Lecture10.ipynb ├── adspy_shared_utilities.py ├── fruit_data_with_colors.txt ├── wine_data.csv └── winequality-white.csv ├── lecture_slides ├── FIT1043_IntroDS_Lecture 2-2018S2.pdf ├── FIT1043_IntroDS_Lecture 3-2018S2.pdf ├── FIT1043_IntroDS_Lecture 4-2018S2.pdf ├── FIT1043_introDS_Lecture 1-2018S2.pdf ├── FIT1043_introDS_Lecture 10-2018S2(2).pdf ├── FIT1043_introDS_Lecture 10-2018S2.pdf ├── FIT1043_introDS_Lecture 11-2018S2.pdf ├── FIT1043_introDS_Lecture 12-2018S2.pdf ├── FIT1043_introDS_Lecture 5-2018S2.pdf ├── FIT1043_introDS_Lecture 6-2018S2.pdf ├── FIT1043_introDS_Lecture 7-2018S2.pdf ├── FIT1043_introDS_Lecture 8-2018S2.pdf ├── FIT1043_introDS_Lecture 9-2018S2.pdf ├── FIT1043_introDS_M6_L11-Unit review.pdf ├── Intro_to_Predictive_Models.pdf ├── Introduction-to-Data-Science.pdf ├── Introduction_to_Python_for_Data_Science.pdf ├── Introduction_to_Python_for_Data_Science_PART2.pdf ├── Introduction_to_R_for_Data_Science.pdf ├── Introduction_to_Shell_Commands_for_Data_Science.pdf ├── PMML in R.png ├── PandasPythonForDataScience.pdf ├── Semi Structured Data.pdf └── Ten Examples of Open Source Projects.pdf ├── motion-chart_activity └── MotionChart Activity │ ├── .ipynb_checkpoints │ └── MotionChart-checkpoint.ipynb │ ├── MotionChart.ipynb │ ├── data.csv │ ├── mc_temp.html │ ├── motionchart.py │ ├── motionchart │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ └── motionchart.cpython-36.pyc │ └── motionchart.py │ └── setting.png ├── notes ├── commands.pdf └── complete_notes.pdf └── past_exam ├── FIT1043_Sample_2016.pdf ├── FIT1043_Sample_Exam.pdf ├── FIT1043_Sample_Exam_Sols.pdf └── answers.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac files 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jun Qing Lim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fit1043-introduction-to-data-science 2 | FIT1043 Introduction to Data Science notes, batch of Semester 2, 2018. 3 | 4 | ## Notes 5 | [notes](notes) is written by me. *Do take note of any inaccuracies made by me.* 6 | 7 | ## Review over FIT1043 8 | Took this unit during my entry first semester. Much of what was taught in lectures were all about scraping data from online public datasets site like [Kaggle](https://www.kaggle.com/datasets). Speaking from the perspective of a person with no absolute background in "data field", this unit is considered as challenging for me, because much of the mathematical understanding behind the data modelling requires advanced mathematics skills such as [Regression Analysis](https://en.wikipedia.org/wiki/Regression_analysis), [Linear Regression](https://en.wikipedia.org/wiki/Linear_regression).

So it was regarded as a "course without deep understanding". Assignments were easy and basic, which extracts info from the lecture slides and tutorials. Full marks are easily achievable as the assignments were opinion/analysis-based, where answers that make sense/valid/logic will be deemed to be correct, so there are no absolute answers in this unit, but like a philosophical approach of describing the data. Memorization constitutes a large portion of the exam, as the real understanding is not within the scope of the unit, so lots of stuffs are preliminary, which requires memorization. All-in-all, data science is statistics, without statistics skills, one could hardly understand the reasons behind data science. Would recommend this to people with interest in statistics, as it serves an elementary idea of what data is all about. It is also strongly and closely related to machine learning and artificial intelligence field. 9 | 10 | Overall Rating: 2/10
Final Grade: HD 11 | 12 | ## License 13 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 14 |
Copyright (c) 2019 Jun Qing Lim
The content of this repository is licensed under [MIT License](https://opensource.org/licenses/MIT). See [LICENSE](LICENSE) for more information. 15 | -------------------------------------------------------------------------------- /data_science_basics/BasicPythonSupport/Boxplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/data_science_basics/BasicPythonSupport/Boxplot.png -------------------------------------------------------------------------------- /data_science_basics/BasicPythonSupport/titanic.csv: -------------------------------------------------------------------------------- 1 | survived,pclass,sex,age,sibsp,parch,fare,embarked,class,who,adult_male,deck,embark_town,alive,alone 2 | 0,3,male,22.0,1,0,7.25,S,Third,man,True,,Southampton,no,False 3 | 1,1,female,38.0,1,0,71.2833,C,First,woman,False,C,Cherbourg,yes,False 4 | 1,3,female,26.0,0,0,7.925,S,Third,woman,False,,Southampton,yes,True 5 | 1,1,female,35.0,1,0,53.1,S,First,woman,False,C,Southampton,yes,False 6 | 0,3,male,35.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 7 | 0,3,male,,0,0,8.4583,Q,Third,man,True,,Queenstown,no,True 8 | 0,1,male,54.0,0,0,51.8625,S,First,man,True,E,Southampton,no,True 9 | 0,3,male,2.0,3,1,21.075,S,Third,child,False,,Southampton,no,False 10 | 1,3,female,27.0,0,2,11.1333,S,Third,woman,False,,Southampton,yes,False 11 | 1,2,female,14.0,1,0,30.0708,C,Second,child,False,,Cherbourg,yes,False 12 | 1,3,female,4.0,1,1,16.7,S,Third,child,False,G,Southampton,yes,False 13 | 1,1,female,58.0,0,0,26.55,S,First,woman,False,C,Southampton,yes,True 14 | 0,3,male,20.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 15 | 0,3,male,39.0,1,5,31.275,S,Third,man,True,,Southampton,no,False 16 | 0,3,female,14.0,0,0,7.8542,S,Third,child,False,,Southampton,no,True 17 | 1,2,female,55.0,0,0,16.0,S,Second,woman,False,,Southampton,yes,True 18 | 0,3,male,2.0,4,1,29.125,Q,Third,child,False,,Queenstown,no,False 19 | 1,2,male,,0,0,13.0,S,Second,man,True,,Southampton,yes,True 20 | 0,3,female,31.0,1,0,18.0,S,Third,woman,False,,Southampton,no,False 21 | 1,3,female,,0,0,7.225,C,Third,woman,False,,Cherbourg,yes,True 22 | 0,2,male,35.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 23 | 1,2,male,34.0,0,0,13.0,S,Second,man,True,D,Southampton,yes,True 24 | 1,3,female,15.0,0,0,8.0292,Q,Third,child,False,,Queenstown,yes,True 25 | 1,1,male,28.0,0,0,35.5,S,First,man,True,A,Southampton,yes,True 26 | 0,3,female,8.0,3,1,21.075,S,Third,child,False,,Southampton,no,False 27 | 1,3,female,38.0,1,5,31.3875,S,Third,woman,False,,Southampton,yes,False 28 | 0,3,male,,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 29 | 0,1,male,19.0,3,2,263.0,S,First,man,True,C,Southampton,no,False 30 | 1,3,female,,0,0,7.8792,Q,Third,woman,False,,Queenstown,yes,True 31 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 32 | 0,1,male,40.0,0,0,27.7208,C,First,man,True,,Cherbourg,no,True 33 | 1,1,female,,1,0,146.5208,C,First,woman,False,B,Cherbourg,yes,False 34 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 35 | 0,2,male,66.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 36 | 0,1,male,28.0,1,0,82.1708,C,First,man,True,,Cherbourg,no,False 37 | 0,1,male,42.0,1,0,52.0,S,First,man,True,,Southampton,no,False 38 | 1,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,yes,True 39 | 0,3,male,21.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 40 | 0,3,female,18.0,2,0,18.0,S,Third,woman,False,,Southampton,no,False 41 | 1,3,female,14.0,1,0,11.2417,C,Third,child,False,,Cherbourg,yes,False 42 | 0,3,female,40.0,1,0,9.475,S,Third,woman,False,,Southampton,no,False 43 | 0,2,female,27.0,1,0,21.0,S,Second,woman,False,,Southampton,no,False 44 | 0,3,male,,0,0,7.8958,C,Third,man,True,,Cherbourg,no,True 45 | 1,2,female,3.0,1,2,41.5792,C,Second,child,False,,Cherbourg,yes,False 46 | 1,3,female,19.0,0,0,7.8792,Q,Third,woman,False,,Queenstown,yes,True 47 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 48 | 0,3,male,,1,0,15.5,Q,Third,man,True,,Queenstown,no,False 49 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 50 | 0,3,male,,2,0,21.6792,C,Third,man,True,,Cherbourg,no,False 51 | 0,3,female,18.0,1,0,17.8,S,Third,woman,False,,Southampton,no,False 52 | 0,3,male,7.0,4,1,39.6875,S,Third,child,False,,Southampton,no,False 53 | 0,3,male,21.0,0,0,7.8,S,Third,man,True,,Southampton,no,True 54 | 1,1,female,49.0,1,0,76.7292,C,First,woman,False,D,Cherbourg,yes,False 55 | 1,2,female,29.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 56 | 0,1,male,65.0,0,1,61.9792,C,First,man,True,B,Cherbourg,no,False 57 | 1,1,male,,0,0,35.5,S,First,man,True,C,Southampton,yes,True 58 | 1,2,female,21.0,0,0,10.5,S,Second,woman,False,,Southampton,yes,True 59 | 0,3,male,28.5,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 60 | 1,2,female,5.0,1,2,27.75,S,Second,child,False,,Southampton,yes,False 61 | 0,3,male,11.0,5,2,46.9,S,Third,child,False,,Southampton,no,False 62 | 0,3,male,22.0,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 63 | 1,1,female,38.0,0,0,80.0,,First,woman,False,B,,yes,True 64 | 0,1,male,45.0,1,0,83.475,S,First,man,True,C,Southampton,no,False 65 | 0,3,male,4.0,3,2,27.9,S,Third,child,False,,Southampton,no,False 66 | 0,1,male,,0,0,27.7208,C,First,man,True,,Cherbourg,no,True 67 | 1,3,male,,1,1,15.2458,C,Third,man,True,,Cherbourg,yes,False 68 | 1,2,female,29.0,0,0,10.5,S,Second,woman,False,F,Southampton,yes,True 69 | 0,3,male,19.0,0,0,8.1583,S,Third,man,True,,Southampton,no,True 70 | 1,3,female,17.0,4,2,7.925,S,Third,woman,False,,Southampton,yes,False 71 | 0,3,male,26.0,2,0,8.6625,S,Third,man,True,,Southampton,no,False 72 | 0,2,male,32.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 73 | 0,3,female,16.0,5,2,46.9,S,Third,woman,False,,Southampton,no,False 74 | 0,2,male,21.0,0,0,73.5,S,Second,man,True,,Southampton,no,True 75 | 0,3,male,26.0,1,0,14.4542,C,Third,man,True,,Cherbourg,no,False 76 | 1,3,male,32.0,0,0,56.4958,S,Third,man,True,,Southampton,yes,True 77 | 0,3,male,25.0,0,0,7.65,S,Third,man,True,F,Southampton,no,True 78 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 79 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 80 | 1,2,male,0.83,0,2,29.0,S,Second,child,False,,Southampton,yes,False 81 | 1,3,female,30.0,0,0,12.475,S,Third,woman,False,,Southampton,yes,True 82 | 0,3,male,22.0,0,0,9.0,S,Third,man,True,,Southampton,no,True 83 | 1,3,male,29.0,0,0,9.5,S,Third,man,True,,Southampton,yes,True 84 | 1,3,female,,0,0,7.7875,Q,Third,woman,False,,Queenstown,yes,True 85 | 0,1,male,28.0,0,0,47.1,S,First,man,True,,Southampton,no,True 86 | 1,2,female,17.0,0,0,10.5,S,Second,woman,False,,Southampton,yes,True 87 | 1,3,female,33.0,3,0,15.85,S,Third,woman,False,,Southampton,yes,False 88 | 0,3,male,16.0,1,3,34.375,S,Third,man,True,,Southampton,no,False 89 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 90 | 1,1,female,23.0,3,2,263.0,S,First,woman,False,C,Southampton,yes,False 91 | 0,3,male,24.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 92 | 0,3,male,29.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 93 | 0,3,male,20.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 94 | 0,1,male,46.0,1,0,61.175,S,First,man,True,E,Southampton,no,False 95 | 0,3,male,26.0,1,2,20.575,S,Third,man,True,,Southampton,no,False 96 | 0,3,male,59.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 97 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 98 | 0,1,male,71.0,0,0,34.6542,C,First,man,True,A,Cherbourg,no,True 99 | 1,1,male,23.0,0,1,63.3583,C,First,man,True,D,Cherbourg,yes,False 100 | 1,2,female,34.0,0,1,23.0,S,Second,woman,False,,Southampton,yes,False 101 | 0,2,male,34.0,1,0,26.0,S,Second,man,True,,Southampton,no,False 102 | 0,3,female,28.0,0,0,7.8958,S,Third,woman,False,,Southampton,no,True 103 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 104 | 0,1,male,21.0,0,1,77.2875,S,First,man,True,D,Southampton,no,False 105 | 0,3,male,33.0,0,0,8.6542,S,Third,man,True,,Southampton,no,True 106 | 0,3,male,37.0,2,0,7.925,S,Third,man,True,,Southampton,no,False 107 | 0,3,male,28.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 108 | 1,3,female,21.0,0,0,7.65,S,Third,woman,False,,Southampton,yes,True 109 | 1,3,male,,0,0,7.775,S,Third,man,True,,Southampton,yes,True 110 | 0,3,male,38.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 111 | 1,3,female,,1,0,24.15,Q,Third,woman,False,,Queenstown,yes,False 112 | 0,1,male,47.0,0,0,52.0,S,First,man,True,C,Southampton,no,True 113 | 0,3,female,14.5,1,0,14.4542,C,Third,child,False,,Cherbourg,no,False 114 | 0,3,male,22.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 115 | 0,3,female,20.0,1,0,9.825,S,Third,woman,False,,Southampton,no,False 116 | 0,3,female,17.0,0,0,14.4583,C,Third,woman,False,,Cherbourg,no,True 117 | 0,3,male,21.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 118 | 0,3,male,70.5,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 119 | 0,2,male,29.0,1,0,21.0,S,Second,man,True,,Southampton,no,False 120 | 0,1,male,24.0,0,1,247.5208,C,First,man,True,B,Cherbourg,no,False 121 | 0,3,female,2.0,4,2,31.275,S,Third,child,False,,Southampton,no,False 122 | 0,2,male,21.0,2,0,73.5,S,Second,man,True,,Southampton,no,False 123 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 124 | 0,2,male,32.5,1,0,30.0708,C,Second,man,True,,Cherbourg,no,False 125 | 1,2,female,32.5,0,0,13.0,S,Second,woman,False,E,Southampton,yes,True 126 | 0,1,male,54.0,0,1,77.2875,S,First,man,True,D,Southampton,no,False 127 | 1,3,male,12.0,1,0,11.2417,C,Third,child,False,,Cherbourg,yes,False 128 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 129 | 1,3,male,24.0,0,0,7.1417,S,Third,man,True,,Southampton,yes,True 130 | 1,3,female,,1,1,22.3583,C,Third,woman,False,F,Cherbourg,yes,False 131 | 0,3,male,45.0,0,0,6.975,S,Third,man,True,,Southampton,no,True 132 | 0,3,male,33.0,0,0,7.8958,C,Third,man,True,,Cherbourg,no,True 133 | 0,3,male,20.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 134 | 0,3,female,47.0,1,0,14.5,S,Third,woman,False,,Southampton,no,False 135 | 1,2,female,29.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 136 | 0,2,male,25.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 137 | 0,2,male,23.0,0,0,15.0458,C,Second,man,True,,Cherbourg,no,True 138 | 1,1,female,19.0,0,2,26.2833,S,First,woman,False,D,Southampton,yes,False 139 | 0,1,male,37.0,1,0,53.1,S,First,man,True,C,Southampton,no,False 140 | 0,3,male,16.0,0,0,9.2167,S,Third,man,True,,Southampton,no,True 141 | 0,1,male,24.0,0,0,79.2,C,First,man,True,B,Cherbourg,no,True 142 | 0,3,female,,0,2,15.2458,C,Third,woman,False,,Cherbourg,no,False 143 | 1,3,female,22.0,0,0,7.75,S,Third,woman,False,,Southampton,yes,True 144 | 1,3,female,24.0,1,0,15.85,S,Third,woman,False,,Southampton,yes,False 145 | 0,3,male,19.0,0,0,6.75,Q,Third,man,True,,Queenstown,no,True 146 | 0,2,male,18.0,0,0,11.5,S,Second,man,True,,Southampton,no,True 147 | 0,2,male,19.0,1,1,36.75,S,Second,man,True,,Southampton,no,False 148 | 1,3,male,27.0,0,0,7.7958,S,Third,man,True,,Southampton,yes,True 149 | 0,3,female,9.0,2,2,34.375,S,Third,child,False,,Southampton,no,False 150 | 0,2,male,36.5,0,2,26.0,S,Second,man,True,F,Southampton,no,False 151 | 0,2,male,42.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 152 | 0,2,male,51.0,0,0,12.525,S,Second,man,True,,Southampton,no,True 153 | 1,1,female,22.0,1,0,66.6,S,First,woman,False,C,Southampton,yes,False 154 | 0,3,male,55.5,0,0,8.05,S,Third,man,True,,Southampton,no,True 155 | 0,3,male,40.5,0,2,14.5,S,Third,man,True,,Southampton,no,False 156 | 0,3,male,,0,0,7.3125,S,Third,man,True,,Southampton,no,True 157 | 0,1,male,51.0,0,1,61.3792,C,First,man,True,,Cherbourg,no,False 158 | 1,3,female,16.0,0,0,7.7333,Q,Third,woman,False,,Queenstown,yes,True 159 | 0,3,male,30.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 160 | 0,3,male,,0,0,8.6625,S,Third,man,True,,Southampton,no,True 161 | 0,3,male,,8,2,69.55,S,Third,man,True,,Southampton,no,False 162 | 0,3,male,44.0,0,1,16.1,S,Third,man,True,,Southampton,no,False 163 | 1,2,female,40.0,0,0,15.75,S,Second,woman,False,,Southampton,yes,True 164 | 0,3,male,26.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 165 | 0,3,male,17.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 166 | 0,3,male,1.0,4,1,39.6875,S,Third,child,False,,Southampton,no,False 167 | 1,3,male,9.0,0,2,20.525,S,Third,child,False,,Southampton,yes,False 168 | 1,1,female,,0,1,55.0,S,First,woman,False,E,Southampton,yes,False 169 | 0,3,female,45.0,1,4,27.9,S,Third,woman,False,,Southampton,no,False 170 | 0,1,male,,0,0,25.925,S,First,man,True,,Southampton,no,True 171 | 0,3,male,28.0,0,0,56.4958,S,Third,man,True,,Southampton,no,True 172 | 0,1,male,61.0,0,0,33.5,S,First,man,True,B,Southampton,no,True 173 | 0,3,male,4.0,4,1,29.125,Q,Third,child,False,,Queenstown,no,False 174 | 1,3,female,1.0,1,1,11.1333,S,Third,child,False,,Southampton,yes,False 175 | 0,3,male,21.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 176 | 0,1,male,56.0,0,0,30.6958,C,First,man,True,A,Cherbourg,no,True 177 | 0,3,male,18.0,1,1,7.8542,S,Third,man,True,,Southampton,no,False 178 | 0,3,male,,3,1,25.4667,S,Third,man,True,,Southampton,no,False 179 | 0,1,female,50.0,0,0,28.7125,C,First,woman,False,C,Cherbourg,no,True 180 | 0,2,male,30.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 181 | 0,3,male,36.0,0,0,0.0,S,Third,man,True,,Southampton,no,True 182 | 0,3,female,,8,2,69.55,S,Third,woman,False,,Southampton,no,False 183 | 0,2,male,,0,0,15.05,C,Second,man,True,,Cherbourg,no,True 184 | 0,3,male,9.0,4,2,31.3875,S,Third,child,False,,Southampton,no,False 185 | 1,2,male,1.0,2,1,39.0,S,Second,child,False,F,Southampton,yes,False 186 | 1,3,female,4.0,0,2,22.025,S,Third,child,False,,Southampton,yes,False 187 | 0,1,male,,0,0,50.0,S,First,man,True,A,Southampton,no,True 188 | 1,3,female,,1,0,15.5,Q,Third,woman,False,,Queenstown,yes,False 189 | 1,1,male,45.0,0,0,26.55,S,First,man,True,,Southampton,yes,True 190 | 0,3,male,40.0,1,1,15.5,Q,Third,man,True,,Queenstown,no,False 191 | 0,3,male,36.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 192 | 1,2,female,32.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 193 | 0,2,male,19.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 194 | 1,3,female,19.0,1,0,7.8542,S,Third,woman,False,,Southampton,yes,False 195 | 1,2,male,3.0,1,1,26.0,S,Second,child,False,F,Southampton,yes,False 196 | 1,1,female,44.0,0,0,27.7208,C,First,woman,False,B,Cherbourg,yes,True 197 | 1,1,female,58.0,0,0,146.5208,C,First,woman,False,B,Cherbourg,yes,True 198 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 199 | 0,3,male,42.0,0,1,8.4042,S,Third,man,True,,Southampton,no,False 200 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 201 | 0,2,female,24.0,0,0,13.0,S,Second,woman,False,,Southampton,no,True 202 | 0,3,male,28.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 203 | 0,3,male,,8,2,69.55,S,Third,man,True,,Southampton,no,False 204 | 0,3,male,34.0,0,0,6.4958,S,Third,man,True,,Southampton,no,True 205 | 0,3,male,45.5,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 206 | 1,3,male,18.0,0,0,8.05,S,Third,man,True,,Southampton,yes,True 207 | 0,3,female,2.0,0,1,10.4625,S,Third,child,False,G,Southampton,no,False 208 | 0,3,male,32.0,1,0,15.85,S,Third,man,True,,Southampton,no,False 209 | 1,3,male,26.0,0,0,18.7875,C,Third,man,True,,Cherbourg,yes,True 210 | 1,3,female,16.0,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 211 | 1,1,male,40.0,0,0,31.0,C,First,man,True,A,Cherbourg,yes,True 212 | 0,3,male,24.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 213 | 1,2,female,35.0,0,0,21.0,S,Second,woman,False,,Southampton,yes,True 214 | 0,3,male,22.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 215 | 0,2,male,30.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 216 | 0,3,male,,1,0,7.75,Q,Third,man,True,,Queenstown,no,False 217 | 1,1,female,31.0,1,0,113.275,C,First,woman,False,D,Cherbourg,yes,False 218 | 1,3,female,27.0,0,0,7.925,S,Third,woman,False,,Southampton,yes,True 219 | 0,2,male,42.0,1,0,27.0,S,Second,man,True,,Southampton,no,False 220 | 1,1,female,32.0,0,0,76.2917,C,First,woman,False,D,Cherbourg,yes,True 221 | 0,2,male,30.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 222 | 1,3,male,16.0,0,0,8.05,S,Third,man,True,,Southampton,yes,True 223 | 0,2,male,27.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 224 | 0,3,male,51.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 225 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 226 | 1,1,male,38.0,1,0,90.0,S,First,man,True,C,Southampton,yes,False 227 | 0,3,male,22.0,0,0,9.35,S,Third,man,True,,Southampton,no,True 228 | 1,2,male,19.0,0,0,10.5,S,Second,man,True,,Southampton,yes,True 229 | 0,3,male,20.5,0,0,7.25,S,Third,man,True,,Southampton,no,True 230 | 0,2,male,18.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 231 | 0,3,female,,3,1,25.4667,S,Third,woman,False,,Southampton,no,False 232 | 1,1,female,35.0,1,0,83.475,S,First,woman,False,C,Southampton,yes,False 233 | 0,3,male,29.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 234 | 0,2,male,59.0,0,0,13.5,S,Second,man,True,,Southampton,no,True 235 | 1,3,female,5.0,4,2,31.3875,S,Third,child,False,,Southampton,yes,False 236 | 0,2,male,24.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 237 | 0,3,female,,0,0,7.55,S,Third,woman,False,,Southampton,no,True 238 | 0,2,male,44.0,1,0,26.0,S,Second,man,True,,Southampton,no,False 239 | 1,2,female,8.0,0,2,26.25,S,Second,child,False,,Southampton,yes,False 240 | 0,2,male,19.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 241 | 0,2,male,33.0,0,0,12.275,S,Second,man,True,,Southampton,no,True 242 | 0,3,female,,1,0,14.4542,C,Third,woman,False,,Cherbourg,no,False 243 | 1,3,female,,1,0,15.5,Q,Third,woman,False,,Queenstown,yes,False 244 | 0,2,male,29.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 245 | 0,3,male,22.0,0,0,7.125,S,Third,man,True,,Southampton,no,True 246 | 0,3,male,30.0,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 247 | 0,1,male,44.0,2,0,90.0,Q,First,man,True,C,Queenstown,no,False 248 | 0,3,female,25.0,0,0,7.775,S,Third,woman,False,,Southampton,no,True 249 | 1,2,female,24.0,0,2,14.5,S,Second,woman,False,,Southampton,yes,False 250 | 1,1,male,37.0,1,1,52.5542,S,First,man,True,D,Southampton,yes,False 251 | 0,2,male,54.0,1,0,26.0,S,Second,man,True,,Southampton,no,False 252 | 0,3,male,,0,0,7.25,S,Third,man,True,,Southampton,no,True 253 | 0,3,female,29.0,1,1,10.4625,S,Third,woman,False,G,Southampton,no,False 254 | 0,1,male,62.0,0,0,26.55,S,First,man,True,C,Southampton,no,True 255 | 0,3,male,30.0,1,0,16.1,S,Third,man,True,,Southampton,no,False 256 | 0,3,female,41.0,0,2,20.2125,S,Third,woman,False,,Southampton,no,False 257 | 1,3,female,29.0,0,2,15.2458,C,Third,woman,False,,Cherbourg,yes,False 258 | 1,1,female,,0,0,79.2,C,First,woman,False,,Cherbourg,yes,True 259 | 1,1,female,30.0,0,0,86.5,S,First,woman,False,B,Southampton,yes,True 260 | 1,1,female,35.0,0,0,512.3292,C,First,woman,False,,Cherbourg,yes,True 261 | 1,2,female,50.0,0,1,26.0,S,Second,woman,False,,Southampton,yes,False 262 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 263 | 1,3,male,3.0,4,2,31.3875,S,Third,child,False,,Southampton,yes,False 264 | 0,1,male,52.0,1,1,79.65,S,First,man,True,E,Southampton,no,False 265 | 0,1,male,40.0,0,0,0.0,S,First,man,True,B,Southampton,no,True 266 | 0,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,no,True 267 | 0,2,male,36.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 268 | 0,3,male,16.0,4,1,39.6875,S,Third,man,True,,Southampton,no,False 269 | 1,3,male,25.0,1,0,7.775,S,Third,man,True,,Southampton,yes,False 270 | 1,1,female,58.0,0,1,153.4625,S,First,woman,False,C,Southampton,yes,False 271 | 1,1,female,35.0,0,0,135.6333,S,First,woman,False,C,Southampton,yes,True 272 | 0,1,male,,0,0,31.0,S,First,man,True,,Southampton,no,True 273 | 1,3,male,25.0,0,0,0.0,S,Third,man,True,,Southampton,yes,True 274 | 1,2,female,41.0,0,1,19.5,S,Second,woman,False,,Southampton,yes,False 275 | 0,1,male,37.0,0,1,29.7,C,First,man,True,C,Cherbourg,no,False 276 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 277 | 1,1,female,63.0,1,0,77.9583,S,First,woman,False,D,Southampton,yes,False 278 | 0,3,female,45.0,0,0,7.75,S,Third,woman,False,,Southampton,no,True 279 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 280 | 0,3,male,7.0,4,1,29.125,Q,Third,child,False,,Queenstown,no,False 281 | 1,3,female,35.0,1,1,20.25,S,Third,woman,False,,Southampton,yes,False 282 | 0,3,male,65.0,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 283 | 0,3,male,28.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 284 | 0,3,male,16.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 285 | 1,3,male,19.0,0,0,8.05,S,Third,man,True,,Southampton,yes,True 286 | 0,1,male,,0,0,26.0,S,First,man,True,A,Southampton,no,True 287 | 0,3,male,33.0,0,0,8.6625,C,Third,man,True,,Cherbourg,no,True 288 | 1,3,male,30.0,0,0,9.5,S,Third,man,True,,Southampton,yes,True 289 | 0,3,male,22.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 290 | 1,2,male,42.0,0,0,13.0,S,Second,man,True,,Southampton,yes,True 291 | 1,3,female,22.0,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 292 | 1,1,female,26.0,0,0,78.85,S,First,woman,False,,Southampton,yes,True 293 | 1,1,female,19.0,1,0,91.0792,C,First,woman,False,B,Cherbourg,yes,False 294 | 0,2,male,36.0,0,0,12.875,C,Second,man,True,D,Cherbourg,no,True 295 | 0,3,female,24.0,0,0,8.85,S,Third,woman,False,,Southampton,no,True 296 | 0,3,male,24.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 297 | 0,1,male,,0,0,27.7208,C,First,man,True,,Cherbourg,no,True 298 | 0,3,male,23.5,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 299 | 0,1,female,2.0,1,2,151.55,S,First,child,False,C,Southampton,no,False 300 | 1,1,male,,0,0,30.5,S,First,man,True,C,Southampton,yes,True 301 | 1,1,female,50.0,0,1,247.5208,C,First,woman,False,B,Cherbourg,yes,False 302 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 303 | 1,3,male,,2,0,23.25,Q,Third,man,True,,Queenstown,yes,False 304 | 0,3,male,19.0,0,0,0.0,S,Third,man,True,,Southampton,no,True 305 | 1,2,female,,0,0,12.35,Q,Second,woman,False,E,Queenstown,yes,True 306 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 307 | 1,1,male,0.92,1,2,151.55,S,First,child,False,C,Southampton,yes,False 308 | 1,1,female,,0,0,110.8833,C,First,woman,False,,Cherbourg,yes,True 309 | 1,1,female,17.0,1,0,108.9,C,First,woman,False,C,Cherbourg,yes,False 310 | 0,2,male,30.0,1,0,24.0,C,Second,man,True,,Cherbourg,no,False 311 | 1,1,female,30.0,0,0,56.9292,C,First,woman,False,E,Cherbourg,yes,True 312 | 1,1,female,24.0,0,0,83.1583,C,First,woman,False,C,Cherbourg,yes,True 313 | 1,1,female,18.0,2,2,262.375,C,First,woman,False,B,Cherbourg,yes,False 314 | 0,2,female,26.0,1,1,26.0,S,Second,woman,False,,Southampton,no,False 315 | 0,3,male,28.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 316 | 0,2,male,43.0,1,1,26.25,S,Second,man,True,,Southampton,no,False 317 | 1,3,female,26.0,0,0,7.8542,S,Third,woman,False,,Southampton,yes,True 318 | 1,2,female,24.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 319 | 0,2,male,54.0,0,0,14.0,S,Second,man,True,,Southampton,no,True 320 | 1,1,female,31.0,0,2,164.8667,S,First,woman,False,C,Southampton,yes,False 321 | 1,1,female,40.0,1,1,134.5,C,First,woman,False,E,Cherbourg,yes,False 322 | 0,3,male,22.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 323 | 0,3,male,27.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 324 | 1,2,female,30.0,0,0,12.35,Q,Second,woman,False,,Queenstown,yes,True 325 | 1,2,female,22.0,1,1,29.0,S,Second,woman,False,,Southampton,yes,False 326 | 0,3,male,,8,2,69.55,S,Third,man,True,,Southampton,no,False 327 | 1,1,female,36.0,0,0,135.6333,C,First,woman,False,C,Cherbourg,yes,True 328 | 0,3,male,61.0,0,0,6.2375,S,Third,man,True,,Southampton,no,True 329 | 1,2,female,36.0,0,0,13.0,S,Second,woman,False,D,Southampton,yes,True 330 | 1,3,female,31.0,1,1,20.525,S,Third,woman,False,,Southampton,yes,False 331 | 1,1,female,16.0,0,1,57.9792,C,First,woman,False,B,Cherbourg,yes,False 332 | 1,3,female,,2,0,23.25,Q,Third,woman,False,,Queenstown,yes,False 333 | 0,1,male,45.5,0,0,28.5,S,First,man,True,C,Southampton,no,True 334 | 0,1,male,38.0,0,1,153.4625,S,First,man,True,C,Southampton,no,False 335 | 0,3,male,16.0,2,0,18.0,S,Third,man,True,,Southampton,no,False 336 | 1,1,female,,1,0,133.65,S,First,woman,False,,Southampton,yes,False 337 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 338 | 0,1,male,29.0,1,0,66.6,S,First,man,True,C,Southampton,no,False 339 | 1,1,female,41.0,0,0,134.5,C,First,woman,False,E,Cherbourg,yes,True 340 | 1,3,male,45.0,0,0,8.05,S,Third,man,True,,Southampton,yes,True 341 | 0,1,male,45.0,0,0,35.5,S,First,man,True,,Southampton,no,True 342 | 1,2,male,2.0,1,1,26.0,S,Second,child,False,F,Southampton,yes,False 343 | 1,1,female,24.0,3,2,263.0,S,First,woman,False,C,Southampton,yes,False 344 | 0,2,male,28.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 345 | 0,2,male,25.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 346 | 0,2,male,36.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 347 | 1,2,female,24.0,0,0,13.0,S,Second,woman,False,F,Southampton,yes,True 348 | 1,2,female,40.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 349 | 1,3,female,,1,0,16.1,S,Third,woman,False,,Southampton,yes,False 350 | 1,3,male,3.0,1,1,15.9,S,Third,child,False,,Southampton,yes,False 351 | 0,3,male,42.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 352 | 0,3,male,23.0,0,0,9.225,S,Third,man,True,,Southampton,no,True 353 | 0,1,male,,0,0,35.0,S,First,man,True,C,Southampton,no,True 354 | 0,3,male,15.0,1,1,7.2292,C,Third,child,False,,Cherbourg,no,False 355 | 0,3,male,25.0,1,0,17.8,S,Third,man,True,,Southampton,no,False 356 | 0,3,male,,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 357 | 0,3,male,28.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 358 | 1,1,female,22.0,0,1,55.0,S,First,woman,False,E,Southampton,yes,False 359 | 0,2,female,38.0,0,0,13.0,S,Second,woman,False,,Southampton,no,True 360 | 1,3,female,,0,0,7.8792,Q,Third,woman,False,,Queenstown,yes,True 361 | 1,3,female,,0,0,7.8792,Q,Third,woman,False,,Queenstown,yes,True 362 | 0,3,male,40.0,1,4,27.9,S,Third,man,True,,Southampton,no,False 363 | 0,2,male,29.0,1,0,27.7208,C,Second,man,True,,Cherbourg,no,False 364 | 0,3,female,45.0,0,1,14.4542,C,Third,woman,False,,Cherbourg,no,False 365 | 0,3,male,35.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 366 | 0,3,male,,1,0,15.5,Q,Third,man,True,,Queenstown,no,False 367 | 0,3,male,30.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 368 | 1,1,female,60.0,1,0,75.25,C,First,woman,False,D,Cherbourg,yes,False 369 | 1,3,female,,0,0,7.2292,C,Third,woman,False,,Cherbourg,yes,True 370 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 371 | 1,1,female,24.0,0,0,69.3,C,First,woman,False,B,Cherbourg,yes,True 372 | 1,1,male,25.0,1,0,55.4417,C,First,man,True,E,Cherbourg,yes,False 373 | 0,3,male,18.0,1,0,6.4958,S,Third,man,True,,Southampton,no,False 374 | 0,3,male,19.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 375 | 0,1,male,22.0,0,0,135.6333,C,First,man,True,,Cherbourg,no,True 376 | 0,3,female,3.0,3,1,21.075,S,Third,child,False,,Southampton,no,False 377 | 1,1,female,,1,0,82.1708,C,First,woman,False,,Cherbourg,yes,False 378 | 1,3,female,22.0,0,0,7.25,S,Third,woman,False,,Southampton,yes,True 379 | 0,1,male,27.0,0,2,211.5,C,First,man,True,C,Cherbourg,no,False 380 | 0,3,male,20.0,0,0,4.0125,C,Third,man,True,,Cherbourg,no,True 381 | 0,3,male,19.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 382 | 1,1,female,42.0,0,0,227.525,C,First,woman,False,,Cherbourg,yes,True 383 | 1,3,female,1.0,0,2,15.7417,C,Third,child,False,,Cherbourg,yes,False 384 | 0,3,male,32.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 385 | 1,1,female,35.0,1,0,52.0,S,First,woman,False,,Southampton,yes,False 386 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 387 | 0,2,male,18.0,0,0,73.5,S,Second,man,True,,Southampton,no,True 388 | 0,3,male,1.0,5,2,46.9,S,Third,child,False,,Southampton,no,False 389 | 1,2,female,36.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 390 | 0,3,male,,0,0,7.7292,Q,Third,man,True,,Queenstown,no,True 391 | 1,2,female,17.0,0,0,12.0,C,Second,woman,False,,Cherbourg,yes,True 392 | 1,1,male,36.0,1,2,120.0,S,First,man,True,B,Southampton,yes,False 393 | 1,3,male,21.0,0,0,7.7958,S,Third,man,True,,Southampton,yes,True 394 | 0,3,male,28.0,2,0,7.925,S,Third,man,True,,Southampton,no,False 395 | 1,1,female,23.0,1,0,113.275,C,First,woman,False,D,Cherbourg,yes,False 396 | 1,3,female,24.0,0,2,16.7,S,Third,woman,False,G,Southampton,yes,False 397 | 0,3,male,22.0,0,0,7.7958,S,Third,man,True,,Southampton,no,True 398 | 0,3,female,31.0,0,0,7.8542,S,Third,woman,False,,Southampton,no,True 399 | 0,2,male,46.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 400 | 0,2,male,23.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 401 | 1,2,female,28.0,0,0,12.65,S,Second,woman,False,,Southampton,yes,True 402 | 1,3,male,39.0,0,0,7.925,S,Third,man,True,,Southampton,yes,True 403 | 0,3,male,26.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 404 | 0,3,female,21.0,1,0,9.825,S,Third,woman,False,,Southampton,no,False 405 | 0,3,male,28.0,1,0,15.85,S,Third,man,True,,Southampton,no,False 406 | 0,3,female,20.0,0,0,8.6625,S,Third,woman,False,,Southampton,no,True 407 | 0,2,male,34.0,1,0,21.0,S,Second,man,True,,Southampton,no,False 408 | 0,3,male,51.0,0,0,7.75,S,Third,man,True,,Southampton,no,True 409 | 1,2,male,3.0,1,1,18.75,S,Second,child,False,,Southampton,yes,False 410 | 0,3,male,21.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 411 | 0,3,female,,3,1,25.4667,S,Third,woman,False,,Southampton,no,False 412 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 413 | 0,3,male,,0,0,6.8583,Q,Third,man,True,,Queenstown,no,True 414 | 1,1,female,33.0,1,0,90.0,Q,First,woman,False,C,Queenstown,yes,False 415 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 416 | 1,3,male,44.0,0,0,7.925,S,Third,man,True,,Southampton,yes,True 417 | 0,3,female,,0,0,8.05,S,Third,woman,False,,Southampton,no,True 418 | 1,2,female,34.0,1,1,32.5,S,Second,woman,False,,Southampton,yes,False 419 | 1,2,female,18.0,0,2,13.0,S,Second,woman,False,,Southampton,yes,False 420 | 0,2,male,30.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 421 | 0,3,female,10.0,0,2,24.15,S,Third,child,False,,Southampton,no,False 422 | 0,3,male,,0,0,7.8958,C,Third,man,True,,Cherbourg,no,True 423 | 0,3,male,21.0,0,0,7.7333,Q,Third,man,True,,Queenstown,no,True 424 | 0,3,male,29.0,0,0,7.875,S,Third,man,True,,Southampton,no,True 425 | 0,3,female,28.0,1,1,14.4,S,Third,woman,False,,Southampton,no,False 426 | 0,3,male,18.0,1,1,20.2125,S,Third,man,True,,Southampton,no,False 427 | 0,3,male,,0,0,7.25,S,Third,man,True,,Southampton,no,True 428 | 1,2,female,28.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 429 | 1,2,female,19.0,0,0,26.0,S,Second,woman,False,,Southampton,yes,True 430 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 431 | 1,3,male,32.0,0,0,8.05,S,Third,man,True,E,Southampton,yes,True 432 | 1,1,male,28.0,0,0,26.55,S,First,man,True,C,Southampton,yes,True 433 | 1,3,female,,1,0,16.1,S,Third,woman,False,,Southampton,yes,False 434 | 1,2,female,42.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 435 | 0,3,male,17.0,0,0,7.125,S,Third,man,True,,Southampton,no,True 436 | 0,1,male,50.0,1,0,55.9,S,First,man,True,E,Southampton,no,False 437 | 1,1,female,14.0,1,2,120.0,S,First,child,False,B,Southampton,yes,False 438 | 0,3,female,21.0,2,2,34.375,S,Third,woman,False,,Southampton,no,False 439 | 1,2,female,24.0,2,3,18.75,S,Second,woman,False,,Southampton,yes,False 440 | 0,1,male,64.0,1,4,263.0,S,First,man,True,C,Southampton,no,False 441 | 0,2,male,31.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 442 | 1,2,female,45.0,1,1,26.25,S,Second,woman,False,,Southampton,yes,False 443 | 0,3,male,20.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 444 | 0,3,male,25.0,1,0,7.775,S,Third,man,True,,Southampton,no,False 445 | 1,2,female,28.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 446 | 1,3,male,,0,0,8.1125,S,Third,man,True,,Southampton,yes,True 447 | 1,1,male,4.0,0,2,81.8583,S,First,child,False,A,Southampton,yes,False 448 | 1,2,female,13.0,0,1,19.5,S,Second,child,False,,Southampton,yes,False 449 | 1,1,male,34.0,0,0,26.55,S,First,man,True,,Southampton,yes,True 450 | 1,3,female,5.0,2,1,19.2583,C,Third,child,False,,Cherbourg,yes,False 451 | 1,1,male,52.0,0,0,30.5,S,First,man,True,C,Southampton,yes,True 452 | 0,2,male,36.0,1,2,27.75,S,Second,man,True,,Southampton,no,False 453 | 0,3,male,,1,0,19.9667,S,Third,man,True,,Southampton,no,False 454 | 0,1,male,30.0,0,0,27.75,C,First,man,True,C,Cherbourg,no,True 455 | 1,1,male,49.0,1,0,89.1042,C,First,man,True,C,Cherbourg,yes,False 456 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 457 | 1,3,male,29.0,0,0,7.8958,C,Third,man,True,,Cherbourg,yes,True 458 | 0,1,male,65.0,0,0,26.55,S,First,man,True,E,Southampton,no,True 459 | 1,1,female,,1,0,51.8625,S,First,woman,False,D,Southampton,yes,False 460 | 1,2,female,50.0,0,0,10.5,S,Second,woman,False,,Southampton,yes,True 461 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 462 | 1,1,male,48.0,0,0,26.55,S,First,man,True,E,Southampton,yes,True 463 | 0,3,male,34.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 464 | 0,1,male,47.0,0,0,38.5,S,First,man,True,E,Southampton,no,True 465 | 0,2,male,48.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 466 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 467 | 0,3,male,38.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 468 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 469 | 0,1,male,56.0,0,0,26.55,S,First,man,True,,Southampton,no,True 470 | 0,3,male,,0,0,7.725,Q,Third,man,True,,Queenstown,no,True 471 | 1,3,female,0.75,2,1,19.2583,C,Third,child,False,,Cherbourg,yes,False 472 | 0,3,male,,0,0,7.25,S,Third,man,True,,Southampton,no,True 473 | 0,3,male,38.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 474 | 1,2,female,33.0,1,2,27.75,S,Second,woman,False,,Southampton,yes,False 475 | 1,2,female,23.0,0,0,13.7917,C,Second,woman,False,D,Cherbourg,yes,True 476 | 0,3,female,22.0,0,0,9.8375,S,Third,woman,False,,Southampton,no,True 477 | 0,1,male,,0,0,52.0,S,First,man,True,A,Southampton,no,True 478 | 0,2,male,34.0,1,0,21.0,S,Second,man,True,,Southampton,no,False 479 | 0,3,male,29.0,1,0,7.0458,S,Third,man,True,,Southampton,no,False 480 | 0,3,male,22.0,0,0,7.5208,S,Third,man,True,,Southampton,no,True 481 | 1,3,female,2.0,0,1,12.2875,S,Third,child,False,,Southampton,yes,False 482 | 0,3,male,9.0,5,2,46.9,S,Third,child,False,,Southampton,no,False 483 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 484 | 0,3,male,50.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 485 | 1,3,female,63.0,0,0,9.5875,S,Third,woman,False,,Southampton,yes,True 486 | 1,1,male,25.0,1,0,91.0792,C,First,man,True,B,Cherbourg,yes,False 487 | 0,3,female,,3,1,25.4667,S,Third,woman,False,,Southampton,no,False 488 | 1,1,female,35.0,1,0,90.0,S,First,woman,False,C,Southampton,yes,False 489 | 0,1,male,58.0,0,0,29.7,C,First,man,True,B,Cherbourg,no,True 490 | 0,3,male,30.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 491 | 1,3,male,9.0,1,1,15.9,S,Third,child,False,,Southampton,yes,False 492 | 0,3,male,,1,0,19.9667,S,Third,man,True,,Southampton,no,False 493 | 0,3,male,21.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 494 | 0,1,male,55.0,0,0,30.5,S,First,man,True,C,Southampton,no,True 495 | 0,1,male,71.0,0,0,49.5042,C,First,man,True,,Cherbourg,no,True 496 | 0,3,male,21.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 497 | 0,3,male,,0,0,14.4583,C,Third,man,True,,Cherbourg,no,True 498 | 1,1,female,54.0,1,0,78.2667,C,First,woman,False,D,Cherbourg,yes,False 499 | 0,3,male,,0,0,15.1,S,Third,man,True,,Southampton,no,True 500 | 0,1,female,25.0,1,2,151.55,S,First,woman,False,C,Southampton,no,False 501 | 0,3,male,24.0,0,0,7.7958,S,Third,man,True,,Southampton,no,True 502 | 0,3,male,17.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 503 | 0,3,female,21.0,0,0,7.75,Q,Third,woman,False,,Queenstown,no,True 504 | 0,3,female,,0,0,7.6292,Q,Third,woman,False,,Queenstown,no,True 505 | 0,3,female,37.0,0,0,9.5875,S,Third,woman,False,,Southampton,no,True 506 | 1,1,female,16.0,0,0,86.5,S,First,woman,False,B,Southampton,yes,True 507 | 0,1,male,18.0,1,0,108.9,C,First,man,True,C,Cherbourg,no,False 508 | 1,2,female,33.0,0,2,26.0,S,Second,woman,False,,Southampton,yes,False 509 | 1,1,male,,0,0,26.55,S,First,man,True,,Southampton,yes,True 510 | 0,3,male,28.0,0,0,22.525,S,Third,man,True,,Southampton,no,True 511 | 1,3,male,26.0,0,0,56.4958,S,Third,man,True,,Southampton,yes,True 512 | 1,3,male,29.0,0,0,7.75,Q,Third,man,True,,Queenstown,yes,True 513 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 514 | 1,1,male,36.0,0,0,26.2875,S,First,man,True,E,Southampton,yes,True 515 | 1,1,female,54.0,1,0,59.4,C,First,woman,False,,Cherbourg,yes,False 516 | 0,3,male,24.0,0,0,7.4958,S,Third,man,True,,Southampton,no,True 517 | 0,1,male,47.0,0,0,34.0208,S,First,man,True,D,Southampton,no,True 518 | 1,2,female,34.0,0,0,10.5,S,Second,woman,False,F,Southampton,yes,True 519 | 0,3,male,,0,0,24.15,Q,Third,man,True,,Queenstown,no,True 520 | 1,2,female,36.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 521 | 0,3,male,32.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 522 | 1,1,female,30.0,0,0,93.5,S,First,woman,False,B,Southampton,yes,True 523 | 0,3,male,22.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 524 | 0,3,male,,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 525 | 1,1,female,44.0,0,1,57.9792,C,First,woman,False,B,Cherbourg,yes,False 526 | 0,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 527 | 0,3,male,40.5,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 528 | 1,2,female,50.0,0,0,10.5,S,Second,woman,False,,Southampton,yes,True 529 | 0,1,male,,0,0,221.7792,S,First,man,True,C,Southampton,no,True 530 | 0,3,male,39.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 531 | 0,2,male,23.0,2,1,11.5,S,Second,man,True,,Southampton,no,False 532 | 1,2,female,2.0,1,1,26.0,S,Second,child,False,,Southampton,yes,False 533 | 0,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 534 | 0,3,male,17.0,1,1,7.2292,C,Third,man,True,,Cherbourg,no,False 535 | 1,3,female,,0,2,22.3583,C,Third,woman,False,,Cherbourg,yes,False 536 | 0,3,female,30.0,0,0,8.6625,S,Third,woman,False,,Southampton,no,True 537 | 1,2,female,7.0,0,2,26.25,S,Second,child,False,,Southampton,yes,False 538 | 0,1,male,45.0,0,0,26.55,S,First,man,True,B,Southampton,no,True 539 | 1,1,female,30.0,0,0,106.425,C,First,woman,False,,Cherbourg,yes,True 540 | 0,3,male,,0,0,14.5,S,Third,man,True,,Southampton,no,True 541 | 1,1,female,22.0,0,2,49.5,C,First,woman,False,B,Cherbourg,yes,False 542 | 1,1,female,36.0,0,2,71.0,S,First,woman,False,B,Southampton,yes,False 543 | 0,3,female,9.0,4,2,31.275,S,Third,child,False,,Southampton,no,False 544 | 0,3,female,11.0,4,2,31.275,S,Third,child,False,,Southampton,no,False 545 | 1,2,male,32.0,1,0,26.0,S,Second,man,True,,Southampton,yes,False 546 | 0,1,male,50.0,1,0,106.425,C,First,man,True,C,Cherbourg,no,False 547 | 0,1,male,64.0,0,0,26.0,S,First,man,True,,Southampton,no,True 548 | 1,2,female,19.0,1,0,26.0,S,Second,woman,False,,Southampton,yes,False 549 | 1,2,male,,0,0,13.8625,C,Second,man,True,,Cherbourg,yes,True 550 | 0,3,male,33.0,1,1,20.525,S,Third,man,True,,Southampton,no,False 551 | 1,2,male,8.0,1,1,36.75,S,Second,child,False,,Southampton,yes,False 552 | 1,1,male,17.0,0,2,110.8833,C,First,man,True,C,Cherbourg,yes,False 553 | 0,2,male,27.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 554 | 0,3,male,,0,0,7.8292,Q,Third,man,True,,Queenstown,no,True 555 | 1,3,male,22.0,0,0,7.225,C,Third,man,True,,Cherbourg,yes,True 556 | 1,3,female,22.0,0,0,7.775,S,Third,woman,False,,Southampton,yes,True 557 | 0,1,male,62.0,0,0,26.55,S,First,man,True,,Southampton,no,True 558 | 1,1,female,48.0,1,0,39.6,C,First,woman,False,A,Cherbourg,yes,False 559 | 0,1,male,,0,0,227.525,C,First,man,True,,Cherbourg,no,True 560 | 1,1,female,39.0,1,1,79.65,S,First,woman,False,E,Southampton,yes,False 561 | 1,3,female,36.0,1,0,17.4,S,Third,woman,False,,Southampton,yes,False 562 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 563 | 0,3,male,40.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 564 | 0,2,male,28.0,0,0,13.5,S,Second,man,True,,Southampton,no,True 565 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 566 | 0,3,female,,0,0,8.05,S,Third,woman,False,,Southampton,no,True 567 | 0,3,male,24.0,2,0,24.15,S,Third,man,True,,Southampton,no,False 568 | 0,3,male,19.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 569 | 0,3,female,29.0,0,4,21.075,S,Third,woman,False,,Southampton,no,False 570 | 0,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 571 | 1,3,male,32.0,0,0,7.8542,S,Third,man,True,,Southampton,yes,True 572 | 1,2,male,62.0,0,0,10.5,S,Second,man,True,,Southampton,yes,True 573 | 1,1,female,53.0,2,0,51.4792,S,First,woman,False,C,Southampton,yes,False 574 | 1,1,male,36.0,0,0,26.3875,S,First,man,True,E,Southampton,yes,True 575 | 1,3,female,,0,0,7.75,Q,Third,woman,False,,Queenstown,yes,True 576 | 0,3,male,16.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 577 | 0,3,male,19.0,0,0,14.5,S,Third,man,True,,Southampton,no,True 578 | 1,2,female,34.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 579 | 1,1,female,39.0,1,0,55.9,S,First,woman,False,E,Southampton,yes,False 580 | 0,3,female,,1,0,14.4583,C,Third,woman,False,,Cherbourg,no,False 581 | 1,3,male,32.0,0,0,7.925,S,Third,man,True,,Southampton,yes,True 582 | 1,2,female,25.0,1,1,30.0,S,Second,woman,False,,Southampton,yes,False 583 | 1,1,female,39.0,1,1,110.8833,C,First,woman,False,C,Cherbourg,yes,False 584 | 0,2,male,54.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 585 | 0,1,male,36.0,0,0,40.125,C,First,man,True,A,Cherbourg,no,True 586 | 0,3,male,,0,0,8.7125,C,Third,man,True,,Cherbourg,no,True 587 | 1,1,female,18.0,0,2,79.65,S,First,woman,False,E,Southampton,yes,False 588 | 0,2,male,47.0,0,0,15.0,S,Second,man,True,,Southampton,no,True 589 | 1,1,male,60.0,1,1,79.2,C,First,man,True,B,Cherbourg,yes,False 590 | 0,3,male,22.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 591 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 592 | 0,3,male,35.0,0,0,7.125,S,Third,man,True,,Southampton,no,True 593 | 1,1,female,52.0,1,0,78.2667,C,First,woman,False,D,Cherbourg,yes,False 594 | 0,3,male,47.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 595 | 0,3,female,,0,2,7.75,Q,Third,woman,False,,Queenstown,no,False 596 | 0,2,male,37.0,1,0,26.0,S,Second,man,True,,Southampton,no,False 597 | 0,3,male,36.0,1,1,24.15,S,Third,man,True,,Southampton,no,False 598 | 1,2,female,,0,0,33.0,S,Second,woman,False,,Southampton,yes,True 599 | 0,3,male,49.0,0,0,0.0,S,Third,man,True,,Southampton,no,True 600 | 0,3,male,,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 601 | 1,1,male,49.0,1,0,56.9292,C,First,man,True,A,Cherbourg,yes,False 602 | 1,2,female,24.0,2,1,27.0,S,Second,woman,False,,Southampton,yes,False 603 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 604 | 0,1,male,,0,0,42.4,S,First,man,True,,Southampton,no,True 605 | 0,3,male,44.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 606 | 1,1,male,35.0,0,0,26.55,C,First,man,True,,Cherbourg,yes,True 607 | 0,3,male,36.0,1,0,15.55,S,Third,man,True,,Southampton,no,False 608 | 0,3,male,30.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 609 | 1,1,male,27.0,0,0,30.5,S,First,man,True,,Southampton,yes,True 610 | 1,2,female,22.0,1,2,41.5792,C,Second,woman,False,,Cherbourg,yes,False 611 | 1,1,female,40.0,0,0,153.4625,S,First,woman,False,C,Southampton,yes,True 612 | 0,3,female,39.0,1,5,31.275,S,Third,woman,False,,Southampton,no,False 613 | 0,3,male,,0,0,7.05,S,Third,man,True,,Southampton,no,True 614 | 1,3,female,,1,0,15.5,Q,Third,woman,False,,Queenstown,yes,False 615 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 616 | 0,3,male,35.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 617 | 1,2,female,24.0,1,2,65.0,S,Second,woman,False,,Southampton,yes,False 618 | 0,3,male,34.0,1,1,14.4,S,Third,man,True,,Southampton,no,False 619 | 0,3,female,26.0,1,0,16.1,S,Third,woman,False,,Southampton,no,False 620 | 1,2,female,4.0,2,1,39.0,S,Second,child,False,F,Southampton,yes,False 621 | 0,2,male,26.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 622 | 0,3,male,27.0,1,0,14.4542,C,Third,man,True,,Cherbourg,no,False 623 | 1,1,male,42.0,1,0,52.5542,S,First,man,True,D,Southampton,yes,False 624 | 1,3,male,20.0,1,1,15.7417,C,Third,man,True,,Cherbourg,yes,False 625 | 0,3,male,21.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 626 | 0,3,male,21.0,0,0,16.1,S,Third,man,True,,Southampton,no,True 627 | 0,1,male,61.0,0,0,32.3208,S,First,man,True,D,Southampton,no,True 628 | 0,2,male,57.0,0,0,12.35,Q,Second,man,True,,Queenstown,no,True 629 | 1,1,female,21.0,0,0,77.9583,S,First,woman,False,D,Southampton,yes,True 630 | 0,3,male,26.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 631 | 0,3,male,,0,0,7.7333,Q,Third,man,True,,Queenstown,no,True 632 | 1,1,male,80.0,0,0,30.0,S,First,man,True,A,Southampton,yes,True 633 | 0,3,male,51.0,0,0,7.0542,S,Third,man,True,,Southampton,no,True 634 | 1,1,male,32.0,0,0,30.5,C,First,man,True,B,Cherbourg,yes,True 635 | 0,1,male,,0,0,0.0,S,First,man,True,,Southampton,no,True 636 | 0,3,female,9.0,3,2,27.9,S,Third,child,False,,Southampton,no,False 637 | 1,2,female,28.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 638 | 0,3,male,32.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 639 | 0,2,male,31.0,1,1,26.25,S,Second,man,True,,Southampton,no,False 640 | 0,3,female,41.0,0,5,39.6875,S,Third,woman,False,,Southampton,no,False 641 | 0,3,male,,1,0,16.1,S,Third,man,True,,Southampton,no,False 642 | 0,3,male,20.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 643 | 1,1,female,24.0,0,0,69.3,C,First,woman,False,B,Cherbourg,yes,True 644 | 0,3,female,2.0,3,2,27.9,S,Third,child,False,,Southampton,no,False 645 | 1,3,male,,0,0,56.4958,S,Third,man,True,,Southampton,yes,True 646 | 1,3,female,0.75,2,1,19.2583,C,Third,child,False,,Cherbourg,yes,False 647 | 1,1,male,48.0,1,0,76.7292,C,First,man,True,D,Cherbourg,yes,False 648 | 0,3,male,19.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 649 | 1,1,male,56.0,0,0,35.5,C,First,man,True,A,Cherbourg,yes,True 650 | 0,3,male,,0,0,7.55,S,Third,man,True,,Southampton,no,True 651 | 1,3,female,23.0,0,0,7.55,S,Third,woman,False,,Southampton,yes,True 652 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 653 | 1,2,female,18.0,0,1,23.0,S,Second,woman,False,,Southampton,yes,False 654 | 0,3,male,21.0,0,0,8.4333,S,Third,man,True,,Southampton,no,True 655 | 1,3,female,,0,0,7.8292,Q,Third,woman,False,,Queenstown,yes,True 656 | 0,3,female,18.0,0,0,6.75,Q,Third,woman,False,,Queenstown,no,True 657 | 0,2,male,24.0,2,0,73.5,S,Second,man,True,,Southampton,no,False 658 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 659 | 0,3,female,32.0,1,1,15.5,Q,Third,woman,False,,Queenstown,no,False 660 | 0,2,male,23.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 661 | 0,1,male,58.0,0,2,113.275,C,First,man,True,D,Cherbourg,no,False 662 | 1,1,male,50.0,2,0,133.65,S,First,man,True,,Southampton,yes,False 663 | 0,3,male,40.0,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 664 | 0,1,male,47.0,0,0,25.5875,S,First,man,True,E,Southampton,no,True 665 | 0,3,male,36.0,0,0,7.4958,S,Third,man,True,,Southampton,no,True 666 | 1,3,male,20.0,1,0,7.925,S,Third,man,True,,Southampton,yes,False 667 | 0,2,male,32.0,2,0,73.5,S,Second,man,True,,Southampton,no,False 668 | 0,2,male,25.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 669 | 0,3,male,,0,0,7.775,S,Third,man,True,,Southampton,no,True 670 | 0,3,male,43.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 671 | 1,1,female,,1,0,52.0,S,First,woman,False,C,Southampton,yes,False 672 | 1,2,female,40.0,1,1,39.0,S,Second,woman,False,,Southampton,yes,False 673 | 0,1,male,31.0,1,0,52.0,S,First,man,True,B,Southampton,no,False 674 | 0,2,male,70.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 675 | 1,2,male,31.0,0,0,13.0,S,Second,man,True,,Southampton,yes,True 676 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 677 | 0,3,male,18.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 678 | 0,3,male,24.5,0,0,8.05,S,Third,man,True,,Southampton,no,True 679 | 1,3,female,18.0,0,0,9.8417,S,Third,woman,False,,Southampton,yes,True 680 | 0,3,female,43.0,1,6,46.9,S,Third,woman,False,,Southampton,no,False 681 | 1,1,male,36.0,0,1,512.3292,C,First,man,True,B,Cherbourg,yes,False 682 | 0,3,female,,0,0,8.1375,Q,Third,woman,False,,Queenstown,no,True 683 | 1,1,male,27.0,0,0,76.7292,C,First,man,True,D,Cherbourg,yes,True 684 | 0,3,male,20.0,0,0,9.225,S,Third,man,True,,Southampton,no,True 685 | 0,3,male,14.0,5,2,46.9,S,Third,child,False,,Southampton,no,False 686 | 0,2,male,60.0,1,1,39.0,S,Second,man,True,,Southampton,no,False 687 | 0,2,male,25.0,1,2,41.5792,C,Second,man,True,,Cherbourg,no,False 688 | 0,3,male,14.0,4,1,39.6875,S,Third,child,False,,Southampton,no,False 689 | 0,3,male,19.0,0,0,10.1708,S,Third,man,True,,Southampton,no,True 690 | 0,3,male,18.0,0,0,7.7958,S,Third,man,True,,Southampton,no,True 691 | 1,1,female,15.0,0,1,211.3375,S,First,child,False,B,Southampton,yes,False 692 | 1,1,male,31.0,1,0,57.0,S,First,man,True,B,Southampton,yes,False 693 | 1,3,female,4.0,0,1,13.4167,C,Third,child,False,,Cherbourg,yes,False 694 | 1,3,male,,0,0,56.4958,S,Third,man,True,,Southampton,yes,True 695 | 0,3,male,25.0,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 696 | 0,1,male,60.0,0,0,26.55,S,First,man,True,,Southampton,no,True 697 | 0,2,male,52.0,0,0,13.5,S,Second,man,True,,Southampton,no,True 698 | 0,3,male,44.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 699 | 1,3,female,,0,0,7.7333,Q,Third,woman,False,,Queenstown,yes,True 700 | 0,1,male,49.0,1,1,110.8833,C,First,man,True,C,Cherbourg,no,False 701 | 0,3,male,42.0,0,0,7.65,S,Third,man,True,F,Southampton,no,True 702 | 1,1,female,18.0,1,0,227.525,C,First,woman,False,C,Cherbourg,yes,False 703 | 1,1,male,35.0,0,0,26.2875,S,First,man,True,E,Southampton,yes,True 704 | 0,3,female,18.0,0,1,14.4542,C,Third,woman,False,,Cherbourg,no,False 705 | 0,3,male,25.0,0,0,7.7417,Q,Third,man,True,,Queenstown,no,True 706 | 0,3,male,26.0,1,0,7.8542,S,Third,man,True,,Southampton,no,False 707 | 0,2,male,39.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 708 | 1,2,female,45.0,0,0,13.5,S,Second,woman,False,,Southampton,yes,True 709 | 1,1,male,42.0,0,0,26.2875,S,First,man,True,E,Southampton,yes,True 710 | 1,1,female,22.0,0,0,151.55,S,First,woman,False,,Southampton,yes,True 711 | 1,3,male,,1,1,15.2458,C,Third,man,True,,Cherbourg,yes,False 712 | 1,1,female,24.0,0,0,49.5042,C,First,woman,False,C,Cherbourg,yes,True 713 | 0,1,male,,0,0,26.55,S,First,man,True,C,Southampton,no,True 714 | 1,1,male,48.0,1,0,52.0,S,First,man,True,C,Southampton,yes,False 715 | 0,3,male,29.0,0,0,9.4833,S,Third,man,True,,Southampton,no,True 716 | 0,2,male,52.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 717 | 0,3,male,19.0,0,0,7.65,S,Third,man,True,F,Southampton,no,True 718 | 1,1,female,38.0,0,0,227.525,C,First,woman,False,C,Cherbourg,yes,True 719 | 1,2,female,27.0,0,0,10.5,S,Second,woman,False,E,Southampton,yes,True 720 | 0,3,male,,0,0,15.5,Q,Third,man,True,,Queenstown,no,True 721 | 0,3,male,33.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 722 | 1,2,female,6.0,0,1,33.0,S,Second,child,False,,Southampton,yes,False 723 | 0,3,male,17.0,1,0,7.0542,S,Third,man,True,,Southampton,no,False 724 | 0,2,male,34.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 725 | 0,2,male,50.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 726 | 1,1,male,27.0,1,0,53.1,S,First,man,True,E,Southampton,yes,False 727 | 0,3,male,20.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 728 | 1,2,female,30.0,3,0,21.0,S,Second,woman,False,,Southampton,yes,False 729 | 1,3,female,,0,0,7.7375,Q,Third,woman,False,,Queenstown,yes,True 730 | 0,2,male,25.0,1,0,26.0,S,Second,man,True,,Southampton,no,False 731 | 0,3,female,25.0,1,0,7.925,S,Third,woman,False,,Southampton,no,False 732 | 1,1,female,29.0,0,0,211.3375,S,First,woman,False,B,Southampton,yes,True 733 | 0,3,male,11.0,0,0,18.7875,C,Third,child,False,,Cherbourg,no,True 734 | 0,2,male,,0,0,0.0,S,Second,man,True,,Southampton,no,True 735 | 0,2,male,23.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 736 | 0,2,male,23.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 737 | 0,3,male,28.5,0,0,16.1,S,Third,man,True,,Southampton,no,True 738 | 0,3,female,48.0,1,3,34.375,S,Third,woman,False,,Southampton,no,False 739 | 1,1,male,35.0,0,0,512.3292,C,First,man,True,B,Cherbourg,yes,True 740 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 741 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 742 | 1,1,male,,0,0,30.0,S,First,man,True,D,Southampton,yes,True 743 | 0,1,male,36.0,1,0,78.85,S,First,man,True,C,Southampton,no,False 744 | 1,1,female,21.0,2,2,262.375,C,First,woman,False,B,Cherbourg,yes,False 745 | 0,3,male,24.0,1,0,16.1,S,Third,man,True,,Southampton,no,False 746 | 1,3,male,31.0,0,0,7.925,S,Third,man,True,,Southampton,yes,True 747 | 0,1,male,70.0,1,1,71.0,S,First,man,True,B,Southampton,no,False 748 | 0,3,male,16.0,1,1,20.25,S,Third,man,True,,Southampton,no,False 749 | 1,2,female,30.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 750 | 0,1,male,19.0,1,0,53.1,S,First,man,True,D,Southampton,no,False 751 | 0,3,male,31.0,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 752 | 1,2,female,4.0,1,1,23.0,S,Second,child,False,,Southampton,yes,False 753 | 1,3,male,6.0,0,1,12.475,S,Third,child,False,E,Southampton,yes,False 754 | 0,3,male,33.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 755 | 0,3,male,23.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 756 | 1,2,female,48.0,1,2,65.0,S,Second,woman,False,,Southampton,yes,False 757 | 1,2,male,0.67,1,1,14.5,S,Second,child,False,,Southampton,yes,False 758 | 0,3,male,28.0,0,0,7.7958,S,Third,man,True,,Southampton,no,True 759 | 0,2,male,18.0,0,0,11.5,S,Second,man,True,,Southampton,no,True 760 | 0,3,male,34.0,0,0,8.05,S,Third,man,True,,Southampton,no,True 761 | 1,1,female,33.0,0,0,86.5,S,First,woman,False,B,Southampton,yes,True 762 | 0,3,male,,0,0,14.5,S,Third,man,True,,Southampton,no,True 763 | 0,3,male,41.0,0,0,7.125,S,Third,man,True,,Southampton,no,True 764 | 1,3,male,20.0,0,0,7.2292,C,Third,man,True,,Cherbourg,yes,True 765 | 1,1,female,36.0,1,2,120.0,S,First,woman,False,B,Southampton,yes,False 766 | 0,3,male,16.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 767 | 1,1,female,51.0,1,0,77.9583,S,First,woman,False,D,Southampton,yes,False 768 | 0,1,male,,0,0,39.6,C,First,man,True,,Cherbourg,no,True 769 | 0,3,female,30.5,0,0,7.75,Q,Third,woman,False,,Queenstown,no,True 770 | 0,3,male,,1,0,24.15,Q,Third,man,True,,Queenstown,no,False 771 | 0,3,male,32.0,0,0,8.3625,S,Third,man,True,,Southampton,no,True 772 | 0,3,male,24.0,0,0,9.5,S,Third,man,True,,Southampton,no,True 773 | 0,3,male,48.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 774 | 0,2,female,57.0,0,0,10.5,S,Second,woman,False,E,Southampton,no,True 775 | 0,3,male,,0,0,7.225,C,Third,man,True,,Cherbourg,no,True 776 | 1,2,female,54.0,1,3,23.0,S,Second,woman,False,,Southampton,yes,False 777 | 0,3,male,18.0,0,0,7.75,S,Third,man,True,,Southampton,no,True 778 | 0,3,male,,0,0,7.75,Q,Third,man,True,F,Queenstown,no,True 779 | 1,3,female,5.0,0,0,12.475,S,Third,child,False,,Southampton,yes,True 780 | 0,3,male,,0,0,7.7375,Q,Third,man,True,,Queenstown,no,True 781 | 1,1,female,43.0,0,1,211.3375,S,First,woman,False,B,Southampton,yes,False 782 | 1,3,female,13.0,0,0,7.2292,C,Third,child,False,,Cherbourg,yes,True 783 | 1,1,female,17.0,1,0,57.0,S,First,woman,False,B,Southampton,yes,False 784 | 0,1,male,29.0,0,0,30.0,S,First,man,True,D,Southampton,no,True 785 | 0,3,male,,1,2,23.45,S,Third,man,True,,Southampton,no,False 786 | 0,3,male,25.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 787 | 0,3,male,25.0,0,0,7.25,S,Third,man,True,,Southampton,no,True 788 | 1,3,female,18.0,0,0,7.4958,S,Third,woman,False,,Southampton,yes,True 789 | 0,3,male,8.0,4,1,29.125,Q,Third,child,False,,Queenstown,no,False 790 | 1,3,male,1.0,1,2,20.575,S,Third,child,False,,Southampton,yes,False 791 | 0,1,male,46.0,0,0,79.2,C,First,man,True,B,Cherbourg,no,True 792 | 0,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 793 | 0,2,male,16.0,0,0,26.0,S,Second,man,True,,Southampton,no,True 794 | 0,3,female,,8,2,69.55,S,Third,woman,False,,Southampton,no,False 795 | 0,1,male,,0,0,30.6958,C,First,man,True,,Cherbourg,no,True 796 | 0,3,male,25.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 797 | 0,2,male,39.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 798 | 1,1,female,49.0,0,0,25.9292,S,First,woman,False,D,Southampton,yes,True 799 | 1,3,female,31.0,0,0,8.6833,S,Third,woman,False,,Southampton,yes,True 800 | 0,3,male,30.0,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 801 | 0,3,female,30.0,1,1,24.15,S,Third,woman,False,,Southampton,no,False 802 | 0,2,male,34.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 803 | 1,2,female,31.0,1,1,26.25,S,Second,woman,False,,Southampton,yes,False 804 | 1,1,male,11.0,1,2,120.0,S,First,child,False,B,Southampton,yes,False 805 | 1,3,male,0.42,0,1,8.5167,C,Third,child,False,,Cherbourg,yes,False 806 | 1,3,male,27.0,0,0,6.975,S,Third,man,True,,Southampton,yes,True 807 | 0,3,male,31.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 808 | 0,1,male,39.0,0,0,0.0,S,First,man,True,A,Southampton,no,True 809 | 0,3,female,18.0,0,0,7.775,S,Third,woman,False,,Southampton,no,True 810 | 0,2,male,39.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 811 | 1,1,female,33.0,1,0,53.1,S,First,woman,False,E,Southampton,yes,False 812 | 0,3,male,26.0,0,0,7.8875,S,Third,man,True,,Southampton,no,True 813 | 0,3,male,39.0,0,0,24.15,S,Third,man,True,,Southampton,no,True 814 | 0,2,male,35.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 815 | 0,3,female,6.0,4,2,31.275,S,Third,child,False,,Southampton,no,False 816 | 0,3,male,30.5,0,0,8.05,S,Third,man,True,,Southampton,no,True 817 | 0,1,male,,0,0,0.0,S,First,man,True,B,Southampton,no,True 818 | 0,3,female,23.0,0,0,7.925,S,Third,woman,False,,Southampton,no,True 819 | 0,2,male,31.0,1,1,37.0042,C,Second,man,True,,Cherbourg,no,False 820 | 0,3,male,43.0,0,0,6.45,S,Third,man,True,,Southampton,no,True 821 | 0,3,male,10.0,3,2,27.9,S,Third,child,False,,Southampton,no,False 822 | 1,1,female,52.0,1,1,93.5,S,First,woman,False,B,Southampton,yes,False 823 | 1,3,male,27.0,0,0,8.6625,S,Third,man,True,,Southampton,yes,True 824 | 0,1,male,38.0,0,0,0.0,S,First,man,True,,Southampton,no,True 825 | 1,3,female,27.0,0,1,12.475,S,Third,woman,False,E,Southampton,yes,False 826 | 0,3,male,2.0,4,1,39.6875,S,Third,child,False,,Southampton,no,False 827 | 0,3,male,,0,0,6.95,Q,Third,man,True,,Queenstown,no,True 828 | 0,3,male,,0,0,56.4958,S,Third,man,True,,Southampton,no,True 829 | 1,2,male,1.0,0,2,37.0042,C,Second,child,False,,Cherbourg,yes,False 830 | 1,3,male,,0,0,7.75,Q,Third,man,True,,Queenstown,yes,True 831 | 1,1,female,62.0,0,0,80.0,,First,woman,False,B,,yes,True 832 | 1,3,female,15.0,1,0,14.4542,C,Third,child,False,,Cherbourg,yes,False 833 | 1,2,male,0.83,1,1,18.75,S,Second,child,False,,Southampton,yes,False 834 | 0,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 835 | 0,3,male,23.0,0,0,7.8542,S,Third,man,True,,Southampton,no,True 836 | 0,3,male,18.0,0,0,8.3,S,Third,man,True,,Southampton,no,True 837 | 1,1,female,39.0,1,1,83.1583,C,First,woman,False,E,Cherbourg,yes,False 838 | 0,3,male,21.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 839 | 0,3,male,,0,0,8.05,S,Third,man,True,,Southampton,no,True 840 | 1,3,male,32.0,0,0,56.4958,S,Third,man,True,,Southampton,yes,True 841 | 1,1,male,,0,0,29.7,C,First,man,True,C,Cherbourg,yes,True 842 | 0,3,male,20.0,0,0,7.925,S,Third,man,True,,Southampton,no,True 843 | 0,2,male,16.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 844 | 1,1,female,30.0,0,0,31.0,C,First,woman,False,,Cherbourg,yes,True 845 | 0,3,male,34.5,0,0,6.4375,C,Third,man,True,,Cherbourg,no,True 846 | 0,3,male,17.0,0,0,8.6625,S,Third,man,True,,Southampton,no,True 847 | 0,3,male,42.0,0,0,7.55,S,Third,man,True,,Southampton,no,True 848 | 0,3,male,,8,2,69.55,S,Third,man,True,,Southampton,no,False 849 | 0,3,male,35.0,0,0,7.8958,C,Third,man,True,,Cherbourg,no,True 850 | 0,2,male,28.0,0,1,33.0,S,Second,man,True,,Southampton,no,False 851 | 1,1,female,,1,0,89.1042,C,First,woman,False,C,Cherbourg,yes,False 852 | 0,3,male,4.0,4,2,31.275,S,Third,child,False,,Southampton,no,False 853 | 0,3,male,74.0,0,0,7.775,S,Third,man,True,,Southampton,no,True 854 | 0,3,female,9.0,1,1,15.2458,C,Third,child,False,,Cherbourg,no,False 855 | 1,1,female,16.0,0,1,39.4,S,First,woman,False,D,Southampton,yes,False 856 | 0,2,female,44.0,1,0,26.0,S,Second,woman,False,,Southampton,no,False 857 | 1,3,female,18.0,0,1,9.35,S,Third,woman,False,,Southampton,yes,False 858 | 1,1,female,45.0,1,1,164.8667,S,First,woman,False,,Southampton,yes,False 859 | 1,1,male,51.0,0,0,26.55,S,First,man,True,E,Southampton,yes,True 860 | 1,3,female,24.0,0,3,19.2583,C,Third,woman,False,,Cherbourg,yes,False 861 | 0,3,male,,0,0,7.2292,C,Third,man,True,,Cherbourg,no,True 862 | 0,3,male,41.0,2,0,14.1083,S,Third,man,True,,Southampton,no,False 863 | 0,2,male,21.0,1,0,11.5,S,Second,man,True,,Southampton,no,False 864 | 1,1,female,48.0,0,0,25.9292,S,First,woman,False,D,Southampton,yes,True 865 | 0,3,female,,8,2,69.55,S,Third,woman,False,,Southampton,no,False 866 | 0,2,male,24.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 867 | 1,2,female,42.0,0,0,13.0,S,Second,woman,False,,Southampton,yes,True 868 | 1,2,female,27.0,1,0,13.8583,C,Second,woman,False,,Cherbourg,yes,False 869 | 0,1,male,31.0,0,0,50.4958,S,First,man,True,A,Southampton,no,True 870 | 0,3,male,,0,0,9.5,S,Third,man,True,,Southampton,no,True 871 | 1,3,male,4.0,1,1,11.1333,S,Third,child,False,,Southampton,yes,False 872 | 0,3,male,26.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 873 | 1,1,female,47.0,1,1,52.5542,S,First,woman,False,D,Southampton,yes,False 874 | 0,1,male,33.0,0,0,5.0,S,First,man,True,B,Southampton,no,True 875 | 0,3,male,47.0,0,0,9.0,S,Third,man,True,,Southampton,no,True 876 | 1,2,female,28.0,1,0,24.0,C,Second,woman,False,,Cherbourg,yes,False 877 | 1,3,female,15.0,0,0,7.225,C,Third,child,False,,Cherbourg,yes,True 878 | 0,3,male,20.0,0,0,9.8458,S,Third,man,True,,Southampton,no,True 879 | 0,3,male,19.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 880 | 0,3,male,,0,0,7.8958,S,Third,man,True,,Southampton,no,True 881 | 1,1,female,56.0,0,1,83.1583,C,First,woman,False,C,Cherbourg,yes,False 882 | 1,2,female,25.0,0,1,26.0,S,Second,woman,False,,Southampton,yes,False 883 | 0,3,male,33.0,0,0,7.8958,S,Third,man,True,,Southampton,no,True 884 | 0,3,female,22.0,0,0,10.5167,S,Third,woman,False,,Southampton,no,True 885 | 0,2,male,28.0,0,0,10.5,S,Second,man,True,,Southampton,no,True 886 | 0,3,male,25.0,0,0,7.05,S,Third,man,True,,Southampton,no,True 887 | 0,3,female,39.0,0,5,29.125,Q,Third,woman,False,,Queenstown,no,False 888 | 0,2,male,27.0,0,0,13.0,S,Second,man,True,,Southampton,no,True 889 | 1,1,female,19.0,0,0,30.0,S,First,woman,False,B,Southampton,yes,True 890 | 0,3,female,,1,2,23.45,S,Third,woman,False,,Southampton,no,False 891 | 1,1,male,26.0,0,0,30.0,C,First,man,True,C,Cherbourg,yes,True 892 | 0,3,male,32.0,0,0,7.75,Q,Third,man,True,,Queenstown,no,True 893 | -------------------------------------------------------------------------------- /data_science_basics/BasicPythonSupport/uforeports_excel.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/data_science_basics/BasicPythonSupport/uforeports_excel.xls -------------------------------------------------------------------------------- /lecture_10/adspy_shared_utilities.py: -------------------------------------------------------------------------------- 1 | # version 1.0 2 | 3 | import numpy 4 | import pandas as pd 5 | import seaborn as sn 6 | import matplotlib.pyplot as plt 7 | import matplotlib.cm as cm 8 | from matplotlib.colors import ListedColormap, BoundaryNorm 9 | from sklearn import neighbors 10 | import matplotlib.patches as mpatches 11 | import graphviz 12 | from sklearn.tree import export_graphviz 13 | import matplotlib.patches as mpatches 14 | 15 | def load_crime_dataset(): 16 | # Communities and Crime dataset for regression 17 | # https://archive.ics.uci.edu/ml/datasets/Communities+and+Crime+Unnormalized 18 | 19 | crime = pd.read_table('CommViolPredUnnormalizedData.txt', sep=',', na_values='?') 20 | # remove features with poor coverage or lower relevance, and keep ViolentCrimesPerPop target column 21 | columns_to_keep = [5, 6] + list(range(11,26)) + list(range(32, 103)) + [145] 22 | crime = crime.ix[:,columns_to_keep].dropna() 23 | 24 | X_crime = crime.ix[:,range(0,88)] 25 | y_crime = crime['ViolentCrimesPerPop'] 26 | 27 | return (X_crime, y_crime) 28 | 29 | def plot_decision_tree(clf, feature_names, class_names): 30 | # This function requires the pydotplus module and assumes it's been installed. 31 | # In some cases (typically under Windows) even after running conda install, there is a problem where the 32 | # pydotplus module is not found when running from within the notebook environment. The following code 33 | # may help to guarantee the module is installed in the current notebook environment directory. 34 | # 35 | # import sys; sys.executable 36 | # !{sys.executable} -m pip install pydotplus 37 | 38 | export_graphviz(clf, out_file="readonly/adspy_temp.dot", feature_names=feature_names, class_names=class_names, filled = True, impurity = False) 39 | with open("readonly/adspy_temp.dot") as f: 40 | dot_graph = f.read() 41 | # Alternate method using pydotplus, if installed. 42 | # graph = pydotplus.graphviz.graph_from_dot_data(dot_graph) 43 | # return graph.create_png() 44 | return graphviz.Source(dot_graph) 45 | 46 | def plot_feature_importances(clf, feature_names): 47 | c_features = len(feature_names) 48 | plt.barh(range(c_features), clf.feature_importances_) 49 | plt.xlabel("Feature importance") 50 | plt.ylabel("Feature name") 51 | plt.yticks(numpy.arange(c_features), feature_names) 52 | 53 | def plot_labelled_scatter(X, y, class_labels): 54 | num_labels = len(class_labels) 55 | 56 | x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1 57 | y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1 58 | 59 | marker_array = ['o', '^', '*'] 60 | color_array = ['#FFFF00', '#00AAFF', '#000000', '#FF00AA'] 61 | cmap_bold = ListedColormap(color_array) 62 | bnorm = BoundaryNorm(numpy.arange(0, num_labels + 1, 1), ncolors=num_labels) 63 | plt.figure() 64 | 65 | plt.scatter(X[:, 0], X[:, 1], s=65, c=y, cmap=cmap_bold, norm = bnorm, alpha = 0.40, edgecolor='black', lw = 1) 66 | 67 | plt.xlim(x_min, x_max) 68 | plt.ylim(y_min, y_max) 69 | 70 | h = [] 71 | for c in range(0, num_labels): 72 | h.append(mpatches.Patch(color=color_array[c], label=class_labels[c])) 73 | plt.legend(handles=h) 74 | 75 | plt.show() 76 | 77 | 78 | def plot_class_regions_for_classifier_subplot(clf, X, y, X_test, y_test, title, subplot, target_names = None, plot_decision_regions = True): 79 | 80 | numClasses = numpy.amax(y) + 1 81 | color_list_light = ['#FFFFAA', '#EFEFEF', '#AAFFAA', '#AAAAFF'] 82 | color_list_bold = ['#EEEE00', '#000000', '#00CC00', '#0000CC'] 83 | cmap_light = ListedColormap(color_list_light[0:numClasses]) 84 | cmap_bold = ListedColormap(color_list_bold[0:numClasses]) 85 | 86 | h = 0.03 87 | k = 0.5 88 | x_plot_adjust = 0.1 89 | y_plot_adjust = 0.1 90 | plot_symbol_size = 50 91 | 92 | x_min = X[:, 0].min() 93 | x_max = X[:, 0].max() 94 | y_min = X[:, 1].min() 95 | y_max = X[:, 1].max() 96 | x2, y2 = numpy.meshgrid(numpy.arange(x_min-k, x_max+k, h), numpy.arange(y_min-k, y_max+k, h)) 97 | 98 | P = clf.predict(numpy.c_[x2.ravel(), y2.ravel()]) 99 | P = P.reshape(x2.shape) 100 | 101 | if plot_decision_regions: 102 | subplot.contourf(x2, y2, P, cmap=cmap_light, alpha = 0.8) 103 | 104 | subplot.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold, s=plot_symbol_size, edgecolor = 'black') 105 | subplot.set_xlim(x_min - x_plot_adjust, x_max + x_plot_adjust) 106 | subplot.set_ylim(y_min - y_plot_adjust, y_max + y_plot_adjust) 107 | 108 | if (X_test is not None): 109 | subplot.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cmap_bold, s=plot_symbol_size, marker='^', edgecolor = 'black') 110 | train_score = clf.score(X, y) 111 | test_score = clf.score(X_test, y_test) 112 | title = title + "\nTrain score = {:.2f}, Test score = {:.2f}".format(train_score, test_score) 113 | 114 | subplot.set_title(title) 115 | 116 | if (target_names is not None): 117 | legend_handles = [] 118 | for i in range(0, len(target_names)): 119 | patch = mpatches.Patch(color=color_list_bold[i], label=target_names[i]) 120 | legend_handles.append(patch) 121 | subplot.legend(loc=0, handles=legend_handles) 122 | 123 | 124 | def plot_class_regions_for_classifier(clf, X, y, X_test=None, y_test=None, title=None, target_names = None, plot_decision_regions = True): 125 | 126 | numClasses = numpy.amax(y) + 1 127 | color_list_light = ['#FFFFAA', '#EFEFEF', '#AAFFAA', '#AAAAFF'] 128 | color_list_bold = ['#EEEE00', '#000000', '#00CC00', '#0000CC'] 129 | cmap_light = ListedColormap(color_list_light[0:numClasses]) 130 | cmap_bold = ListedColormap(color_list_bold[0:numClasses]) 131 | 132 | h = 0.03 133 | k = 0.5 134 | x_plot_adjust = 0.1 135 | y_plot_adjust = 0.1 136 | plot_symbol_size = 50 137 | 138 | x_min = X[:, 0].min() 139 | x_max = X[:, 0].max() 140 | y_min = X[:, 1].min() 141 | y_max = X[:, 1].max() 142 | x2, y2 = numpy.meshgrid(numpy.arange(x_min-k, x_max+k, h), numpy.arange(y_min-k, y_max+k, h)) 143 | 144 | P = clf.predict(numpy.c_[x2.ravel(), y2.ravel()]) 145 | P = P.reshape(x2.shape) 146 | plt.figure() 147 | if plot_decision_regions: 148 | plt.contourf(x2, y2, P, cmap=cmap_light, alpha = 0.8) 149 | 150 | plt.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold, s=plot_symbol_size, edgecolor = 'black') 151 | plt.xlim(x_min - x_plot_adjust, x_max + x_plot_adjust) 152 | plt.ylim(y_min - y_plot_adjust, y_max + y_plot_adjust) 153 | 154 | if (X_test is not None): 155 | plt.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cmap_bold, s=plot_symbol_size, marker='^', edgecolor = 'black') 156 | train_score = clf.score(X, y) 157 | test_score = clf.score(X_test, y_test) 158 | title = title + "\nTrain score = {:.2f}, Test score = {:.2f}".format(train_score, test_score) 159 | 160 | if (target_names is not None): 161 | legend_handles = [] 162 | for i in range(0, len(target_names)): 163 | patch = mpatches.Patch(color=color_list_bold[i], label=target_names[i]) 164 | legend_handles.append(patch) 165 | plt.legend(loc=0, handles=legend_handles) 166 | 167 | if (title is not None): 168 | plt.title(title) 169 | plt.show() 170 | 171 | def plot_fruit_knn(X, y, n_neighbors, weights): 172 | X_mat = X[['height', 'width']].as_matrix() 173 | y_mat = y.as_matrix() 174 | 175 | # Create color maps 176 | cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#AAAAFF','#AFAFAF']) 177 | cmap_bold = ListedColormap(['#FF0000', '#00FF00', '#0000FF','#AFAFAF']) 178 | 179 | clf = neighbors.KNeighborsClassifier(n_neighbors, weights=weights) 180 | clf.fit(X_mat, y_mat) 181 | 182 | # Plot the decision boundary by assigning a color in the color map 183 | # to each mesh point. 184 | 185 | mesh_step_size = .01 # step size in the mesh 186 | plot_symbol_size = 50 187 | 188 | x_min, x_max = X_mat[:, 0].min() - 1, X_mat[:, 0].max() + 1 189 | y_min, y_max = X_mat[:, 1].min() - 1, X_mat[:, 1].max() + 1 190 | xx, yy = numpy.meshgrid(numpy.arange(x_min, x_max, mesh_step_size), 191 | numpy.arange(y_min, y_max, mesh_step_size)) 192 | Z = clf.predict(numpy.c_[xx.ravel(), yy.ravel()]) 193 | 194 | # Put the result into a color plot 195 | Z = Z.reshape(xx.shape) 196 | plt.figure() 197 | plt.pcolormesh(xx, yy, Z, cmap=cmap_light) 198 | 199 | # Plot training points 200 | plt.scatter(X_mat[:, 0], X_mat[:, 1], s=plot_symbol_size, c=y, cmap=cmap_bold, edgecolor = 'black') 201 | plt.xlim(xx.min(), xx.max()) 202 | plt.ylim(yy.min(), yy.max()) 203 | 204 | patch0 = mpatches.Patch(color='#FF0000', label='apple') 205 | patch1 = mpatches.Patch(color='#00FF00', label='mandarin') 206 | patch2 = mpatches.Patch(color='#0000FF', label='orange') 207 | patch3 = mpatches.Patch(color='#AFAFAF', label='lemon') 208 | plt.legend(handles=[patch0, patch1, patch2, patch3]) 209 | 210 | 211 | plt.xlabel('height (cm)') 212 | plt.ylabel('width (cm)') 213 | 214 | plt.show() 215 | 216 | def plot_two_class_knn(X, y, n_neighbors, weights, X_test, y_test): 217 | X_mat = X 218 | y_mat = y 219 | 220 | # Create color maps 221 | cmap_light = ListedColormap(['#FFFFAA', '#AAFFAA', '#AAAAFF','#EFEFEF']) 222 | cmap_bold = ListedColormap(['#FFFF00', '#00FF00', '#0000FF','#000000']) 223 | 224 | clf = neighbors.KNeighborsClassifier(n_neighbors, weights=weights) 225 | clf.fit(X_mat, y_mat) 226 | 227 | # Plot the decision boundary by assigning a color in the color map 228 | # to each mesh point. 229 | 230 | mesh_step_size = .01 # step size in the mesh 231 | plot_symbol_size = 50 232 | 233 | x_min, x_max = X_mat[:, 0].min() - 1, X_mat[:, 0].max() + 1 234 | y_min, y_max = X_mat[:, 1].min() - 1, X_mat[:, 1].max() + 1 235 | xx, yy = numpy.meshgrid(numpy.arange(x_min, x_max, mesh_step_size), 236 | numpy.arange(y_min, y_max, mesh_step_size)) 237 | Z = clf.predict(numpy.c_[xx.ravel(), yy.ravel()]) 238 | 239 | # Put the result into a color plot 240 | Z = Z.reshape(xx.shape) 241 | plt.figure() 242 | plt.pcolormesh(xx, yy, Z, cmap=cmap_light) 243 | 244 | # Plot training points 245 | plt.scatter(X_mat[:, 0], X_mat[:, 1], s=plot_symbol_size, c=y, cmap=cmap_bold, edgecolor = 'black') 246 | plt.xlim(xx.min(), xx.max()) 247 | plt.ylim(yy.min(), yy.max()) 248 | 249 | title = "Neighbors = {}".format(n_neighbors) 250 | if (X_test is not None): 251 | train_score = clf.score(X_mat, y_mat) 252 | test_score = clf.score(X_test, y_test) 253 | title = title + "\nTrain score = {:.2f}, Test score = {:.2f}".format(train_score, test_score) 254 | 255 | patch0 = mpatches.Patch(color='#FFFF00', label='class 0') 256 | patch1 = mpatches.Patch(color='#000000', label='class 1') 257 | plt.legend(handles=[patch0, patch1]) 258 | 259 | plt.xlabel('Feature 0') 260 | plt.ylabel('Feature 1') 261 | plt.title(title) 262 | 263 | plt.show() 264 | -------------------------------------------------------------------------------- /lecture_10/fruit_data_with_colors.txt: -------------------------------------------------------------------------------- 1 | fruit_label fruit_name fruit_subtype mass width height color_score 2 | 1 apple granny_smith 192 8.4 7.3 0.55 3 | 1 apple granny_smith 180 8.0 6.8 0.59 4 | 1 apple granny_smith 176 7.4 7.2 0.60 5 | 2 mandarin mandarin 86 6.2 4.7 0.80 6 | 2 mandarin mandarin 84 6.0 4.6 0.79 7 | 2 mandarin mandarin 80 5.8 4.3 0.77 8 | 2 mandarin mandarin 80 5.9 4.3 0.81 9 | 2 mandarin mandarin 76 5.8 4.0 0.81 10 | 1 apple braeburn 178 7.1 7.8 0.92 11 | 1 apple braeburn 172 7.4 7.0 0.89 12 | 1 apple braeburn 166 6.9 7.3 0.93 13 | 1 apple braeburn 172 7.1 7.6 0.92 14 | 1 apple braeburn 154 7.0 7.1 0.88 15 | 1 apple golden_delicious 164 7.3 7.7 0.70 16 | 1 apple golden_delicious 152 7.6 7.3 0.69 17 | 1 apple golden_delicious 156 7.7 7.1 0.69 18 | 1 apple golden_delicious 156 7.6 7.5 0.67 19 | 1 apple golden_delicious 168 7.5 7.6 0.73 20 | 1 apple cripps_pink 162 7.5 7.1 0.83 21 | 1 apple cripps_pink 162 7.4 7.2 0.85 22 | 1 apple cripps_pink 160 7.5 7.5 0.86 23 | 1 apple cripps_pink 156 7.4 7.4 0.84 24 | 1 apple cripps_pink 140 7.3 7.1 0.87 25 | 1 apple cripps_pink 170 7.6 7.9 0.88 26 | 3 orange spanish_jumbo 342 9.0 9.4 0.75 27 | 3 orange spanish_jumbo 356 9.2 9.2 0.75 28 | 3 orange spanish_jumbo 362 9.6 9.2 0.74 29 | 3 orange selected_seconds 204 7.5 9.2 0.77 30 | 3 orange selected_seconds 140 6.7 7.1 0.72 31 | 3 orange selected_seconds 160 7.0 7.4 0.81 32 | 3 orange selected_seconds 158 7.1 7.5 0.79 33 | 3 orange selected_seconds 210 7.8 8.0 0.82 34 | 3 orange selected_seconds 164 7.2 7.0 0.80 35 | 3 orange turkey_navel 190 7.5 8.1 0.74 36 | 3 orange turkey_navel 142 7.6 7.8 0.75 37 | 3 orange turkey_navel 150 7.1 7.9 0.75 38 | 3 orange turkey_navel 160 7.1 7.6 0.76 39 | 3 orange turkey_navel 154 7.3 7.3 0.79 40 | 3 orange turkey_navel 158 7.2 7.8 0.77 41 | 3 orange turkey_navel 144 6.8 7.4 0.75 42 | 3 orange turkey_navel 154 7.1 7.5 0.78 43 | 3 orange turkey_navel 180 7.6 8.2 0.79 44 | 3 orange turkey_navel 154 7.2 7.2 0.82 45 | 4 lemon spanish_belsan 194 7.2 10.3 0.70 46 | 4 lemon spanish_belsan 200 7.3 10.5 0.72 47 | 4 lemon spanish_belsan 186 7.2 9.2 0.72 48 | 4 lemon spanish_belsan 216 7.3 10.2 0.71 49 | 4 lemon spanish_belsan 196 7.3 9.7 0.72 50 | 4 lemon spanish_belsan 174 7.3 10.1 0.72 51 | 4 lemon unknown 132 5.8 8.7 0.73 52 | 4 lemon unknown 130 6.0 8.2 0.71 53 | 4 lemon unknown 116 6.0 7.5 0.72 54 | 4 lemon unknown 118 5.9 8.0 0.72 55 | 4 lemon unknown 120 6.0 8.4 0.74 56 | 4 lemon unknown 116 6.1 8.5 0.71 57 | 4 lemon unknown 116 6.3 7.7 0.72 58 | 4 lemon unknown 116 5.9 8.1 0.73 59 | 4 lemon unknown 152 6.5 8.5 0.72 60 | 4 lemon unknown 118 6.1 8.1 0.70 61 | -------------------------------------------------------------------------------- /lecture_10/wine_data.csv: -------------------------------------------------------------------------------- 1 | 1,14.23,1.71,2.43,15.6,127,2.8,3.06,.28,2.29,5.64,1.04,3.92,1065 2 | 1,13.2,1.78,2.14,11.2,100,2.65,2.76,.26,1.28,4.38,1.05,3.4,1050 3 | 1,13.16,2.36,2.67,18.6,101,2.8,3.24,.3,2.81,5.68,1.03,3.17,1185 4 | 1,14.37,1.95,2.5,16.8,113,3.85,3.49,.24,2.18,7.8,.86,3.45,1480 5 | 1,13.24,2.59,2.87,21,118,2.8,2.69,.39,1.82,4.32,1.04,2.93,735 6 | 1,14.2,1.76,2.45,15.2,112,3.27,3.39,.34,1.97,6.75,1.05,2.85,1450 7 | 1,14.39,1.87,2.45,14.6,96,2.5,2.52,.3,1.98,5.25,1.02,3.58,1290 8 | 1,14.06,2.15,2.61,17.6,121,2.6,2.51,.31,1.25,5.05,1.06,3.58,1295 9 | 1,14.83,1.64,2.17,14,97,2.8,2.98,.29,1.98,5.2,1.08,2.85,1045 10 | 1,13.86,1.35,2.27,16,98,2.98,3.15,.22,1.85,7.22,1.01,3.55,1045 11 | 1,14.1,2.16,2.3,18,105,2.95,3.32,.22,2.38,5.75,1.25,3.17,1510 12 | 1,14.12,1.48,2.32,16.8,95,2.2,2.43,.26,1.57,5,1.17,2.82,1280 13 | 1,13.75,1.73,2.41,16,89,2.6,2.76,.29,1.81,5.6,1.15,2.9,1320 14 | 1,14.75,1.73,2.39,11.4,91,3.1,3.69,.43,2.81,5.4,1.25,2.73,1150 15 | 1,14.38,1.87,2.38,12,102,3.3,3.64,.29,2.96,7.5,1.2,3,1547 16 | 1,13.63,1.81,2.7,17.2,112,2.85,2.91,.3,1.46,7.3,1.28,2.88,1310 17 | 1,14.3,1.92,2.72,20,120,2.8,3.14,.33,1.97,6.2,1.07,2.65,1280 18 | 1,13.83,1.57,2.62,20,115,2.95,3.4,.4,1.72,6.6,1.13,2.57,1130 19 | 1,14.19,1.59,2.48,16.5,108,3.3,3.93,.32,1.86,8.7,1.23,2.82,1680 20 | 1,13.64,3.1,2.56,15.2,116,2.7,3.03,.17,1.66,5.1,.96,3.36,845 21 | 1,14.06,1.63,2.28,16,126,3,3.17,.24,2.1,5.65,1.09,3.71,780 22 | 1,12.93,3.8,2.65,18.6,102,2.41,2.41,.25,1.98,4.5,1.03,3.52,770 23 | 1,13.71,1.86,2.36,16.6,101,2.61,2.88,.27,1.69,3.8,1.11,4,1035 24 | 1,12.85,1.6,2.52,17.8,95,2.48,2.37,.26,1.46,3.93,1.09,3.63,1015 25 | 1,13.5,1.81,2.61,20,96,2.53,2.61,.28,1.66,3.52,1.12,3.82,845 26 | 1,13.05,2.05,3.22,25,124,2.63,2.68,.47,1.92,3.58,1.13,3.2,830 27 | 1,13.39,1.77,2.62,16.1,93,2.85,2.94,.34,1.45,4.8,.92,3.22,1195 28 | 1,13.3,1.72,2.14,17,94,2.4,2.19,.27,1.35,3.95,1.02,2.77,1285 29 | 1,13.87,1.9,2.8,19.4,107,2.95,2.97,.37,1.76,4.5,1.25,3.4,915 30 | 1,14.02,1.68,2.21,16,96,2.65,2.33,.26,1.98,4.7,1.04,3.59,1035 31 | 1,13.73,1.5,2.7,22.5,101,3,3.25,.29,2.38,5.7,1.19,2.71,1285 32 | 1,13.58,1.66,2.36,19.1,106,2.86,3.19,.22,1.95,6.9,1.09,2.88,1515 33 | 1,13.68,1.83,2.36,17.2,104,2.42,2.69,.42,1.97,3.84,1.23,2.87,990 34 | 1,13.76,1.53,2.7,19.5,132,2.95,2.74,.5,1.35,5.4,1.25,3,1235 35 | 1,13.51,1.8,2.65,19,110,2.35,2.53,.29,1.54,4.2,1.1,2.87,1095 36 | 1,13.48,1.81,2.41,20.5,100,2.7,2.98,.26,1.86,5.1,1.04,3.47,920 37 | 1,13.28,1.64,2.84,15.5,110,2.6,2.68,.34,1.36,4.6,1.09,2.78,880 38 | 1,13.05,1.65,2.55,18,98,2.45,2.43,.29,1.44,4.25,1.12,2.51,1105 39 | 1,13.07,1.5,2.1,15.5,98,2.4,2.64,.28,1.37,3.7,1.18,2.69,1020 40 | 1,14.22,3.99,2.51,13.2,128,3,3.04,.2,2.08,5.1,.89,3.53,760 41 | 1,13.56,1.71,2.31,16.2,117,3.15,3.29,.34,2.34,6.13,.95,3.38,795 42 | 1,13.41,3.84,2.12,18.8,90,2.45,2.68,.27,1.48,4.28,.91,3,1035 43 | 1,13.88,1.89,2.59,15,101,3.25,3.56,.17,1.7,5.43,.88,3.56,1095 44 | 1,13.24,3.98,2.29,17.5,103,2.64,2.63,.32,1.66,4.36,.82,3,680 45 | 1,13.05,1.77,2.1,17,107,3,3,.28,2.03,5.04,.88,3.35,885 46 | 1,14.21,4.04,2.44,18.9,111,2.85,2.65,.3,1.25,5.24,.87,3.33,1080 47 | 1,14.38,3.59,2.28,16,102,3.25,3.17,.27,2.19,4.9,1.04,3.44,1065 48 | 1,13.9,1.68,2.12,16,101,3.1,3.39,.21,2.14,6.1,.91,3.33,985 49 | 1,14.1,2.02,2.4,18.8,103,2.75,2.92,.32,2.38,6.2,1.07,2.75,1060 50 | 1,13.94,1.73,2.27,17.4,108,2.88,3.54,.32,2.08,8.90,1.12,3.1,1260 51 | 1,13.05,1.73,2.04,12.4,92,2.72,3.27,.17,2.91,7.2,1.12,2.91,1150 52 | 1,13.83,1.65,2.6,17.2,94,2.45,2.99,.22,2.29,5.6,1.24,3.37,1265 53 | 1,13.82,1.75,2.42,14,111,3.88,3.74,.32,1.87,7.05,1.01,3.26,1190 54 | 1,13.77,1.9,2.68,17.1,115,3,2.79,.39,1.68,6.3,1.13,2.93,1375 55 | 1,13.74,1.67,2.25,16.4,118,2.6,2.9,.21,1.62,5.85,.92,3.2,1060 56 | 1,13.56,1.73,2.46,20.5,116,2.96,2.78,.2,2.45,6.25,.98,3.03,1120 57 | 1,14.22,1.7,2.3,16.3,118,3.2,3,.26,2.03,6.38,.94,3.31,970 58 | 1,13.29,1.97,2.68,16.8,102,3,3.23,.31,1.66,6,1.07,2.84,1270 59 | 1,13.72,1.43,2.5,16.7,108,3.4,3.67,.19,2.04,6.8,.89,2.87,1285 60 | 2,12.37,.94,1.36,10.6,88,1.98,.57,.28,.42,1.95,1.05,1.82,520 61 | 2,12.33,1.1,2.28,16,101,2.05,1.09,.63,.41,3.27,1.25,1.67,680 62 | 2,12.64,1.36,2.02,16.8,100,2.02,1.41,.53,.62,5.75,.98,1.59,450 63 | 2,13.67,1.25,1.92,18,94,2.1,1.79,.32,.73,3.8,1.23,2.46,630 64 | 2,12.37,1.13,2.16,19,87,3.5,3.1,.19,1.87,4.45,1.22,2.87,420 65 | 2,12.17,1.45,2.53,19,104,1.89,1.75,.45,1.03,2.95,1.45,2.23,355 66 | 2,12.37,1.21,2.56,18.1,98,2.42,2.65,.37,2.08,4.6,1.19,2.3,678 67 | 2,13.11,1.01,1.7,15,78,2.98,3.18,.26,2.28,5.3,1.12,3.18,502 68 | 2,12.37,1.17,1.92,19.6,78,2.11,2,.27,1.04,4.68,1.12,3.48,510 69 | 2,13.34,.94,2.36,17,110,2.53,1.3,.55,.42,3.17,1.02,1.93,750 70 | 2,12.21,1.19,1.75,16.8,151,1.85,1.28,.14,2.5,2.85,1.28,3.07,718 71 | 2,12.29,1.61,2.21,20.4,103,1.1,1.02,.37,1.46,3.05,.906,1.82,870 72 | 2,13.86,1.51,2.67,25,86,2.95,2.86,.21,1.87,3.38,1.36,3.16,410 73 | 2,13.49,1.66,2.24,24,87,1.88,1.84,.27,1.03,3.74,.98,2.78,472 74 | 2,12.99,1.67,2.6,30,139,3.3,2.89,.21,1.96,3.35,1.31,3.5,985 75 | 2,11.96,1.09,2.3,21,101,3.38,2.14,.13,1.65,3.21,.99,3.13,886 76 | 2,11.66,1.88,1.92,16,97,1.61,1.57,.34,1.15,3.8,1.23,2.14,428 77 | 2,13.03,.9,1.71,16,86,1.95,2.03,.24,1.46,4.6,1.19,2.48,392 78 | 2,11.84,2.89,2.23,18,112,1.72,1.32,.43,.95,2.65,.96,2.52,500 79 | 2,12.33,.99,1.95,14.8,136,1.9,1.85,.35,2.76,3.4,1.06,2.31,750 80 | 2,12.7,3.87,2.4,23,101,2.83,2.55,.43,1.95,2.57,1.19,3.13,463 81 | 2,12,.92,2,19,86,2.42,2.26,.3,1.43,2.5,1.38,3.12,278 82 | 2,12.72,1.81,2.2,18.8,86,2.2,2.53,.26,1.77,3.9,1.16,3.14,714 83 | 2,12.08,1.13,2.51,24,78,2,1.58,.4,1.4,2.2,1.31,2.72,630 84 | 2,13.05,3.86,2.32,22.5,85,1.65,1.59,.61,1.62,4.8,.84,2.01,515 85 | 2,11.84,.89,2.58,18,94,2.2,2.21,.22,2.35,3.05,.79,3.08,520 86 | 2,12.67,.98,2.24,18,99,2.2,1.94,.3,1.46,2.62,1.23,3.16,450 87 | 2,12.16,1.61,2.31,22.8,90,1.78,1.69,.43,1.56,2.45,1.33,2.26,495 88 | 2,11.65,1.67,2.62,26,88,1.92,1.61,.4,1.34,2.6,1.36,3.21,562 89 | 2,11.64,2.06,2.46,21.6,84,1.95,1.69,.48,1.35,2.8,1,2.75,680 90 | 2,12.08,1.33,2.3,23.6,70,2.2,1.59,.42,1.38,1.74,1.07,3.21,625 91 | 2,12.08,1.83,2.32,18.5,81,1.6,1.5,.52,1.64,2.4,1.08,2.27,480 92 | 2,12,1.51,2.42,22,86,1.45,1.25,.5,1.63,3.6,1.05,2.65,450 93 | 2,12.69,1.53,2.26,20.7,80,1.38,1.46,.58,1.62,3.05,.96,2.06,495 94 | 2,12.29,2.83,2.22,18,88,2.45,2.25,.25,1.99,2.15,1.15,3.3,290 95 | 2,11.62,1.99,2.28,18,98,3.02,2.26,.17,1.35,3.25,1.16,2.96,345 96 | 2,12.47,1.52,2.2,19,162,2.5,2.27,.32,3.28,2.6,1.16,2.63,937 97 | 2,11.81,2.12,2.74,21.5,134,1.6,.99,.14,1.56,2.5,.95,2.26,625 98 | 2,12.29,1.41,1.98,16,85,2.55,2.5,.29,1.77,2.9,1.23,2.74,428 99 | 2,12.37,1.07,2.1,18.5,88,3.52,3.75,.24,1.95,4.5,1.04,2.77,660 100 | 2,12.29,3.17,2.21,18,88,2.85,2.99,.45,2.81,2.3,1.42,2.83,406 101 | 2,12.08,2.08,1.7,17.5,97,2.23,2.17,.26,1.4,3.3,1.27,2.96,710 102 | 2,12.6,1.34,1.9,18.5,88,1.45,1.36,.29,1.35,2.45,1.04,2.77,562 103 | 2,12.34,2.45,2.46,21,98,2.56,2.11,.34,1.31,2.8,.8,3.38,438 104 | 2,11.82,1.72,1.88,19.5,86,2.5,1.64,.37,1.42,2.06,.94,2.44,415 105 | 2,12.51,1.73,1.98,20.5,85,2.2,1.92,.32,1.48,2.94,1.04,3.57,672 106 | 2,12.42,2.55,2.27,22,90,1.68,1.84,.66,1.42,2.7,.86,3.3,315 107 | 2,12.25,1.73,2.12,19,80,1.65,2.03,.37,1.63,3.4,1,3.17,510 108 | 2,12.72,1.75,2.28,22.5,84,1.38,1.76,.48,1.63,3.3,.88,2.42,488 109 | 2,12.22,1.29,1.94,19,92,2.36,2.04,.39,2.08,2.7,.86,3.02,312 110 | 2,11.61,1.35,2.7,20,94,2.74,2.92,.29,2.49,2.65,.96,3.26,680 111 | 2,11.46,3.74,1.82,19.5,107,3.18,2.58,.24,3.58,2.9,.75,2.81,562 112 | 2,12.52,2.43,2.17,21,88,2.55,2.27,.26,1.22,2,.9,2.78,325 113 | 2,11.76,2.68,2.92,20,103,1.75,2.03,.6,1.05,3.8,1.23,2.5,607 114 | 2,11.41,.74,2.5,21,88,2.48,2.01,.42,1.44,3.08,1.1,2.31,434 115 | 2,12.08,1.39,2.5,22.5,84,2.56,2.29,.43,1.04,2.9,.93,3.19,385 116 | 2,11.03,1.51,2.2,21.5,85,2.46,2.17,.52,2.01,1.9,1.71,2.87,407 117 | 2,11.82,1.47,1.99,20.8,86,1.98,1.6,.3,1.53,1.95,.95,3.33,495 118 | 2,12.42,1.61,2.19,22.5,108,2,2.09,.34,1.61,2.06,1.06,2.96,345 119 | 2,12.77,3.43,1.98,16,80,1.63,1.25,.43,.83,3.4,.7,2.12,372 120 | 2,12,3.43,2,19,87,2,1.64,.37,1.87,1.28,.93,3.05,564 121 | 2,11.45,2.4,2.42,20,96,2.9,2.79,.32,1.83,3.25,.8,3.39,625 122 | 2,11.56,2.05,3.23,28.5,119,3.18,5.08,.47,1.87,6,.93,3.69,465 123 | 2,12.42,4.43,2.73,26.5,102,2.2,2.13,.43,1.71,2.08,.92,3.12,365 124 | 2,13.05,5.8,2.13,21.5,86,2.62,2.65,.3,2.01,2.6,.73,3.1,380 125 | 2,11.87,4.31,2.39,21,82,2.86,3.03,.21,2.91,2.8,.75,3.64,380 126 | 2,12.07,2.16,2.17,21,85,2.6,2.65,.37,1.35,2.76,.86,3.28,378 127 | 2,12.43,1.53,2.29,21.5,86,2.74,3.15,.39,1.77,3.94,.69,2.84,352 128 | 2,11.79,2.13,2.78,28.5,92,2.13,2.24,.58,1.76,3,.97,2.44,466 129 | 2,12.37,1.63,2.3,24.5,88,2.22,2.45,.4,1.9,2.12,.89,2.78,342 130 | 2,12.04,4.3,2.38,22,80,2.1,1.75,.42,1.35,2.6,.79,2.57,580 131 | 3,12.86,1.35,2.32,18,122,1.51,1.25,.21,.94,4.1,.76,1.29,630 132 | 3,12.88,2.99,2.4,20,104,1.3,1.22,.24,.83,5.4,.74,1.42,530 133 | 3,12.81,2.31,2.4,24,98,1.15,1.09,.27,.83,5.7,.66,1.36,560 134 | 3,12.7,3.55,2.36,21.5,106,1.7,1.2,.17,.84,5,.78,1.29,600 135 | 3,12.51,1.24,2.25,17.5,85,2,.58,.6,1.25,5.45,.75,1.51,650 136 | 3,12.6,2.46,2.2,18.5,94,1.62,.66,.63,.94,7.1,.73,1.58,695 137 | 3,12.25,4.72,2.54,21,89,1.38,.47,.53,.8,3.85,.75,1.27,720 138 | 3,12.53,5.51,2.64,25,96,1.79,.6,.63,1.1,5,.82,1.69,515 139 | 3,13.49,3.59,2.19,19.5,88,1.62,.48,.58,.88,5.7,.81,1.82,580 140 | 3,12.84,2.96,2.61,24,101,2.32,.6,.53,.81,4.92,.89,2.15,590 141 | 3,12.93,2.81,2.7,21,96,1.54,.5,.53,.75,4.6,.77,2.31,600 142 | 3,13.36,2.56,2.35,20,89,1.4,.5,.37,.64,5.6,.7,2.47,780 143 | 3,13.52,3.17,2.72,23.5,97,1.55,.52,.5,.55,4.35,.89,2.06,520 144 | 3,13.62,4.95,2.35,20,92,2,.8,.47,1.02,4.4,.91,2.05,550 145 | 3,12.25,3.88,2.2,18.5,112,1.38,.78,.29,1.14,8.21,.65,2,855 146 | 3,13.16,3.57,2.15,21,102,1.5,.55,.43,1.3,4,.6,1.68,830 147 | 3,13.88,5.04,2.23,20,80,.98,.34,.4,.68,4.9,.58,1.33,415 148 | 3,12.87,4.61,2.48,21.5,86,1.7,.65,.47,.86,7.65,.54,1.86,625 149 | 3,13.32,3.24,2.38,21.5,92,1.93,.76,.45,1.25,8.42,.55,1.62,650 150 | 3,13.08,3.9,2.36,21.5,113,1.41,1.39,.34,1.14,9.40,.57,1.33,550 151 | 3,13.5,3.12,2.62,24,123,1.4,1.57,.22,1.25,8.60,.59,1.3,500 152 | 3,12.79,2.67,2.48,22,112,1.48,1.36,.24,1.26,10.8,.48,1.47,480 153 | 3,13.11,1.9,2.75,25.5,116,2.2,1.28,.26,1.56,7.1,.61,1.33,425 154 | 3,13.23,3.3,2.28,18.5,98,1.8,.83,.61,1.87,10.52,.56,1.51,675 155 | 3,12.58,1.29,2.1,20,103,1.48,.58,.53,1.4,7.6,.58,1.55,640 156 | 3,13.17,5.19,2.32,22,93,1.74,.63,.61,1.55,7.9,.6,1.48,725 157 | 3,13.84,4.12,2.38,19.5,89,1.8,.83,.48,1.56,9.01,.57,1.64,480 158 | 3,12.45,3.03,2.64,27,97,1.9,.58,.63,1.14,7.5,.67,1.73,880 159 | 3,14.34,1.68,2.7,25,98,2.8,1.31,.53,2.7,13,.57,1.96,660 160 | 3,13.48,1.67,2.64,22.5,89,2.6,1.1,.52,2.29,11.75,.57,1.78,620 161 | 3,12.36,3.83,2.38,21,88,2.3,.92,.5,1.04,7.65,.56,1.58,520 162 | 3,13.69,3.26,2.54,20,107,1.83,.56,.5,.8,5.88,.96,1.82,680 163 | 3,12.85,3.27,2.58,22,106,1.65,.6,.6,.96,5.58,.87,2.11,570 164 | 3,12.96,3.45,2.35,18.5,106,1.39,.7,.4,.94,5.28,.68,1.75,675 165 | 3,13.78,2.76,2.3,22,90,1.35,.68,.41,1.03,9.58,.7,1.68,615 166 | 3,13.73,4.36,2.26,22.5,88,1.28,.47,.52,1.15,6.62,.78,1.75,520 167 | 3,13.45,3.7,2.6,23,111,1.7,.92,.43,1.46,10.68,.85,1.56,695 168 | 3,12.82,3.37,2.3,19.5,88,1.48,.66,.4,.97,10.26,.72,1.75,685 169 | 3,13.58,2.58,2.69,24.5,105,1.55,.84,.39,1.54,8.66,.74,1.8,750 170 | 3,13.4,4.6,2.86,25,112,1.98,.96,.27,1.11,8.5,.67,1.92,630 171 | 3,12.2,3.03,2.32,19,96,1.25,.49,.4,.73,5.5,.66,1.83,510 172 | 3,12.77,2.39,2.28,19.5,86,1.39,.51,.48,.64,9.899999,.57,1.63,470 173 | 3,14.16,2.51,2.48,20,91,1.68,.7,.44,1.24,9.7,.62,1.71,660 174 | 3,13.71,5.65,2.45,20.5,95,1.68,.61,.52,1.06,7.7,.64,1.74,740 175 | 3,13.4,3.91,2.48,23,102,1.8,.75,.43,1.41,7.3,.7,1.56,750 176 | 3,13.27,4.28,2.26,20,120,1.59,.69,.43,1.35,10.2,.59,1.56,835 177 | 3,13.17,2.59,2.37,20,120,1.65,.68,.53,1.46,9.3,.6,1.62,840 178 | 3,14.13,4.1,2.74,24.5,96,2.05,.76,.56,1.35,9.2,.61,1.6,560 179 | -------------------------------------------------------------------------------- /lecture_slides/FIT1043_IntroDS_Lecture 2-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_IntroDS_Lecture 2-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_IntroDS_Lecture 3-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_IntroDS_Lecture 3-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_IntroDS_Lecture 4-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_IntroDS_Lecture 4-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 1-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 1-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 10-2018S2(2).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 10-2018S2(2).pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 10-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 10-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 11-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 11-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 12-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 12-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 5-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 5-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 6-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 6-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 7-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 7-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 8-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 8-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_Lecture 9-2018S2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_Lecture 9-2018S2.pdf -------------------------------------------------------------------------------- /lecture_slides/FIT1043_introDS_M6_L11-Unit review.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/FIT1043_introDS_M6_L11-Unit review.pdf -------------------------------------------------------------------------------- /lecture_slides/Intro_to_Predictive_Models.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Intro_to_Predictive_Models.pdf -------------------------------------------------------------------------------- /lecture_slides/Introduction-to-Data-Science.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Introduction-to-Data-Science.pdf -------------------------------------------------------------------------------- /lecture_slides/Introduction_to_Python_for_Data_Science.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Introduction_to_Python_for_Data_Science.pdf -------------------------------------------------------------------------------- /lecture_slides/Introduction_to_Python_for_Data_Science_PART2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Introduction_to_Python_for_Data_Science_PART2.pdf -------------------------------------------------------------------------------- /lecture_slides/Introduction_to_R_for_Data_Science.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Introduction_to_R_for_Data_Science.pdf -------------------------------------------------------------------------------- /lecture_slides/Introduction_to_Shell_Commands_for_Data_Science.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Introduction_to_Shell_Commands_for_Data_Science.pdf -------------------------------------------------------------------------------- /lecture_slides/PMML in R.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/PMML in R.png -------------------------------------------------------------------------------- /lecture_slides/PandasPythonForDataScience.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/PandasPythonForDataScience.pdf -------------------------------------------------------------------------------- /lecture_slides/Semi Structured Data.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Semi Structured Data.pdf -------------------------------------------------------------------------------- /lecture_slides/Ten Examples of Open Source Projects.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/lecture_slides/Ten Examples of Open Source Projects.pdf -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/.ipynb_checkpoints/MotionChart-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Motion Chart with Python\n", 8 | "In this activity, we are going to learn how to create motion charts with Python." 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "## Step 1: Importing libraries and packages\n", 16 | "Like other python libraries, we have to import before use. \n", 17 | "Also if we know the which part of the library we need, it is more efficient to import the specific part rather than the whole library. \n", 18 | "In this activity, we will only need MotionChart, so let's begin with importing MotionChart from it's package. \n", 19 | "\n", 20 | "For this tutorial, we will put some sample data into DataFrame structure and then show their changes during time with MotionChart tools. So we will also need to import pandas.\n", 21 | "\n", 22 | "Notice that if you are using your own machine, you will need to install motionchart library in your python before you import it, otherwise you will get an error when executing the following code. \n", 23 | "Please following the instruction here for installing motionchart.\n", 24 | "In a simple case, you will only need to open your terminal (mac) or windows prompt, and enter the following:\n", 25 | "\n", 26 | " pip install motionchart \n", 27 | "\n", 28 | "You will probably need to install also its denpendency: pyperclip\n", 29 | "\n", 30 | " pip install pyperclip" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 30, 36 | "metadata": { 37 | "collapsed": true 38 | }, 39 | "outputs": [], 40 | "source": [ 41 | "from motionchart.motionchart import MotionChart\n", 42 | "import pandas as pd" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "## Step 2: Sample data\n", 50 | "Now we need some sample data and we will use the content of following table. \n", 51 | "This table shows GDP, Life Expectancy and Population of some countries of several years.\n", 52 | "\n", 53 | "#### Sample Data Table\n", 54 | "| Countries | Years | GDP | Life Expectancy | Population | Region\n", 55 | "|:------------:|:--------:|:------:|:-------:|:----------------------:|:--------------:\n", 56 | "| USA | 1990 | 31744 | 76 | 250 | North America\n", 57 | "| USA | 2000 | 38850 | 77 | 285 | North America\n", 58 | "| China | 1990 | 1466 | 68 | 1440 | Asia\n", 59 | "| China | 2000 | 2806 | 72 | 1270 | Asia\n", 60 | "| Japan | 1990 | 25870 | 79 | 124 | Asia\n", 61 | "| Japan | 2000 | 28569 | 81 | 127 | Asia\n", 62 | "| Brazil | 1990 | 7247 | 66 | 151 | South America\n", 63 | "| Brazil | 2000 | 8184 | 71 | 178 | South America\n" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "## Step 3: Storing sample data into pandas dataframe\n", 71 | "As previously mentioned, we will put the sample data into a DataFrame object." 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "### Enter sample data manually\n", 79 | "In a simply example, we can enter the sample data manually one by one. The following code creates a dataframe with the sample data and set its column names as listed previously." 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 31, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/html": [ 90 | "
\n", 91 | "\n", 104 | "\n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | "
CountriesTimeGDPLife ExpectancyPopulationRegion
0USA19903174476250North America
1USA20003885077285North America
2China19901466681440Asia
3China20002806721270Asia
4Japan19902587079124Asia
5Japan20002856981127Asia
6Brazil1990724766151South America
7Brazil2000818471178South America
\n", 191 | "
" 192 | ], 193 | "text/plain": [ 194 | " Countries Time GDP Life Expectancy Population Region\n", 195 | "0 USA 1990 31744 76 250 North America\n", 196 | "1 USA 2000 38850 77 285 North America\n", 197 | "2 China 1990 1466 68 1440 Asia\n", 198 | "3 China 2000 2806 72 1270 Asia\n", 199 | "4 Japan 1990 25870 79 124 Asia\n", 200 | "5 Japan 2000 28569 81 127 Asia\n", 201 | "6 Brazil 1990 7247 66 151 South America\n", 202 | "7 Brazil 2000 8184 71 178 South America" 203 | ] 204 | }, 205 | "execution_count": 31, 206 | "metadata": {}, 207 | "output_type": "execute_result" 208 | } 209 | ], 210 | "source": [ 211 | "# create a pandas dataframe with the sample data values\n", 212 | "sampleData = pd.DataFrame([\n", 213 | "['USA', '1990', '31744', '76', '250', 'North America'],\n", 214 | "['USA', '2000', '38850', '77', '285', 'North America'],\n", 215 | "['China', '1990', '1466', '68', '1440', 'Asia'],\n", 216 | "['China', '2000', '2806', '72', '1270', 'Asia'],\n", 217 | "['Japan', '1990', '25870', '79', '124', 'Asia'],\n", 218 | "['Japan', '2000', '28569', '81', '127', 'Asia'],\n", 219 | "['Brazil', '1990', '7247', '66', '151', 'South America'],\n", 220 | "['Brazil', '2000', '8184', '71', '178', 'South America']])\n", 221 | "\n", 222 | "sampleData.columns = ['Countries','Time', 'GDP', 'Life Expectancy', 'Population', 'Region']\n", 223 | "sampleData # we can then have a look at the dataframe" 224 | ] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "metadata": {}, 229 | "source": [ 230 | "### Reading data from csv file\n", 231 | "In a more complex case where you have a large dataset, manually entering them will not be possible. \n", 232 | "Now assume we have the sample data in csv format (data.csv; make sure that the data file is in the same directory as this jupyter notebook). \n", 233 | "The following code will read the data directly from data.csv into a pandas dataframe. \n", 234 | "We do not even need to set the column names, becaues the headers are automatically recognized as column names." 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": 32, 240 | "metadata": {}, 241 | "outputs": [ 242 | { 243 | "data": { 244 | "text/html": [ 245 | "
\n", 246 | "\n", 259 | "\n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | "
TimeGDPLife ExpectancyCountriesPopulationRegion
019903174476USA250North America
120003885077USA285North America
219901146668China1440Asia
320001280672China1270Asia
419902587079Japan124Asia
520002856981Japan127Asia
61990724766Brazil151South America
72000818471Brazil178South America
\n", 346 | "
" 347 | ], 348 | "text/plain": [ 349 | " Time GDP Life Expectancy Countries Population Region\n", 350 | "0 1990 31744 76 USA 250 North America\n", 351 | "1 2000 38850 77 USA 285 North America\n", 352 | "2 1990 11466 68 China 1440 Asia\n", 353 | "3 2000 12806 72 China 1270 Asia\n", 354 | "4 1990 25870 79 Japan 124 Asia\n", 355 | "5 2000 28569 81 Japan 127 Asia\n", 356 | "6 1990 7247 66 Brazil 151 South America\n", 357 | "7 2000 8184 71 Brazil 178 South America" 358 | ] 359 | }, 360 | "execution_count": 32, 361 | "metadata": {}, 362 | "output_type": "execute_result" 363 | } 364 | ], 365 | "source": [ 366 | "# read in the sample data from data.csv\n", 367 | "sampleData = pd.read_csv('data.csv')\n", 368 | "# have a look at the dataframe, it should be exactly the same as the one we had before\n", 369 | "sampleData" 370 | ] 371 | }, 372 | { 373 | "cell_type": "markdown", 374 | "metadata": {}, 375 | "source": [ 376 | "## Step 4: Creating motion chart\n", 377 | "In the following, we pass our data to MotionChart to make them animate and show thier changes." 378 | ] 379 | }, 380 | { 381 | "cell_type": "markdown", 382 | "metadata": {}, 383 | "source": [ 384 | "The following html code block is just to make sure that you will see the entire motion chart nicely in the output cell." 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": 33, 390 | "metadata": {}, 391 | "outputs": [ 392 | { 393 | "data": { 394 | "text/html": [ 395 | "" 405 | ], 406 | "text/plain": [ 407 | "" 408 | ] 409 | }, 410 | "metadata": {}, 411 | "output_type": "display_data" 412 | } 413 | ], 414 | "source": [ 415 | "%%html\n", 416 | "" 426 | ] 427 | }, 428 | { 429 | "cell_type": "code", 430 | "execution_count": 34, 431 | "metadata": { 432 | "scrolled": true 433 | }, 434 | "outputs": [ 435 | { 436 | "data": { 437 | "text/html": [ 438 | "\n", 439 | " \n", 446 | " " 447 | ], 448 | "text/plain": [ 449 | "" 450 | ] 451 | }, 452 | "metadata": {}, 453 | "output_type": "display_data" 454 | } 455 | ], 456 | "source": [ 457 | "# now generate the motionchart and show it in the notebook\n", 458 | "mChart = MotionChart(df = sampleData)\n", 459 | "mChart.to_notebook()" 460 | ] 461 | }, 462 | { 463 | "cell_type": "markdown", 464 | "metadata": {}, 465 | "source": [ 466 | "At first, we've got a motion chart that doesn't looks quite right. \n", 467 | "There are some defult settings which may not be what we want, e.g., what we will use for x and y axis, what will be shown as size, etc.\n", 468 | "Therefore, we will have to reset the options and parameters. \n", 469 | "You can do this when you create your motion chart (with coding) or change the setting with the active motion chart panel." 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 35, 475 | "metadata": {}, 476 | "outputs": [ 477 | { 478 | "data": { 479 | "text/html": [ 480 | "\n", 481 | " \n", 488 | " " 489 | ], 490 | "text/plain": [ 491 | "" 492 | ] 493 | }, 494 | "metadata": {}, 495 | "output_type": "display_data" 496 | } 497 | ], 498 | "source": [ 499 | "mChart = MotionChart(df = sampleData, key='Time', x='GDP', y='Life Expectancy', xscale='linear', yscale='linear',\n", 500 | " size='Population', color='Region', category='Countries')\n", 501 | "\n", 502 | "mChart.to_notebook()" 503 | ] 504 | }, 505 | { 506 | "cell_type": "markdown", 507 | "metadata": {}, 508 | "source": [ 509 | "To change the setting directly in the motion chart, move your mouse towards the top right of the motion chart, you'll see a blue long rectangle. Once you hover your mouse on the rectangle, it will show all the options. \n", 510 | "In this example, we choose the following settings:\n", 511 | "- Key: Time\n", 512 | "- X-Axis: GDP\n", 513 | "- Y-Ais: Life Expecta\n", 514 | "- Size: Population\n", 515 | "- Color: Region\n", 516 | "- Category: Countries\n", 517 | "\n", 518 | "The correct setting would look like this:\n", 519 | "\n", 520 | "\n", 521 | "Once you've reset the options, you are free to play around with the motion chart. \n", 522 | "\n", 523 | "In fact, there are a lot of controls in Python Motion Charts, two buttons on top and some setting panel on right side. \n", 524 | "You can change the chart setting and generate any visualization you get. " 525 | ] 526 | }, 527 | { 528 | "cell_type": "markdown", 529 | "metadata": {}, 530 | "source": [ 531 | "#### Question:\n", 532 | "Looking at the data, we've only got data in 1990 and 2000. However, it seems that the data points changes smoothly from 1990 to 2000 - do you know what is going on?" 533 | ] 534 | }, 535 | { 536 | "cell_type": "markdown", 537 | "metadata": {}, 538 | "source": [ 539 | "## Step 5: Adding the Australian data\n", 540 | "\n", 541 | "In this step, you are to research about the data (GDP or appriximate, etc.) of Australia and add that into the dataset. You then can re-generate the motion chart and compare the Australian data with other countries." 542 | ] 543 | }, 544 | { 545 | "cell_type": "markdown", 546 | "metadata": {}, 547 | "source": [ 548 | "## Step 6: Create your own motion chart\n", 549 | "\n", 550 | "There are other datasets would be suitable to be visualised via motion chart. \n", 551 | "Now you can explore a dataset of your own interest and visualise it using motion chart.\n", 552 | "\n", 553 | "You can also get a big dataset from GapMinder: http://www.gapminder.org/data/ (or from US labor stats, see:\n", 554 | "www.bls.gov/osmr/pdf/st110110.pdf).\n", 555 | "\n", 556 | "#### Explore and assess:\n", 557 | "How do you rate GapMinder as a tool, as used by Rosling, for social good, for education?\n", 558 | "
GapMinder is nearly 10 years old (Google bought it circa 2008), what's available now?\n" 559 | ] 560 | } 561 | ], 562 | "metadata": { 563 | "kernelspec": { 564 | "display_name": "Python 3", 565 | "language": "python", 566 | "name": "python3" 567 | }, 568 | "language_info": { 569 | "codemirror_mode": { 570 | "name": "ipython", 571 | "version": 3 572 | }, 573 | "file_extension": ".py", 574 | "mimetype": "text/x-python", 575 | "name": "python", 576 | "nbconvert_exporter": "python", 577 | "pygments_lexer": "ipython3", 578 | "version": "3.6.1" 579 | } 580 | }, 581 | "nbformat": 4, 582 | "nbformat_minor": 2 583 | } 584 | -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/MotionChart.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Motion Chart with Python\n", 8 | "In this activity, we are going to learn how to create motion charts with Python." 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "## Step 1: Importing libraries and packages\n", 16 | "Like other python libraries, we have to import before use. \n", 17 | "Also if we know the which part of the library we need, it is more efficient to import the specific part rather than the whole library. \n", 18 | "In this activity, we will only need MotionChart, so let's begin with importing MotionChart from it's package. \n", 19 | "\n", 20 | "For this tutorial, we will put some sample data into DataFrame structure and then show their changes during time with MotionChart tools. So we will also need to import pandas.\n", 21 | "\n", 22 | "Notice that if you are using your own machine, you will need to install motionchart library in your python before you import it, otherwise you will get an error when executing the following code. \n", 23 | "Please following the instruction here for installing motionchart.\n", 24 | "In a simple case, you will only need to open your terminal (mac) or windows prompt, and enter the following:\n", 25 | "\n", 26 | " pip install motionchart \n", 27 | "\n", 28 | "You will probably need to install also its denpendency: pyperclip\n", 29 | "\n", 30 | " pip install pyperclip" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 2, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "from motionchart.motionchart import MotionChart\n", 40 | "import pandas as pd" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "## Step 2: Sample data\n", 48 | "Now we need some sample data and we will use the content of following table. \n", 49 | "This table shows GDP, Life Expectancy and Population of some countries of several years.\n", 50 | "\n", 51 | "#### Sample Data Table\n", 52 | "| Countries | Years | GDP | Life Expectancy | Population | Region\n", 53 | "|:------------:|:--------:|:------:|:-------:|:----------------------:|:--------------:\n", 54 | "| USA | 1990 | 31744 | 76 | 250 | North America\n", 55 | "| USA | 2000 | 38850 | 77 | 285 | North America\n", 56 | "| China | 1990 | 1466 | 68 | 1440 | Asia\n", 57 | "| China | 2000 | 2806 | 72 | 1270 | Asia\n", 58 | "| Japan | 1990 | 25870 | 79 | 124 | Asia\n", 59 | "| Japan | 2000 | 28569 | 81 | 127 | Asia\n", 60 | "| Brazil | 1990 | 7247 | 66 | 151 | South America\n", 61 | "| Brazil | 2000 | 8184 | 71 | 178 | South America\n" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "## Step 3: Storing sample data into pandas dataframe\n", 69 | "As previously mentioned, we will put the sample data into a DataFrame object." 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "### Enter sample data manually\n", 77 | "In a simply example, we can enter the sample data manually one by one. The following code creates a dataframe with the sample data and set its column names as listed previously." 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 3, 83 | "metadata": {}, 84 | "outputs": [ 85 | { 86 | "data": { 87 | "text/html": [ 88 | "
\n", 89 | "\n", 102 | "\n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | "
CountriesTimeGDPLife ExpectancyPopulationRegion
0USA19903174476250North America
1USA20003885077285North America
2China19901466681440Asia
3China20002806721270Asia
4Japan19902587079124Asia
5Japan20002856981127Asia
6Brazil1990724766151South America
7Brazil2000818471178South America
\n", 189 | "
" 190 | ], 191 | "text/plain": [ 192 | " Countries Time GDP Life Expectancy Population Region\n", 193 | "0 USA 1990 31744 76 250 North America\n", 194 | "1 USA 2000 38850 77 285 North America\n", 195 | "2 China 1990 1466 68 1440 Asia\n", 196 | "3 China 2000 2806 72 1270 Asia\n", 197 | "4 Japan 1990 25870 79 124 Asia\n", 198 | "5 Japan 2000 28569 81 127 Asia\n", 199 | "6 Brazil 1990 7247 66 151 South America\n", 200 | "7 Brazil 2000 8184 71 178 South America" 201 | ] 202 | }, 203 | "execution_count": 3, 204 | "metadata": {}, 205 | "output_type": "execute_result" 206 | } 207 | ], 208 | "source": [ 209 | "# create a pandas dataframe with the sample data values\n", 210 | "sampleData = pd.DataFrame([\n", 211 | "['USA', '1990', '31744', '76', '250', 'North America'],\n", 212 | "['USA', '2000', '38850', '77', '285', 'North America'],\n", 213 | "['China', '1990', '1466', '68', '1440', 'Asia'],\n", 214 | "['China', '2000', '2806', '72', '1270', 'Asia'],\n", 215 | "['Japan', '1990', '25870', '79', '124', 'Asia'],\n", 216 | "['Japan', '2000', '28569', '81', '127', 'Asia'],\n", 217 | "['Brazil', '1990', '7247', '66', '151', 'South America'],\n", 218 | "['Brazil', '2000', '8184', '71', '178', 'South America']])\n", 219 | "\n", 220 | "sampleData.columns = ['Countries','Time', 'GDP', 'Life Expectancy', 'Population', 'Region']\n", 221 | "sampleData # we can then have a look at the dataframe" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "### Reading data from csv file\n", 229 | "In a more complex case where you have a large dataset, manually entering them will not be possible. \n", 230 | "Now assume we have the sample data in csv format (data.csv; make sure that the data file is in the same directory as this jupyter notebook). \n", 231 | "The following code will read the data directly from data.csv into a pandas dataframe. \n", 232 | "We do not even need to set the column names, becaues the headers are automatically recognized as column names." 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 4, 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/html": [ 243 | "
\n", 244 | "\n", 257 | "\n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | "
TimeGDPLife ExpectancyCountriesPopulationRegion
019903174476USA250North America
120003885077USA285North America
219901146668China1440Asia
320001280672China1270Asia
419902587079Japan124Asia
520002856981Japan127Asia
61990724766Brazil151South America
72000818471Brazil178South America
\n", 344 | "
" 345 | ], 346 | "text/plain": [ 347 | " Time GDP Life Expectancy Countries Population Region\n", 348 | "0 1990 31744 76 USA 250 North America\n", 349 | "1 2000 38850 77 USA 285 North America\n", 350 | "2 1990 11466 68 China 1440 Asia\n", 351 | "3 2000 12806 72 China 1270 Asia\n", 352 | "4 1990 25870 79 Japan 124 Asia\n", 353 | "5 2000 28569 81 Japan 127 Asia\n", 354 | "6 1990 7247 66 Brazil 151 South America\n", 355 | "7 2000 8184 71 Brazil 178 South America" 356 | ] 357 | }, 358 | "execution_count": 4, 359 | "metadata": {}, 360 | "output_type": "execute_result" 361 | } 362 | ], 363 | "source": [ 364 | "# read in the sample data from data.csv\n", 365 | "sampleData = pd.read_csv('data.csv')\n", 366 | "# have a look at the dataframe, it should be exactly the same as the one we had before\n", 367 | "sampleData" 368 | ] 369 | }, 370 | { 371 | "cell_type": "markdown", 372 | "metadata": {}, 373 | "source": [ 374 | "## Step 4: Creating motion chart\n", 375 | "In the following, we pass our data to MotionChart to make them animate and show thier changes." 376 | ] 377 | }, 378 | { 379 | "cell_type": "markdown", 380 | "metadata": {}, 381 | "source": [ 382 | "The following html code block is just to make sure that you will see the entire motion chart nicely in the output cell." 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "execution_count": 5, 388 | "metadata": {}, 389 | "outputs": [ 390 | { 391 | "data": { 392 | "text/html": [ 393 | "" 403 | ], 404 | "text/plain": [ 405 | "" 406 | ] 407 | }, 408 | "metadata": {}, 409 | "output_type": "display_data" 410 | } 411 | ], 412 | "source": [ 413 | "%%html\n", 414 | "" 424 | ] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": 6, 429 | "metadata": { 430 | "scrolled": true 431 | }, 432 | "outputs": [ 433 | { 434 | "data": { 435 | "text/html": [ 436 | "\n", 437 | " \n", 444 | " " 445 | ], 446 | "text/plain": [ 447 | "" 448 | ] 449 | }, 450 | "metadata": {}, 451 | "output_type": "display_data" 452 | } 453 | ], 454 | "source": [ 455 | "# now generate the motionchart and show it in the notebook\n", 456 | "mChart = MotionChart(df = sampleData)\n", 457 | "mChart.to_notebook()" 458 | ] 459 | }, 460 | { 461 | "cell_type": "markdown", 462 | "metadata": {}, 463 | "source": [ 464 | "At first, we've got a motion chart that doesn't looks quite right. \n", 465 | "There are some defult settings which may not be what we want, e.g., what we will use for x and y axis, what will be shown as size, etc.\n", 466 | "Therefore, we will have to reset the options and parameters. \n", 467 | "You can do this when you create your motion chart (with coding) or change the setting with the active motion chart panel." 468 | ] 469 | }, 470 | { 471 | "cell_type": "code", 472 | "execution_count": 35, 473 | "metadata": {}, 474 | "outputs": [ 475 | { 476 | "data": { 477 | "text/html": [ 478 | "\n", 479 | " \n", 486 | " " 487 | ], 488 | "text/plain": [ 489 | "" 490 | ] 491 | }, 492 | "metadata": {}, 493 | "output_type": "display_data" 494 | } 495 | ], 496 | "source": [ 497 | "mChart = MotionChart(df = sampleData, key='Time', x='GDP', y='Life Expectancy', xscale='linear', yscale='linear',\n", 498 | " size='Population', color='Region', category='Countries')\n", 499 | "\n", 500 | "mChart.to_notebook()" 501 | ] 502 | }, 503 | { 504 | "cell_type": "markdown", 505 | "metadata": {}, 506 | "source": [ 507 | "To change the setting directly in the motion chart, move your mouse towards the top right of the motion chart, you'll see a blue long rectangle. Once you hover your mouse on the rectangle, it will show all the options. \n", 508 | "In this example, we choose the following settings:\n", 509 | "- Key: Time\n", 510 | "- X-Axis: GDP\n", 511 | "- Y-Ais: Life Expecta\n", 512 | "- Size: Population\n", 513 | "- Color: Region\n", 514 | "- Category: Countries\n", 515 | "\n", 516 | "The correct setting would look like this:\n", 517 | "\n", 518 | "\n", 519 | "Once you've reset the options, you are free to play around with the motion chart. \n", 520 | "\n", 521 | "In fact, there are a lot of controls in Python Motion Charts, two buttons on top and some setting panel on right side. \n", 522 | "You can change the chart setting and generate any visualization you get. " 523 | ] 524 | }, 525 | { 526 | "cell_type": "markdown", 527 | "metadata": {}, 528 | "source": [ 529 | "#### Question:\n", 530 | "Looking at the data, we've only got data in 1990 and 2000. However, it seems that the data points changes smoothly from 1990 to 2000 - do you know what is going on?" 531 | ] 532 | }, 533 | { 534 | "cell_type": "markdown", 535 | "metadata": {}, 536 | "source": [ 537 | "## Step 5: Adding the Australian data\n", 538 | "\n", 539 | "In this step, you are to research about the data (GDP or appriximate, etc.) of Australia and add that into the dataset. You then can re-generate the motion chart and compare the Australian data with other countries." 540 | ] 541 | }, 542 | { 543 | "cell_type": "markdown", 544 | "metadata": {}, 545 | "source": [ 546 | "## Step 6: Create your own motion chart\n", 547 | "\n", 548 | "There are other datasets would be suitable to be visualised via motion chart. \n", 549 | "Now you can explore a dataset of your own interest and visualise it using motion chart.\n", 550 | "\n", 551 | "You can also get a big dataset from GapMinder: http://www.gapminder.org/data/ (or from US labor stats, see:\n", 552 | "www.bls.gov/osmr/pdf/st110110.pdf).\n", 553 | "\n", 554 | "#### Explore and assess:\n", 555 | "How do you rate GapMinder as a tool, as used by Rosling, for social good, for education?\n", 556 | "
GapMinder is nearly 10 years old (Google bought it circa 2008), what's available now?\n" 557 | ] 558 | } 559 | ], 560 | "metadata": { 561 | "kernelspec": { 562 | "display_name": "Python 3", 563 | "language": "python", 564 | "name": "python3" 565 | }, 566 | "language_info": { 567 | "codemirror_mode": { 568 | "name": "ipython", 569 | "version": 3 570 | }, 571 | "file_extension": ".py", 572 | "mimetype": "text/x-python", 573 | "name": "python", 574 | "nbconvert_exporter": "python", 575 | "pygments_lexer": "ipython3", 576 | "version": "3.6.4" 577 | } 578 | }, 579 | "nbformat": 4, 580 | "nbformat_minor": 2 581 | } 582 | -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/data.csv: -------------------------------------------------------------------------------- 1 | Time,GDP,Life Expectancy,Countries,Population,Region 1990,31744,76,USA,250,North America 2000,38850,77,USA,285,North America 1990,11466,68,China,1440,Asia 2000,12806,72,China,1270,Asia 1990,25870,79,Japan,124,Asia 2000,28569,81,Japan,127,Asia 1990,7247,66,Brazil,151,South America 2000,8184,71,Brazil,178,South America -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/mc_temp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 |
25 |
26 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/motionchart.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Dec 28 15:33:33 2014 4 | 5 | @author: Hans Olav Melberg 6 | """ 7 | # This is a wrapper that makes it possible to create motion charts from a pandas dataframe 8 | # 9 | # Acknowledgements and more information 10 | # See https://github.com/RamyElkest/SocrMotionChartsHTML5 for more information about the javascript 11 | # See also https://github.com/psychemedia/dataviz4development/tree/master/SocrMotionCharts 12 | # For more bakcground, and java version, see http://www.amstat.org/publications/jse/v18n3/dinov.pdf 13 | 14 | import os 15 | import webbrowser 16 | import pandas as pd 17 | import pyperclip 18 | from IPython.display import display, HTML, IFrame 19 | 20 | class MotionChart(object): 21 | ''' To create a Motion Chart object from a pandas dataframe: 22 | mc = MotionChart(df = dataframe) 23 | To send the object to the Ipyton Notebook, to a browser, to the clipboard and to a file by writing: 24 | mc.to_notebook() 25 | mc.to_browser() 26 | mc.to_clipboard() 27 | mc.to_file() 28 | 29 | Options and defaults (specifying which variable you want to be x, y, etc): 30 | mc = MotionChart( 31 | df = df, 32 | title = "Motion Chart", 33 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 34 | key = 1, 35 | x = 2, 36 | y = 3, 37 | size = 4, 38 | color = 5, 39 | category = 1, 40 | xscale='linear', 41 | yscale='linear', 42 | play = 'true', 43 | loop = 'false', 44 | width = 800, 45 | height = 600, 46 | varLabels=None) 47 | 48 | Explained: 49 | df # specifies the name of the pandas dataframe used to create the motion chart, default is df 50 | title # string. The title of the chart 51 | url # string. url to folder with js and css files; 52 | can be local, default is external which requires wireless connection 53 | key # string or integer. the column number of the "motion" variable (does not have to be time) 54 | x # string or integer. number (integer) or name (text, string) of the x-variable in the chart. 55 | Can later be changed by clicking on the variable in the chart. 56 | Number starts from 0 which is the outer index of the dataframe 57 | y # string or integer. number (integer) or name (text, string) of the x-variable in the chart. 58 | size # name (text, string) or column number (integer) 59 | The variable used to determine the size of the circles 60 | color # name (text, string) or column number (integer) 61 | The variable used to determine the color of the circles 62 | category # name (text, string) or column number (integer) 63 | The variable used to describe the category the observation belongs to. 64 | Example Mid-West, South. Often the same variable as color. 65 | xscale # string. Scale for x-variable, string, default 'linear'. 66 | Possible values 'linear', 'log', 'sqrt', 'log', 'quadnomial', 'ordinal' 67 | yscale # string. Scale for x-variable, string, default 'linear'. 68 | Possible values 'linear', 'log', 'sqrt', 'log', 'quadnomial', 'ordinal' 69 | play # string. 'true' or 'false' (default, false). 70 | Determines whether the motion starts right away or if you have to click play first. 71 | loop # string. 'true' or 'false' (default, false). 72 | Determines whether the motion keeps repeating after one loop over the series, or stops. 73 | width # integer. width of chart in pixels, default 900 74 | height # integer. height of chart in pixels, default 700 75 | varLabels # list. list of labels for columns (default is column headers of dataframe) 76 | Must be of same length as the number of columns in the dataframe, including the index 77 | 78 | ''' 79 | # This defines the motion chart object. 80 | # Basically just holds the parameters used to create the chart: name of data source, which variables to use 81 | def __init__(self, 82 | df = 'df', 83 | title = "Motion Chart", 84 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 85 | key = 1, 86 | x = 2, 87 | y = 3, 88 | size = 4, 89 | color = 5, 90 | category = 5, 91 | xscale='linear', 92 | yscale='linear', 93 | play = 'true', 94 | loop = 'false', 95 | width = 800, 96 | height = 600, 97 | varLabels=None): 98 | self.df = df 99 | self.title = title 100 | self.url = url 101 | self.key = key 102 | self.x = x 103 | self.y = y 104 | self.size = size 105 | self.color = color 106 | self.category = category 107 | self.xscale= xscale 108 | self.yscale= yscale 109 | self.play = play 110 | self.loop = loop # string: 'true' or 'false' (default, false). 111 | self.width = width # width of chart in pixels, default 800 112 | self.height = height # height of chart in pixels, default 400 113 | self.varLabels = varLabels # list of labels for columns (default is column headers of dataframe 114 | 115 | # The informaton from the object is used to generate the HTML string generating the chart 116 | # (inserting the specific information in the object into the template string) 117 | # Note 1: The string is generated in two steps, not one, because future version might want to revise some properties 118 | # without redoing the reformatting and creatingof the dataset from the dataframe 119 | # Note 2: Initially the string itself was saved in the object, although useful sometimes it seems memory greedy 120 | # Note 3: The template string used here is just a revised version of a template somebody else has created 121 | # See Tony Hirst: https://github.com/psychemedia/dataviz4development/tree/master/SocrMotionCharts 122 | def htmlStringStart(self): 123 | socrTemplateStart=''' 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 146 | ''' 147 | # In order to make it easy to use information in the index of the dataframe, the index in the passed dataframe is reset 148 | # For instance: If the time variable is in the index of the dataframe, say the outer index, then one would write 149 | # mc = MotionChart(df, key = 0) when specifying the motion chart 150 | # Note that although the key often is time, it does not have to be so (unlike Google Motion Chart) 151 | # In MotionCharts it is basically whatver variable you want to use to define the change 152 | 153 | df = self.df.reset_index() 154 | 155 | # If variable labels are not specified, the column names of the dataframe is used 156 | # Note. variable levels are specified the list of labels to be used has to have the same number of elements 157 | # as the columns in the reset dataframe (ie. original number of columns plus number of index levels) 158 | if self.varLabels == None: 159 | self.varLabels = df.columns.tolist() 160 | 161 | # Here the data is converted from a pandas dataframe to the format which is accepted by the SocrMotion Chart (javascript) 162 | # The starting point is a json string of all the values in the dataframe, which is then modified fit SocrMotionChart 163 | dataValuesString = df.to_json(orient = 'values') 164 | varNamesString = ",".join(['"' + str(var) + '"' for var in self.varLabels]) 165 | varNamesString = "[[" + varNamesString + "], [" 166 | dataValuesString = dataValuesString.lstrip("[") 167 | socrDataString = varNamesString + dataValuesString 168 | 169 | # The generated string containing the data in the right format, is inserted into the template string 170 | htmlString1 = socrTemplateStart.format( 171 | data = socrDataString, 172 | url = self.url 173 | ) 174 | # Change reference to bootstrap.js file if the url is changed to "custom-bootstrap.js" 175 | # The js available on SOCR's webpage which lists it as boostrap.js, but on GitHub version which many use 176 | # to install a local copy, the same file is referred to as custom-boostrap.js 177 | # The default value is to keep it as 'custom-boostrap.js', but if the url points to socr 178 | # (which is default since we want the chart to work on the web), then the filename is changed to 'bootstrap.js' 179 | if self.url == "http://socr.ucla.edu/htmls/HTML5/MotionChart": 180 | htmlString1 = htmlString1.replace("custom-bootstrap.js", "bootstrap.js") 181 | return htmlString1 182 | 183 | # Generating the last half of the html string which produces the motion chart 184 | # The reason the string is generated in two halfes, is to open up for revisons in which some options are changed 185 | # without having to transfor and generate the data from the dataframe again. 186 | def htmlStringEnd(self): 187 | socrTemplateEnd = '''
188 |
189 | 202 |
203 | 204 | 205 | ''' 206 | # Rename variables to avoid changing the properties of the object when changing strings to numbers 207 | # (NUmbers are required in the js script) 208 | kkey = self.key 209 | xx = self.x 210 | yy = self.y 211 | ssize = self.size 212 | ccolor = self.color 213 | ccategory = self.category 214 | 215 | # The user is free to specify many variables either by location (an integer representing the column number) 216 | # or by name (the column name in the dataframe) 217 | # This means we have to find and replace with column number if the variable is specified as a string since 218 | # the javascript wants integers (note: variable labels must be unique) 219 | # The code below finds and replaces the specified column name (text) with the column number (numeric) 220 | if type(kkey) is str: 221 | kkey=self.varLabels.index(kkey) 222 | if type(xx) is str: 223 | xx=self.varLabels.index(xx) 224 | if type(yy) is str: 225 | yy=self.varLabels.index(yy) 226 | if type(ssize) is str: 227 | ssize=self.varLabels.index(ssize) 228 | if type(ccolor) is str: 229 | ccolor=self.varLabels.index(ccolor) 230 | if type(ccategory) is str: 231 | ccategory=self.varLabels.index(ccategory) 232 | 233 | # The properties are inserted into the last half of the template string 234 | htmlString2 = socrTemplateEnd.format( 235 | title = self.title, 236 | key = kkey, x = xx, y = yy, size = ssize, color = ccolor, category = ccategory, 237 | xscale= self.xscale , yscale= self.yscale, 238 | play = self.play, loop = self.loop, 239 | width = self.width, height = self.height) 240 | return htmlString2 241 | 242 | # Display the motion chart in the browser (start the default browser) 243 | def to_browser(self): 244 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 245 | path = os.path.abspath('temp.html') 246 | url = 'file://' + path 247 | 248 | with open(path, 'w') as f: 249 | f.write(htmlString) 250 | webbrowser.open(url) 251 | 252 | # Display the motion chart in the Ipython notebook 253 | # This is saved to a file because in Python 3 it was difficult to encode the string that could be used in HTML directly 254 | # TODO: Eliminate file (security risk to leave the file on disk, and overwrite danger?) and avoid name conflicts. 255 | # Also: What if multiple figures? 256 | def to_notebook(self, width = 900, height = 700): 257 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 258 | path = os.path.abspath('mc_temp.html') 259 | with open(path, 'w') as f: 260 | f.write(htmlString) 261 | display(IFrame(src="mc_temp.html", width = width, height = height)) 262 | 263 | # Copy the HTML string to the clipboard 264 | def to_clipboard(self): 265 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 266 | pyperclip.copy(htmlString) 267 | 268 | # Save the motion chart as a file (inclulde .html manually if desired) 269 | def to_file(self, path_and_name): 270 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 271 | fileName = path_and_name 272 | try: # encode will not (need not!) work in Python 3 since it is unicode already 273 | fileName = fileName.encode('string-escape') 274 | with open(fileName, 'w') as f: 275 | f.write(htmlString) 276 | except: 277 | with open(fileName, 'w') as f: 278 | f.write(htmlString) 279 | 280 | # Include a demo option 281 | def MotionChartDemo(): 282 | fruitdf = pd.DataFrame([ 283 | ['Apples', '1988-0-1', 1000, 300, 44,'East'], 284 | ['Oranges', '1988-0-1', 1150, 200, 42, 'West'], 285 | ['Bananas', '1988-0-1', 300, 250, 35, 'West'], 286 | ['Apples', '1989-6-1', 1200, 400, 48, 'East'], 287 | ['Oranges', '1989-6-1', 750, 150, 47, 'West'], 288 | ['Bananas', '1989-6-1', 788, 617, 45, 'West']]) 289 | fruitdf.columns = ['fruit', 'time', 'sales', 'price', 'temperature', 'location'] 290 | fruitdf['time'] = pd.to_datetime(fruitdf['time']) 291 | mChart = MotionChart( 292 | df = fruitdf, 293 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 294 | key = 'time', 295 | x = 'price', 296 | y = 'sales', 297 | size = 'temperature', 298 | color = 'fruit', 299 | category = 'location') 300 | mChart.to_browser() -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/motionchart/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/motion-chart_activity/MotionChart Activity/motionchart/__init__.py -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/motionchart/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/motion-chart_activity/MotionChart Activity/motionchart/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/motionchart/__pycache__/motionchart.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/motion-chart_activity/MotionChart Activity/motionchart/__pycache__/motionchart.cpython-36.pyc -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/motionchart/motionchart.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Dec 28 15:33:33 2014 4 | 5 | @author: Hans Olav Melberg 6 | """ 7 | # This is a wrapper that makes it possible to create motion charts from a pandas dataframe 8 | # 9 | # Acknowledgements and more information 10 | # See https://github.com/RamyElkest/SocrMotionChartsHTML5 for more information about the javascript 11 | # See also https://github.com/psychemedia/dataviz4development/tree/master/SocrMotionCharts 12 | # For more bakcground, and java version, see http://www.amstat.org/publications/jse/v18n3/dinov.pdf 13 | 14 | import os 15 | import webbrowser 16 | import pandas as pd 17 | import pyperclip 18 | from IPython.display import display, HTML, IFrame 19 | 20 | class MotionChart(object): 21 | ''' To create a Motion Chart object from a pandas dataframe: 22 | mc = MotionChart(df = dataframe) 23 | To send the object to the Ipyton Notebook, to a browser, to the clipboard and to a file by writing: 24 | mc.to_notebook() 25 | mc.to_browser() 26 | mc.to_clipboard() 27 | mc.to_file() 28 | 29 | Options and defaults (specifying which variable you want to be x, y, etc): 30 | mc = MotionChart( 31 | df = df, 32 | title = "Motion Chart", 33 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 34 | key = 1, 35 | x = 2, 36 | y = 3, 37 | size = 4, 38 | color = 5, 39 | category = 1, 40 | xscale='linear', 41 | yscale='linear', 42 | play = 'true', 43 | loop = 'false', 44 | width = 800, 45 | height = 600, 46 | varLabels=None) 47 | 48 | Explained: 49 | df # specifies the name of the pandas dataframe used to create the motion chart, default is df 50 | title # string. The title of the chart 51 | url # string. url to folder with js and css files; 52 | can be local, default is external which requires wireless connection 53 | key # string or integer. the column number of the "motion" variable (does not have to be time) 54 | x # string or integer. number (integer) or name (text, string) of the x-variable in the chart. 55 | Can later be changed by clicking on the variable in the chart. 56 | Number starts from 0 which is the outer index of the dataframe 57 | y # string or integer. number (integer) or name (text, string) of the x-variable in the chart. 58 | size # name (text, string) or column number (integer) 59 | The variable used to determine the size of the circles 60 | color # name (text, string) or column number (integer) 61 | The variable used to determine the color of the circles 62 | category # name (text, string) or column number (integer) 63 | The variable used to describe the category the observation belongs to. 64 | Example Mid-West, South. Often the same variable as color. 65 | xscale # string. Scale for x-variable, string, default 'linear'. 66 | Possible values 'linear', 'log', 'sqrt', 'log', 'quadnomial', 'ordinal' 67 | yscale # string. Scale for x-variable, string, default 'linear'. 68 | Possible values 'linear', 'log', 'sqrt', 'log', 'quadnomial', 'ordinal' 69 | play # string. 'true' or 'false' (default, false). 70 | Determines whether the motion starts right away or if you have to click play first. 71 | loop # string. 'true' or 'false' (default, false). 72 | Determines whether the motion keeps repeating after one loop over the series, or stops. 73 | width # integer. width of chart in pixels, default 900 74 | height # integer. height of chart in pixels, default 700 75 | varLabels # list. list of labels for columns (default is column headers of dataframe) 76 | Must be of same length as the number of columns in the dataframe, including the index 77 | 78 | ''' 79 | # This defines the motion chart object. 80 | # Basically just holds the parameters used to create the chart: name of data source, which variables to use 81 | def __init__(self, 82 | df = 'df', 83 | title = "Motion Chart", 84 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 85 | key = 1, 86 | x = 2, 87 | y = 3, 88 | size = 4, 89 | color = 5, 90 | category = 5, 91 | xscale='linear', 92 | yscale='linear', 93 | play = 'true', 94 | loop = 'false', 95 | width = 800, 96 | height = 600, 97 | varLabels=None): 98 | self.df = df 99 | self.title = title 100 | self.url = url 101 | self.key = key 102 | self.x = x 103 | self.y = y 104 | self.size = size 105 | self.color = color 106 | self.category = category 107 | self.xscale= xscale 108 | self.yscale= yscale 109 | self.play = play 110 | self.loop = loop # string: 'true' or 'false' (default, false). 111 | self.width = width # width of chart in pixels, default 800 112 | self.height = height # height of chart in pixels, default 400 113 | self.varLabels = varLabels # list of labels for columns (default is column headers of dataframe 114 | 115 | # The informaton from the object is used to generate the HTML string generating the chart 116 | # (inserting the specific information in the object into the template string) 117 | # Note 1: The string is generated in two steps, not one, because future version might want to revise some properties 118 | # without redoing the reformatting and creatingof the dataset from the dataframe 119 | # Note 2: Initially the string itself was saved in the object, although useful sometimes it seems memory greedy 120 | # Note 3: The template string used here is just a revised version of a template somebody else has created 121 | # See Tony Hirst: https://github.com/psychemedia/dataviz4development/tree/master/SocrMotionCharts 122 | def htmlStringStart(self): 123 | socrTemplateStart=''' 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 146 | ''' 147 | # In order to make it easy to use information in the index of the dataframe, the index in the passed dataframe is reset 148 | # For instance: If the time variable is in the index of the dataframe, say the outer index, then one would write 149 | # mc = MotionChart(df, key = 0) when specifying the motion chart 150 | # Note that although the key often is time, it does not have to be so (unlike Google Motion Chart) 151 | # In MotionCharts it is basically whatver variable you want to use to define the change 152 | 153 | df = self.df.reset_index() 154 | 155 | # If variable labels are not specified, the column names of the dataframe is used 156 | # Note. variable levels are specified the list of labels to be used has to have the same number of elements 157 | # as the columns in the reset dataframe (ie. original number of columns plus number of index levels) 158 | if self.varLabels == None: 159 | self.varLabels = df.columns.tolist() 160 | 161 | # Here the data is converted from a pandas dataframe to the format which is accepted by the SocrMotion Chart (javascript) 162 | # The starting point is a json string of all the values in the dataframe, which is then modified fit SocrMotionChart 163 | dataValuesString = df.to_json(orient = 'values') 164 | varNamesString = ",".join(['"' + str(var) + '"' for var in self.varLabels]) 165 | varNamesString = "[[" + varNamesString + "], [" 166 | dataValuesString = dataValuesString.lstrip("[") 167 | socrDataString = varNamesString + dataValuesString 168 | 169 | # The generated string containing the data in the right format, is inserted into the template string 170 | htmlString1 = socrTemplateStart.format( 171 | data = socrDataString, 172 | url = self.url 173 | ) 174 | # Change reference to bootstrap.js file if the url is changed to "custom-bootstrap.js" 175 | # The js available on SOCR's webpage which lists it as boostrap.js, but on GitHub version which many use 176 | # to install a local copy, the same file is referred to as custom-boostrap.js 177 | # The default value is to keep it as 'custom-boostrap.js', but if the url points to socr 178 | # (which is default since we want the chart to work on the web), then the filename is changed to 'bootstrap.js' 179 | if self.url == "http://socr.ucla.edu/htmls/HTML5/MotionChart": 180 | htmlString1 = htmlString1.replace("custom-bootstrap.js", "bootstrap.js") 181 | return htmlString1 182 | 183 | # Generating the last half of the html string which produces the motion chart 184 | # The reason the string is generated in two halfes, is to open up for revisons in which some options are changed 185 | # without having to transfor and generate the data from the dataframe again. 186 | def htmlStringEnd(self): 187 | socrTemplateEnd = '''
188 |
189 | 202 |
203 | 204 | 205 | ''' 206 | # Rename variables to avoid changing the properties of the object when changing strings to numbers 207 | # (NUmbers are required in the js script) 208 | kkey = self.key 209 | xx = self.x 210 | yy = self.y 211 | ssize = self.size 212 | ccolor = self.color 213 | ccategory = self.category 214 | 215 | # The user is free to specify many variables either by location (an integer representing the column number) 216 | # or by name (the column name in the dataframe) 217 | # This means we have to find and replace with column number if the variable is specified as a string since 218 | # the javascript wants integers (note: variable labels must be unique) 219 | # The code below finds and replaces the specified column name (text) with the column number (numeric) 220 | if type(kkey) is str: 221 | kkey=self.varLabels.index(kkey) 222 | if type(xx) is str: 223 | xx=self.varLabels.index(xx) 224 | if type(yy) is str: 225 | yy=self.varLabels.index(yy) 226 | if type(ssize) is str: 227 | ssize=self.varLabels.index(ssize) 228 | if type(ccolor) is str: 229 | ccolor=self.varLabels.index(ccolor) 230 | if type(ccategory) is str: 231 | ccategory=self.varLabels.index(ccategory) 232 | 233 | # The properties are inserted into the last half of the template string 234 | htmlString2 = socrTemplateEnd.format( 235 | title = self.title, 236 | key = kkey, x = xx, y = yy, size = ssize, color = ccolor, category = ccategory, 237 | xscale= self.xscale , yscale= self.yscale, 238 | play = self.play, loop = self.loop, 239 | width = self.width, height = self.height) 240 | return htmlString2 241 | 242 | # Display the motion chart in the browser (start the default browser) 243 | def to_browser(self): 244 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 245 | path = os.path.abspath('temp.html') 246 | url = 'file://' + path 247 | 248 | with open(path, 'w') as f: 249 | f.write(htmlString) 250 | webbrowser.open(url) 251 | 252 | # Display the motion chart in the Ipython notebook 253 | # This is saved to a file because in Python 3 it was difficult to encode the string that could be used in HTML directly 254 | # TODO: Eliminate file (security risk to leave the file on disk, and overwrite danger?) and avoid name conflicts. 255 | # Also: What if multiple figures? 256 | def to_notebook(self, width = 900, height = 700): 257 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 258 | path = os.path.abspath('mc_temp.html') 259 | with open(path, 'w') as f: 260 | f.write(htmlString) 261 | display(IFrame(src="mc_temp.html", width = width, height = height)) 262 | 263 | # Copy the HTML string to the clipboard 264 | def to_clipboard(self): 265 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 266 | pyperclip.copy(htmlString) 267 | 268 | # Save the motion chart as a file (inclulde .html manually if desired) 269 | def to_file(self, path_and_name): 270 | htmlString = self.htmlStringStart() + self.htmlStringEnd() 271 | fileName = path_and_name 272 | try: # encode will not (need not!) work in Python 3 since it is unicode already 273 | fileName = fileName.encode('string-escape') 274 | with open(fileName, 'w') as f: 275 | f.write(htmlString) 276 | except: 277 | with open(fileName, 'w') as f: 278 | f.write(htmlString) 279 | 280 | # Include a demo option 281 | def MotionChartDemo(): 282 | fruitdf = pd.DataFrame([ 283 | ['Apples', '1988-0-1', 1000, 300, 44,'East'], 284 | ['Oranges', '1988-0-1', 1150, 200, 42, 'West'], 285 | ['Bananas', '1988-0-1', 300, 250, 35, 'West'], 286 | ['Apples', '1989-6-1', 1200, 400, 48, 'East'], 287 | ['Oranges', '1989-6-1', 750, 150, 47, 'West'], 288 | ['Bananas', '1989-6-1', 788, 617, 45, 'West']]) 289 | fruitdf.columns = ['fruit', 'time', 'sales', 'price', 'temperature', 'location'] 290 | fruitdf['time'] = pd.to_datetime(fruitdf['time']) 291 | mChart = MotionChart( 292 | df = fruitdf, 293 | url = "http://socr.ucla.edu/htmls/HTML5/MotionChart", 294 | key = 'time', 295 | x = 'price', 296 | y = 'sales', 297 | size = 'temperature', 298 | color = 'fruit', 299 | category = 'location') 300 | mChart.to_browser() -------------------------------------------------------------------------------- /motion-chart_activity/MotionChart Activity/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/motion-chart_activity/MotionChart Activity/setting.png -------------------------------------------------------------------------------- /notes/commands.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/notes/commands.pdf -------------------------------------------------------------------------------- /notes/complete_notes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/notes/complete_notes.pdf -------------------------------------------------------------------------------- /past_exam/FIT1043_Sample_2016.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/past_exam/FIT1043_Sample_2016.pdf -------------------------------------------------------------------------------- /past_exam/FIT1043_Sample_Exam.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/past_exam/FIT1043_Sample_Exam.pdf -------------------------------------------------------------------------------- /past_exam/FIT1043_Sample_Exam_Sols.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itsjunqing/fit1043-introduction-to-data-science/3d3667752be63cbc7b6dc63435a504d18e311651/past_exam/FIT1043_Sample_Exam_Sols.pdf -------------------------------------------------------------------------------- /past_exam/answers.txt: -------------------------------------------------------------------------------- 1 | For multiple choice, you have roughly 1.5 minutes per answer. You 2 | have to quickly figure out which answers are clearly wrong and then 3 | try and rank the remaining. For short answer, you have roughly 3 4 | minutes per short answer question. The answers could be up to double 5 | in length to what is below but wouldn't expect much more. Please 6 | carefully consider your answer before writing it down. Perhaps write 7 | wee bullets outside the box or on the blank paper at the end to try 8 | and get things straight before committing to an answer. 9 | 10 | 11 | Q1.1 is entry D 12 | unless you had some problems understanding the meaning of the 13 | word "characteristics", this should have been obvious 14 | Q1.2 is entry C 15 | B isn't true, if the data are stored in different DBs, then 16 | its hard to run single processing jobs on them because the 17 | DBs will have different record IDS, standards and naming conventions 18 | A is true initially, but probably not in the long run 19 | D is definitely not recommended 20 | Q1.3 is entry B 21 | Q1.4 is entry A 22 | they are very different systems, but A is common; C is not in 23 | RDBMSs, D is not an issue with in-memory DBs, commercial RDBMSs 24 | are not cheap 25 | Q1.5 is entry A 26 | "big" is relative to the task too, which discounts C and D 27 | Q1.6 is entry A 28 | C is wrong; B is an argument some make but not generally believed; 29 | A is argument behind Zimmerman's law 30 | Q1.7 is entry A 31 | B and D is false; C is partly true no doubt; 32 | Q1.8 is entry C 33 | Q1.9 is entry D 34 | all answers a partially true, so which is best? 35 | B and C should be considered silly; A usually applies to XML, JSOn etc. 36 | Q1.10 is entry B 37 | A and C equally apply to RDBMSs; D is a trick answer to try and fool you 38 | Q1.11 is entry B 39 | C and D are instances of p-hacking; both A and B are good, so which is 40 | best? in fact they are very similar ... not a good question, 41 | but B sounds safer 42 | Q1.12 is entry B 43 | one can "check" significance tests using visualisation, but not 44 | perform them 45 | Q1.13 is entry D 46 | A-C were all discussed and mentioned as examples, so that leaves 47 | D 48 | Q1.14 is entry A 49 | C and D partially true; B clearly wrong; A seems best; the word 50 | "primarily" says A is the answer 51 | Q1.15 is entry B 52 | A and C very important; D is handy; B is probably important in 53 | medicine or other sciences more actively using hypothesis testing, 54 | but the issue is "standard" significant levels change ... some use 0.025; 55 | so B is least useful though not entirely useless 56 | 57 | 58 | Q2.1 linked open data? 59 | Linked Open Data is publicly available data that is ``semantically" connected to other data through established relationships. It uses semantic web formats in RDF and XML to store the data. 60 | 61 | Q2.2 metadata? 62 | Meta data describes the format and characteristics and perhaps the source of the data. Without this contextual information, the data itself cannot be interpreted for analysis, nor can the quality of the data be properly considered or anomalous results explained. 63 | 64 | Q2.3 SAS, Datawrangler, Python? 65 | SAS general purpose, strange syntax, commercial. 66 | DataWrangler -- specialised tool, GUI interface, no coding. 67 | Python -- general purpose, open-source, libraries for tasks 68 | 69 | Q2.4 PMML? 70 | This is an XML standard for describing a predictive model, and can be used to pass model between different systems which often have their own internal and proprietary formats otherwise. 71 | 72 | --------------------------------------------------------------------------------