PROGRAMMING AND MACHINE LEARNING FOR BIOLOGICAL DATA Single channel

Chair (Coordinator) and Rapporteur: ALLEGRA VIA

Lecturers

Objectives

After completing the course, learners will be able to:
Run Python programs
Store data in programs
Use built-in functions
Detect syntax errors occurring in programs
Read tabular data
Visualise and statistically analyse tabular data
Plot biological data
Create functions
Repeat actions with loops
Make choices
Determine where errors occurred
Manage errors and exceptions
Make programs readable
Use software that other people have written
Recognize various data formats to represent DNA/RNA sequence data
Independently write Python scripts to
Read in sequence data using Python or BioPython modules
Parse data files
Run external programs
Read input from the command line
Describe a wide range of machine learning techniques
Recognize what machine learning method is most applicable to given data analysis problems
Transform biological data for ML application. In particular, transform sequence data into a machine-readable format for input into a machine learning pipeline
Preprocess Biological Sequence Data for Natural Language Processing
Build a Random Forest model (RF) to classify a set of sequences

Learning outcomes

GENERAL SKILLS

The course aims to teach students Python programming from scratch and, in parallel, to introduce them to the basics of 'traditional' machine learning (ML) in biology. 'Traditional' ML means that the study of artificial neural networks is not included in this course.
In terms of skills, students will be able, by the end of the course, to implement supervised ML steps using the Python language and libraries such as Numpy, Pandas, Matplotlib and Scikit-Learn. In particular, they will be able to import the data, clean the data, split the data (creating training and test sets), implement a machine learning model, cross-validate the model, optimize its hyperparameters and evaluate its performance.
The ambition of this course is to teach students to program in Python and apply what they have learnt to develop a machine learning pipeline, and not to become machine learning experts. However, students who become passionate about the discipline will be given the tools to independently develop the ability to work in the field of ML applied to biological data.

SPECIFIC SKILLS

After completing the course, learners will be able to:

A) Knowledge and understanding
Explain what is a programming language
Describe what it is and how it works the Python interpreter
Describe different options to run Python code
Explain why we use Python 3
Explain why there are many programming language
List Python data types
Given a piece of code, describe (in comments) line by line what each line of code does
List structural components of Python language (e.g. functions, classes and modules)
Explain what is the meaning and usage of “.” (dot) in Python
Describe the purpose of the libraries needed to do ML with Python
Describe a range of machine learning techniques
List the differences between supervised and unsupervised learning
Explain when using a classification or regression algorithm
Make examples of dimensionality reduction
List the reinforcement learning key features
Make an example of reinforcement learning
List the 6 ML steps
Explain what is a training and a test set


B) Applying knowledge and understanding

Assign a value to a variable
Use an index to get a single character from a string
Use a slice to get a substring
Use the built-in function type() to identify data types
Write and run code on a Jupyter Notebook and/or Google Colab
Given a piece of pseudo code, write and debug the corresponding code
Use data type methods
Import libraries
Call (use) functions from an imported library
Import specific items from a library module
Give a library a short alias when importing it
Create and index lists
Change the values of individual list elements
Append values to an existing list
Reorder and slice list elements
Create and manipulate nested lists
Create a Python dictionary
Assign a dictionary item
Use at least one dictionary method
Use indentation to create an if block
Use booleans True and False in if conditions
Use >, <, >=, <=, === operators

Read data from a csv file into a Python Data Frame
Read a csv table from a URL into a pandas Data Frame
Create a Series and a DataFrame from Python dict
Explore and select data from Data Frames
Loop on a sequence of items and print each item
Loop on a pandas Series
Loop on a column of a pandas DataFrame
Replace non numerical values with NaN
Download a dataset from the Kaggle database
Implement ML models using the Scikit-Learn Python library

C) Making judgements

Given a dataset, decide if it is suitable for supervised learning or not
If yes, indicate whether classification or regression should be used
Recognize what machine learning algorithm is most applicable to given data analysis problems
Manage errors and exceptions
Assess the performance of a ML model.
Improve the performance of a ML model.

Prerequisites

