Seminar Data Science With Python
Seminar Data Science With Python
Course timetable
Learning outcomes
Python
Jupyter Notebooks
Data Science
Machine Learning
Scientific writing and presentation
Scientific Writing
Structure of the Seminar Jupyter Notebook
With this seminar, you can learn the terminology, methodologies and tools used for machine
learning or data science in general. You should learn how to define a problem, how to prepare
data, how to evaluate algorithms, how to improve data analysis workflows and how to present and
visualise results. We don’t want you to just prepare a text and presentation by searching the
Internet for material. Instead, we want you to experiment and code, preparing the report as a
documentation of your data analysis.
You find below a selection of ‘case studies’, from which each student selects one. The goal of the
seminar is to prepare a Jupyter notebook using Python to analyse the data and describe the data
and their analysis in the style of a scientific report.
We do not expect any prior experience with Python. Instead, the seminar is an opportunity to learn
Python and Jupyiter notebooks. This document provides all information on the course content, it’s
realisation, marking and links to material and further information.
See StudIP for information on the course. The meetings may take place online. A link to join the
video conference will be posted on StudIP.
With your participation you accept the rules and regulations associated with online lectures and
exams, as set out by the university and faculty, including the use of Zoom or BigBlueButton
Software.
Mit der Teilnahme an dem Kurs erklären Sie dass Sie den „Leitfaden zur Durchführung von
Online-Kolloquien“ der Universität Rostock gelesen haben und mit den genannten Bedingungen
einverstanden sind. Mit der Nutzung der Plattform Zoom sind Sie mit der Teilnahme für die
Prüfung und den sich daraus ergebenden Datenschutzbestimmungen ebenfalls einverstanden.
Course timetable
Always check StudIP for up-to-date information on this seminar.
During the first meeting each student will be assigned to one case study (described below). The
deadline for the submission of the Jupyter Notebooks is the 1st of July (Send these to
[Link]@[Link]). During the last meeting each student, or group, will present their
Case Study with one slide only, and max 250 words presentation. The content or structure of the
presentation is discussed below.
Learning outcomes
With this seminar, we are pursuing several learning outcomes. The goal is to introduce you to:
Python
Python is a popular and powerful interpreted language. Unlike R, which is also widely used for data
analysis, Python is a complete general-purpose language and platform that can be used for both
research and general software development. It supports multiple programming paradigms,
including structured (particularly, procedural), object-oriented, and functional programming.
Python’s Wikipedia entry provides a nice overview and history. It is fair to say that Python, across
many areas of science and industry has become the most popular language in recent years.
Jupyter Notebooks
Project Jupyter is a nonprofit organization created that supports execution environments for
programming languages including Julia, Python and R. A Jupyter Notebook is an interactive
computational environment, in which you can combine code execution, rich text, mathematics,
plots and rich media. The Jupyter Notebook is a web application that allows you to create and
share documents that contain live code, equations, visualizations and narrative text. Uses include:
data processing, numerical simulation, statistical modeling, data visualization, machine learning.
For our purposes we focus on using it for data analysis with Python. Jupyter Notebooks use the
Markdown language for formatting the text. Markdown has become a popular choice and is used in
an increasing number of contexts. Note: There is also something called JupyterLab, which is a
‘next version’ Jupyter Notebook. Both are browser-based and pretty much the same for the
purpose of this seminar. If you want a stand-alone Python programming environment, that can also
edit Jupyter Notebooks, PyCharm by JetBrains is an option. They offer a free edu version.
Data Science
Data Science is an interdisciplinary field that combines programming and computer science
methodologies with data analysis and statistical data. A data scientist explores datza for real world
applications, drawing from a wide range of tools and methodologies. The most important skill of a
data scientist is to have an appreciation for a wide range of techniques, from computer science,
statistics, and machine learning. The processing of data, analysis and visualisation has become a
core competency in information or knowledge-based societies and business. A data scientist has
knowledge of the mathematical and statistical foundations, and is yet not afraid to get his/her
hands dirty with real, messy data.
Machine Learning
Machine learning (ML) is the study of computer algorithms that can learn from data. Machine
learning algorithms are also at the core of Artificial Intelligence. Given a set of “training data”,
machine learning algorithms build a model that can be used for decision making and predictions.
Machine learning approaches can be roughly divided into four broad categories: Supervised
learning, Unsupervised learning, Reinforcement learning and Deep learning. Dimensionality
reduction, clustering, classification and regression analysis are key concepts required for practical
applications. Machine learning and artificial intelligence have become dominant fields, driving a
variety of businesses, with spectacular developments over the last ten years or so.
Note: The list of objectives for this seminar is long. The links with background material provided
below, can be overwhelming. Learning Python can easily fill a whole semester, and this seminar
gives you about one month to use Python for Machine Learning … We should thus be clear that
this seminar will be a challenge, even for second semester computer science students. Remember
therefore that you are embarking on a learning process and that errors, and error messages in
particular, are perfectly normal. They are part of the learning process. You are not implementing or
coding machine learning algorithms, but using existing functions to analyse data. Nevertheless,
you should know that error messages are fine. Everyone gets them ... all the time. Often it is a
syntax issue like missing brackets or a missing space. You can trust the "error message", it will
give you a lead to its solution. If you are stuck, speak to fellow students, or add stack overflow as a
resource. You may copy paste the error message into Google or add a new thread on
stackoverflow. Most of us never had to create a new thread in Stackoverflow ... any error they may
run into - someone else had before and you can find solutions online.
The data scientist workflow we have in mind for this seminar has been described nicely in a Python
tutorial by Jason Brownlee. If you want to dig deeper, learning Python and/or data analysis,
machine learning and AI techniques, we recommend looking at Jason Brownlee’s webpage for free
tutorials but also excellent eBooks, with many practical examples.
It is not necessary to study all the links below. To start with, you need to install Python and Jupyter
Notebooks. This can be done in various ways (Installing Jupyter Notebook, Anaconda Python/R
Distribution - Free Download) and here is a quick guide:
How to Setup Your Python Environment for Machine Learning with Anaconda
There is also something called JupyterLab, which is a ‘next version’ Jupyter Notebook. Both are
browser-based and pretty much the same for the purpose of this seminar. If you want a
stand-alone Python programming environment, that can also edit Jupyter Notebooks, PyCharm by
JetBrains is an option. They offer a free edu version.
More recently, we have successfully used Google Colab to edit and run Jupyter Notebooks - with
not need to install an IDE or Python! If you run into problem with the installations, or you do not
wish to install anything, you can complete this seminar using just a web browser.
Python
Welcome to [Link]
Jupyter notebooks
The Jupyter Notebook
NumPy — NumPy
Data Visualisation with Python
Bokeh 2.0.1 Documentation
The dataset in Jason Brownlee’s tutorial contains 150 observations of iris flowers. There are four
columns of measurements of the flowers in centimeters. The fifth column is the species of the
flower observed. All observed flowers belong to one of three species. You can learn more about
the “Iris flower data set” on Wikipedia. This dataset has become a famous example, widely used in
data science training. For the case studies below, we shall also use well known benchmark
datasets. You can load many well known benchmark datasets directly from the UCI Machine
Learning Repository.
Jason Brownlee has made available another tutorial, for a step-by-step coding of the k nearest
neighbor algorithm, also using the Iris data set. This tutorial demonstrates nicely the workflow we
would like you to develop, in which the notebook becomes a documentation of your learning and
experimentation.
NOTE: For any ML related tool, a google search of ‘how to use XX using sklearn’ should guide you
to examples of using the tool XX.
What we recommend
● Watching youtube tutorials. For example
○ Scikit-Learn Tutorial | Machine Learning With Scikit-Learn | Sklearn | Python Tutorial
| Simplilearn
○ Complete Python Pandas Data Science Tutorial! (Reading CSV/Excel files, Sorting,
Filtering, Groupby)
○ Complete Python NumPy Tutorial (Creating Arrays, Indexing, Math, Statistics,
Reshaping)
○ Matplotlib Tutorial (Part 1): Creating and Customizing Our First Plots
Also watch tutorials relevant to your topics.
● Interaction among module mates. Keep in touch with your colleagues dealing with the same
model. Some models are basic and some are more advanced. We tried to distribute them
in a way such that the workload is uniform. Nevertheless, interacting with your colleagues
dealing with the same module will make your job easier.
We we expect
● Within each notebook, at least a one page discussion on each model, based on your
literature research and understanding. You might not be able to grasp all the mathematics
and theory for the models but you should be able to grasp the philosophy of the model -
what it is intended for, how it relates to and compares with other algorithms.
● Mention two or three pros and two or three cons of the models you are studying.
● Provide reference (online articles or research papers) to the statements you write. This is a
good scientific practice.
However, the beauty of Jupyter Notebooks is that it combines coding with documentation and
writing. That means, using Jupyter Notebooks allows you to document your coding and analysis
workflow. This makes everything you programme more accessible and reproducible. Code used to
be something tugged to the end of a report. With Jupyter Notebooks you can tell the story of your
coding and analysis, while coding and running algorithms.
The structure of project reports and scientific publication, however, have one characteristic that
contradicts our idea of using Jupyter Notebooks: In reports and publications you summarise the
results of your work, without spending much effort on documenting the actual workflows, including
mistakes made, falsely chosen directions, and dead alleys. Often these experiments are what
provide the greatest learning opportunities.
Ensure there is a red-line going through your notebook, connecting each section. Ideally, your
notebook is read like a story, from beginning to end, with no need to jump forth or back. Remember
to connect sections, focussing on the last and first paragraphs. Each paragraph should contain one
and only one message. The first sentence of a paragraph is the “topic position”, giving context,
motivation and background, while the last sentence of a paragraph is the “stress position”, where
the reader expects the central message that is arising from the paragraph. Try to raise interest,
wherever possible, consider an engaging conversational style. It is often good to imagine you
explain something to your partner, friend or colleague. We want you to create textbook examples
that would show a learner how data are analysed with Python. We hope that you enjoy this
experience - not just copying any report together but sharing your learning experience and also
code and analyse data!
Module I: Supervised Learning
Goal: Module I is about attaining a working knowledge on Supervised Learning algorithms. The
dataset you will use to test the performance of your model is the MNIST dataset which is one of the
basic datasets to be explored by beginners in the field of Machine learning. This dataset is about
classifying handwritten digits (learn more from MNIST database). You can download the dataset
from MNIST in CSV. Each of you have been assigned to work on two ML models.
Experiment Design: Machine learning models are prone to overfitting. The experiments have to
be carefully designed to ensure that your model’s predictive ability is robust to randomness. You
will first train your models with the 5x5-fold stratified cross validation protocol (using only the
training data and using parameter optimization using RandomizedSearchCV
sklearn.model_selection.RandomizedSearchCV — scikit-learn 0.22.2 documentation). Once you
ensure that your model is not overfitting, you will train your model with the entire training data (with
best parameter settings obtained using RandomizedSearchCV) and then validate your model with
the test data available. The performance measures you will use are: Accuracy score and
Confusion matrix.
LGBM is a more recent and advanced model from Microsoft. You might not get too many materials
for understanding its theory. However it is related to models like ADABoost, Gradient Boosting and
XG-Boost. Interact with your colleagues dealing with these to understand it better. Focus on the
applications this model has found. Begin here: Boosting Machine Learning Tutorial | Adaptive
Boosting, Gradient Boosting, XGBoost | Edureka.
Support Vector Machine (SVM) is a more advanced and usually better performing model. There
has been a lot of research on this model. Learn about the Kernel-trick and several kernels for this
model and implement them in your code. Learn how to make SVM faster. Begin your journey with
these:
● Support Vector Machine - How Support Vector Machine Works | SVM In Machine Learning
| Simplilearn
● Support Vector Machines, Clearly Explained!!!
● 16. Learning: Support Vector Machines
● MNIST dataset: This dataset is about classifying handwritten digits (learn more from
MNIST database). You can download the dataset from MNIST in CSV. Each of you have
been assigned to work on two ML models.
● Credit Fraud dataset: This dataset is from a kaggle competition. This is an imbalanced
dataset with very few examples of credit fraud. you can find the details dataset in Credit
Card Fraud Detection
● Swiss Roll dataset: Swiss roll dataset can be produced using scikitlearn using Swiss Roll
reduction with LLE — scikit-learn 0.22.2 documentation. You can produce such a dataset
specifying the number of data points you would like to produce. You can try this with 2000
data points.
Experiment Design: For this module, you are expected to generate 2-D and 3-D reduction plots
for the given data sets. In case the datasets are labelled, you have to use the unlabelled versions
to create the plots. But you can use the labels to color code the plots to view the clusters in your
data.
Try and implement the algorithms for the given three datasets and try to visualize the difference
you see. Comment on this in your Jupyter notebook.
Implement the algorithms for your datasets and compare the results.
Understand what the algorithm adopts from its predecessors like PCA, ISOMAP, t-SNE. Use it for
the three datasets with several parameter settings for ‘metric’, ‘n-neighbours’ etc and comment on
your experiences with these. This link is also going to be very useful:
Since you have one model to deal with, you are expected to submit a two-page report on this
model. It is quite an advanced model, so you will have enough materials
Case Study 9: LLE
Locally linear embedding(LLE) is a vastly popular dimension reduction method. It has several
variants such as Hessian EigenMapping, Local tangent space alignment. You might try coding for
these variants using the ‘method’ parameter in scikit-learn documentation and compare their
performances. Read more about the algorithms from
● Locally Linear Embedding
● Ali Ghodsi, Lec 4: MDS, Isomap, LLE
● 23 Reducing dimensions Local Linear Embedding
● Locally Linear Embedding Python tutorial
Since you have one model to deal with, you are expected to submit a two-page report on this
model. It is quite an advanced model, so you will have enough materials
For the credit fraud dataset you need to use the Random Forest classification algorithm with
default parameters. Although this is not needed for this module, in case you want to learn more
about the algorithms interact with your Module I colleagues or see the videos:
● Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Data Science
|Simplilearn
● Random Forest Algorithm - Random Forest Explained | Random Forest in Machine
Learning | Simplilearn
For the mammography dataset use the knn classification algorithm with k=30. In case you are
curious about the model, watch this : KNN Algorithm - How KNN Algorithm Works With Example |
Data Science For Beginners | Simplilearn.
There are several approaches to handle class imbalance. You will be exploring oversampling
approaches. Each of you will explore two oversampling algorithms. You will read about the
algorithms from respective research papers and then implement the oversampling algorithms on
the above mentioned datasets using respective classification algorithms as instructed above. You
DO NOT need to tune parameters for the classification algorithms. For your respective
oversampling algorithms, if there is a parameter: n_neighbour or k_neighbour, please use 30 as its
value. For this module you need to explore two special libraries:
● smote-variants
● Welcome to imbalanced-learn documentation! — imbalanced-learn 0.5.0 documentation
These libraries will be sufficient for the implementation of all algorithms assigned to you (especially
the first link(smote-variants)). To make coding easier follow: SMOTE with Imbalance Data
Experiment Design: Machine learning models are prone to overfitting. The experiments have to
be carefully designed to ensure that your model’s predictive ability is robust to randomness. You
will first train and test your models with the 5x5-fold stratified cross validation protocol. Present the
average performance for all the folds. Use performance measures: F1-Score, Kappa Score,
Balanced Accuracy, see: [Link]. Generate necessary plots to compare the three scores
between two models you used. Also Generate, PCA and UMAP plots for the oversampled data
color coding the labels to visualize the oversampling pattern. Be in touch with your Module II
colleagues who are dealing with these topics specifically.
It turns out that all these forms of communication (elevator pitch, poster presentations, paper
abstract etc) can be structured by answering the following questions:
1. W
hat is the context?
a. O
ne sentence clearly stating the general problem.
b. I dentify a research gap, and raise interest through selected wording.
hat will come out? (For papers, posters: What has come out?)
4. W
a. One sentence summarising the expected outcomes. (For papers, posters: What are
the results?)
b. One sentence explaining what the main results reveals in direct comparison to what
was thought to be the case previously, or how the main result adds to previous
knowledge.
5. W
hat is the value?
a. One sentence to put the results into a more general context, indicating the
(potential) impact of the work.
b. One sentence to provide a broader perspective, readily comprehensible to a
scientist in any discipline.
If you answer these questions, you will never again worry about summarising your work. At the end
of this seminar, you should be ready to give an oral summary of your project.
During the last meeting each student, or group, will present their Case Study with one slide only,
and max 250 words presentation. We urge you to follow the structure above.
Scientific Writing
We here provide guidance for scientific writing in general. See below our comments on how for this
seminar, things differ slightly.
Author
● Name, affiliation, Email address.
Abstract
● Try to structure the abstract by answering the following question (appr one sentence per
question):
○ What is the context or background of the case study?
○ What is the challenge, research question, addressed?
○ What methods, tools and methodologies are used?
○ What are the results from the analysis?
○ What is the use, value, or application?
● The abstract should be about 150 words, max 200 words.
Keywords
● max 5.
Introductory Part
● State the question you wish to address.
● Describe how this question arises from its context.
● State how you are going to focus on the subject.
● State the objectives and the approach taken.
● Outline the report.
Methodology
● Argue a roadmap for the project, decide upon the approach taken and the methodologies
employed.
● Justify the approach by relating to the literature. Compare and contrast methods, algorithms
and tools.
Conclusions
● What can be concluded from the case study and the results of the analysis?
● Given the opportunity, what could/should be done differently?
● State open problems, make recommendations for future directions of the work.
The beauty of Jupyter Notebooks is that it combines coding with documentation and writing. Some
of the best known Python textbooks are entirely written as Jupyter Notebooks. The structure for a
scientific report or publication, given above, has one characteristic that does not fit our purpose
well. When one is presenting a work, say in a publication, the process through which methods
were implemented, the construction of analysis pipelines (workflows) is not described. What is
described are the methods and results, but not how one actually got to this outcome.
In our case, where we look at textbook examples for the analysis of datasets, the main emphasis
will be on documenting the “workflow” and “train of thoughts” that a data scientist follows in
analysing data. We want you to create textbook examples that would show a learner how data are
analysed with Python.
The data scientist workflow we have in mind for this seminar has been described nicely in a Python
tutorial by Jason Brownlee See also another tutorial by him, showing nicely how one can use
Jupyter Notebooks for an engaging documentation of a data science workflow.
In order to give you an idea of what is expected, we are going to adapt the following general
guidelines for marking written works, including dissertations, final year projects etc.
All aspects are weighted equally, except technical achievements which are weighted twice as
much as any other category.
● 100% would correspond to work, in that aspect, that reaches the highest standards that
could be expected of a professional scientist with experience. Contains all of the relevant
information with no errors or only insignificant errors. Displays excellent understanding of
the subject within a wider context. Gives extensive evidence of critical awareness and
independent thinking.
● 80% corresponds to work that is, in that aspect, mainly of professional standard, but has
few shortfalls. Displays good understanding of the subject within a wider context. Has
reached beyond the essential material.
● 60% corresponds to work which has, in that aspect, both strong and weak features with the
stronger features being in the majority. Less evidence for critical awareness and
independent thinking.
● 40% corresponds to work that is marginally satisfactory in that aspect. There are several
failings, but there are also some achievements and positive features. Little evidence of
critical awareness and independent thinking. Lack of evidence for a deeper understanding
of the subject within a wider context.
Translation into course marks
Mark % Criteria
failed 30-39 Deficient, many omissions or errors, expression and argument poor.
Note: What we are looking for are notebooks that are fun and easy to read, provide clear
instructions and encourage the reader to use Python. We want you to learn Python yourself and
then share your learning experience. You may draw from examples and ideas related to these
datasets on the Internet but try to be creative in how you describe and present the case studies
and their analysis. Compare and contrast the method, tools and algorithms used.
Also note that many of the algorithms that you are to encounter in this course are mathematically
quite advanced. We thus do not expect you to understand these in full mathematical rigor. The
implementation however, is quite straightforward. If you refer to the provided materials properly
and do a bit of research, then this should not be very difficult. To get a headstart refer to the
materials
○ [Link]
○ [Link]
We assure you that 70% of your marks will come from the implementation and coding part which
will be judged from your Jupyter notebooks. 30% of your marks will be judged for the effort that you
put in understanding the algorithm that is the two page report that you are required to submit on
your understanding of the algorithms.