A biological or biomedical background. Knowledge of a variety of biological data and questions.
For the Programming module, no previous experience is necessary, however, you need to understand the concepts of files and directories and how to access your Google Drive.
Familiarity with at least one of the main OS (Linux, Mac OSX, Windows 10) is required.
To be able to complete Module 3 (Advanced programming), the achievement of Modules 1 (Introduction) and 2 (Fundamentals) learning outcomes is a prerequisite.

Programme

Programming and Machine Learning for Biological Data (PMLBD)

Modern biological methods — high-throughput sequencing in particular — now generate unprecedented volumes of data. Extracting meaningful information from this data, and asking the right research questions, requires skills in data mining, artificial intelligence, and deep learning.
The course is organised into three progressive modules, complemented by hands-on activities and individual assignments, and concludes with a 4-hour final session dedicated to an exam simulation.
MODULE 1 — Introduction
Course kick-off
Presentation of the syllabus, working methods, and course tools; getting to know the class through a diagnostic questionnaire on background, expectations, and prior knowledge.
Python programming
Introduction to the language and the Python interpreter; overview of the different ways to run Python code (interactive shell, terminal scripts, code editors, IDEs, notebooks); setting up the working environment with Google Colab and, alternatively, Anaconda/Jupyter Lab.
Machine Learning
Core concepts: what ML is, its relationship with artificial intelligence, how it differs from traditional programming, and why it matters for biological data. Introduction to data science, with a brief historical overview of the evolution of data.
MODULE 2 — Fundamentals
Python basics
Variables and assignment; data types (numbers, strings, lists, tuples, dictionaries, sets); built-in functions and methods; importing modules and libraries; for loops and conditional structures; basic debugging. Introduction to core data-analysis libraries — NumPy, Pandas, and Matplotlib — with a focus on manipulating tabular data through Pandas DataFrames and visualising results.
ML fundamentals
Main types of machine learning; key concepts such as supervised and unsupervised learning, classification, regression, clustering, classes and labels, and training/validation/test splits. Presentation of the six fundamental steps of an ML project:

Importing the data
Cleaning the data
Splitting into training and test sets
Building a model
Checking the output
Improving performance

MODULE 3 — Advanced Programming
Advanced Python
File handling (reading and writing in different modes); writing custom functions; introduction to object-oriented programming (classes).
Advanced Machine Learning
Building solid training datasets through data preprocessing; the K-Nearest Neighbors (KNN) algorithm; model creation and validation via k-fold cross-validation; hyperparameter tuning; comparing multiple classification algorithms (KNN, Random Forest, Logistic Regression, XGBoost, Decision Tree); diagnosing overfitting, underfitting, and data leakage; handling class imbalance; model interpretability through SHAP analysis; feature engineering, selection, and reduction techniques.
Hands-on activities
Each module includes guided exercises (live coding), group work, class discussions, and weekly homework, including the progressive development of a personal data science project that accompanies students throughout the course.

Books

Sebastian Raschka - Introduction to Machine Learning
https://sebastianraschka.com/resources/ml-lectures-1/

Sebastian Raschka, Yuxi Liu, Vahid Mirjalili
Machine Learning with PyTorch and Scikit-Learn: Develop machine learning and deep learning models with Python (ISBN-10: 1801819319 ISBN-13: 978-1801819312)

Further learning materials (including slides, tutorials, videos, notes, and extracts from text books, examples, scripts) will be provided before and during the course by the teacher.

Lessons mode

Learning outcomes (LOs) will guide the design of learning experiences (LEs). For the achievement of each LO, the most appropriate LE(s) will be identified and planned.
Learning experiences will include, depending on the Dublin descriptors involved:
Very brief interactive lectures on the main concept of programming and machine learning;
Participatory live coding sessions;
Hands-on coding sessions (individual or in pairs/groups) where students will have to independently use Python programming to solve data handling problems and implement ML algorithms;

Frequency

The course is fully practical. It is strongly recommended to attend class in order to acquire the skills required to successfully achieve learning outcomes and pass the exam.

Exam mode

Achievement of the course learning outcomes (LOs) will be evaluated through two components.
The first component is a data science project discussion. Students who attend the course are expected to discuss their project progressively during the course and, where possible, before the written exam. Students whose project does not meet the required standard will discuss it immediately after the written exam. The project discussion is designed to assess the achievement of the Machine Learning LOs, as well as students' critical thinking in the choice of a dataset, its pre-processing, and the use of data across all phases of a machine learning protocol.
The second component is a written exam, which assesses the achievement of the Python programming learning outcomes.
Each component is described in detail below.

DATA SCIENCE PROJECT
You will carry out a data science project in which you choose a dataset, analyse it, and apply a complete machine learning (ML) workflow. The project must be developed in a Colab or Jupyter notebook and uploaded to a dedicated Google Drive folder before the discussion with the teacher.
1. Dataset selection Choose a dataset you are genuinely interested in exploring. You may use Kaggle or any other suitable resource. Before starting your analysis, share your choice with the teacher to confirm that the dataset is appropriate in terms of complexity and scope.
2. Notebook structure and content Your notebook must include the following sections, in order:
Objective — clearly state the aim of your study and explain why you chose this particular dataset
Dataset description — provide a thorough analytical description of the data (variables, size, source, known limitations, etc.)
Pre-processing — describe and justify all steps taken to clean, transform, and organise the data
Exploratory data analysis — visualise and describe the main features and patterns in the data
ML workflow — apply a complete ML protocol (a reference workflow is available here); for each step, from model selection to performance evaluation, explain your choices and the strategy adopted
Results and critical discussion — present the outcomes of your analysis and critically discuss your findings, including limitations and possible improvements
3. Documentation Every step of your analysis must be clearly described and explained. Every choice must be justified. The notebook should read as a coherent, self-contained report, understandable to someone who was not present at the discussion.

Written Exam (2h30)

The written exam consists of two exercises assessing your Python programming skills and your ability to work critically with AI-generated code.
Exercise 1 — From pseudocode to Python
You will be given a pseudocode — a sequence of instructions written in plain English — and asked to translate it into working Python code. The exercise has two stages:
Stage 1 (pen and paper): Write your Python translation by hand, without running it.
Stage 2 (notebook): Transcribe your handwritten code into a notebook and run it. Document all errors produced by the Python interpreter directly in the notebook, explaining what caused each error and how you resolved it. This stage also assesses your debugging skills.
Exercise 2 — Prompt engineering and critical code comparison
You will be given a printed Python script written by the instructor. Your task is to:
Write a ChatGPT prompt designed to reproduce that script as precisely as possible
Submit your prompt to ChatGPT and compare its output with the original script
Annotate and explain any discrepancies between the two versions, discussing why they may have occurred
This exercise assesses both your ability to communicate programming tasks effectively to an AI tool and your capacity to critically evaluate AI-generated code.

Example exam questions

EXERCISE 1
1. Write, on a sheet of paper, the code for the pseudocode below.
2. When you are done, copy the code to a Jupyter Notebook (or any other software you know to run Python code), run and debug the code. Advice: debug the code step-by-
step using print() to print every new variable you define, or any time it makes sense to print something. This is a basic and a bit wild approach to debugging, but it
works!
3. Annotate on the same sheet of paper – using different colour or writing style - the errors you made and what you did to correct them.

EXERCISE 2:
1. Write on a sheet of paper the optimal prompt (for ChatGPT or Copilot) tailored to generate exactly the following Python code — same structure, logic, formatting, and comments;
2. When you are done, submit your prompt to ChatGPT, compare the AI generated code with the one below and annotate the conceptual differences, if any.

Arguments

  • https://sites.google.com/uniroma1.it/pmlbdsapienza/home

  • https://swcarpentry.github.io/python-novice-gapminder/

  • Sebastian Raschka, Yuxi Liu, Vahid MirjaliliMachine Learning with PyTorch and Scikit-Learn: Develop machine learning and deep learning models with Python (ISBN-10: 1801819319 ISBN-13: 978-1801819312)

Sustainability goals

  • Goal4
  • Goal5
  • Goal10
  • Academic year2026/2027
  • Degree program to which the course belongsGenetics and Molecular Biology
  • Lesson code10628794
  • Year and semester1st year - 2nd semester
  • Activity typeAttività formative affini ed integrative
  • Academic areaAttività formative affini o integrative
  • SSDBIOS-07/A
  • Mandatory presenceNo
  • Languageeng
  • CFU6 CFU
  • Total duration56 hours
  • Hours distribution32 classroom hours, 24 training hours