## Algorithmic Methods of Data Mining (Sc.M. in Data Science)

## Academic year 2023–2024

"The success of companies like Google, Facebook, Amazon, and Netflix, not to mention Wall Street firms and industries from manufacturing and retail to healthcare, is increasingly driven by better tools for extracting meaning from very large quantities of data. 'Data Scientist' is now the hottest job title in Silicon Valley."– Tim O'Reilly

- Data Scientist: The Sexiest Job of the 21st Century
- Find true love with data mining

The course will develop the basic algorithmic techniques for data analysis and mining, with emphasis on massive data sets such as large network data. It will cover the main theoretical and practical aspects behind data mining.

The goal of the course is twofold. First, it will present the main theory behind the analysis of data. Second, it will be hands-on and at the end students will become familiar with various state-of-the-art tools and techniques for analyzing data.

We will cover some very basic topics necessary for handling large data, such as hashing, sorting, graphs, data structures, and databases. We will then move to more advanced data mining topics: text mining, clustering, classification, mining of frequent itemsets, graph mining, visualization.

The theoretical part will be complemented by a laboratory where students will learn how to use tools for analyzing and mining large data. We will base it on Amazon's AWS. After finishing the course, the students will have a large part of the knowledge required to pursue (independently) for an Amazon AWS Certification.

### Announcements

The fifth homework is out. It is due on January 7.

The deadline for the third homework has been extended to December 17.

The fourth homework is out. It is due on December 10.

The third homework is out. It is due on November 26.

The deadline for the second homework has been extended to November 5.

The second homework is out. It is due on October 29.

The first homework is out. It is due on October 15.

You **need to register** to:

- the class mailing list to be able to do homeworks, be part of groups, receive announcements, etc.: Send email to Aris.
- Amazon Web Services (AWS): Ioannis will open an account for you and provide you with details.
- Slack: Send email to Daniel.

### Instructors

Aris Anagnostopoulos, Sapienza University of Rome.

Ioannis Chatzigiannakis, Sapienza University of Rome.

### Teaching Assistants (TA)

The best way to ask any questions is through slack. If you are registered in the course mailing list and have not received an invitation from Daniel, email Daniel.

Daniel Jiménez (This email address is being protected from spambots. You need JavaScript enabled to view it. ), Ph.D. candidate in Data Science, Sapienza University of Rome. (LinkedIn)

Leonardo Di Nino, (This email address is being protected from spambots. You need JavaScript enabled to view it. ) Data Science student, Sapienza University of Rome. (LinkedIn)

Mehrdad Hassanzadeh (This email address is being protected from spambots. You need JavaScript enabled to view it. ), Data Science student, Sapienza University of Rome. (LinkedIn)

Sara Pepe (This email address is being protected from spambots. You need JavaScript enabled to view it. ), Data Science student, Sapienza University of Rome. (LinkedIn)

Eric Rubia Aguilera, (This email address is being protected from spambots. You need JavaScript enabled to view it. ) Data Science student, Sapienza University of Rome. (LinkedIn)

### When and where:

Monday 14.00–16.00, Via di Castro Laurenziano 7a (Building RM018), Room 3

Thursday 14.00–16.00, Via di Castro Laurenziano 7a (Building RM018), Room 6.

Lab: Tuesday 15.00–19.00, Via Tiburtina 205, Room 17.

### Online lectures

There will not be lectures online, only in class.

### Office hours

You can use the office hours for any question regarding the class material, past or current homeworks, general questions on data mining, the meaning of life, pretty much anything. Send an email to the TAs and, if needed, to the instructors for arrangement.

### Textbook and references

We will use a variety of textbooks. Whenever we can, we will try to find books that are available online. As the course progresses, we will indicate what you should read. The main books that we will use are the:

- (A) C. Aggarwal, "Data Mining: The Textbook," Springer (must be downloaded from Sapienza)
- (ZAL) R. Zafarani, M. A. Abbasi, and H. Liu, "Social Media Mining: An Introduction," Cambridge University Press
- (LRU) J. Leskovec, A. Rajaraman, and J. Ullman, "Mining of Massive Datasets," Cambridge University Press
- (MRS) C. D. Manning, P. Raghavan and H. Schütze, "Introduction to Information Retrieval," Cambridge University Press
- (J) J. Janssens, "Data Science at the Command Line", O'Reilly

In addition, we will cover material from various other sources, which we will post online as the course proceeds.

If you are interested in the topic of algorithms, we recommend the following books:

- T. Cormen, C. Leiserson, R. Rivest, and S. Stein, "Introduction to Algorithms" (4th ed): This is a classic book, very detailed, sometimes too verbose
- S. Dasgupta, C. Papadimitriou, and U. Vazirani, "Algorithms": Very succint but well written, probably the first book to check out. If you cannot follow it, try one of the other books first
- T. Roughgarden, "Algorithms Illuminated": Another introductory text. It is a more recent book. Tim writes very well.
- J. Kleinberg, and E. Tardos, "Algorithm Design": This is a more advanced book, probably not recommended if it is your first contanct with algorithms, but will increase your knowledge a lot if you already know the basic concepts.

### Python resources

The main programming language that we will use in the course is Python 3.

To learn the language you can find a lot of material online. You can start from Python's documentation site: https://www.python.org/doc/.

If you would like to buy some books, you can check the

- "Learning Python, 5th edition," by Mark Lutz. It is a bit verbose, but it presents well the features of the language.
- "Python Pocket Reference, 5th edition," by Mark Lutz. It is usefull as a quick reference if you know more or less the language and you are searching for some information.

We will use several libraries in the class. For Windows users the Anaconda distribution has packaged all of them together and you can download it for free. For MAC/Linux users, all packages can be installed using the **pip3** tool.

We will also use Python (Jupyter) notebooks. You can find instructions for the installation at the Jupyter web site.

If you have problems with Python installation you can obtain an ubuntu virtual machine with Python preinstalled. Contact the instructor for more information.

### Syllabus

Chapters for which no book is mentioned refer to the "Mining of Massive Datasets" (see below). For the other textbooks, we refer to with the author initials: A, ZAL, MRS.

Date |
Topic |
Reading |

September 25 | Introduction to data science, Introduction to algorithmic data mining | Introduction to Sapienza's Data Science, Introduction to data mining |

September 28 | Basic data types, introduction to the analysis of algorithms | Notes, Section 5–5.3 |

October 9 | Introduction to the analysis of algorithms (Big O notation cont.) | Notes, Section 5.2–5.4 |

October 10 | Introduction to Data Pre-processing & Data Visualization | Laboratory 1: Data Pre-processing & Data Visualization The Pandas DataFrame: Make Working With Data Delightful |

October 12 | Introduction to the analysis of algorithms (recursion) | Notes, Section 5.5 |

October 16 | Complexity classes and NP-completeness | Notes, Section 6–6.1 |

October 17 | Introduction to cloud computing Introduction to AWS, AWS Academy, S3 |
Laboratory 2: Introductory course to AWS Cloud and S3 |

October 19 | NP-completeness (cont.), Introduction to distance measures | Notes, Section 6.2, (LRU) Chapter 3.5 |

October 23 | The vector-space model for document similarity | (MRS) Section 6.3 |

October 24 | Introduction to AWS EC2, Unix Shell Programming |
Laboratory 3a: Introductory to AWS EC2 |

October 30 | Distance measures (cont.) | |

October 31 | Introduction to HTML Introduction to Web Scraping |
Laboratory 4: Web Scrapping Introduction to HTML5 Structuring the web with HTML Introduction to BeautifulSoup Selenium with Python |

November 2 | Dynamic programming, basic data representation | Notes, Sections 1 4, 8.1 |

November 6 | Basic data representation (cont.), preprocessing for text mining | (MRS) Chapters 2.0–2.2 |

November 7 | tf-idf, inverted indexes | (MRS) Chapters 6.2, 6.3.1–6.3.2, 1.0–1.4, 6.3.3 |

November 9 | Sorting | Book chapters on mergesort and quicksort from the book "Introduction to Algorithms" by Cormern, Leiserson, Rivest, and Stein. |

November 13 | Data structures, heaps, heapsort | Notes, Section 7, Wikipedia page on data structures book chapter on heaps and heapsort from the book "Introduction to Algorithms" by Cormern, Leiserson, Rivest, and Stein. |

November 14 | Introduction to NLP with Python | Natural Language Toolkit Natural Language Processing with spaCy Tutorial: How to Use the Apply Method in Pandas Python's collections: specialized data types Python's reduce: how to use folding Working With Text Data using scikit-learn |

November 16 | Data structures (cont.), hashing | Notes, Section 7, Wikipedia page on linked lists, book chapter on hashing from the book "Algorithms" by Dasgupta, Papadimitriou, and Vazirani |

November 20 | MapReduce | Most of the things we talked about can be found on this quick introduction |

November 21 | Introduction to Elastic Map Reduce | Laboratory 6: Elastic Map Reduce Big Data Analytics Options on AWS Bigtable: A Distributed Storage System for Structured Data Getting Started: Analyzing Big Data with Amazon EMR Using EMR Notebooks PySpark: the Python API for Spark TF-IDF using Map Reduce |

November 23 | Hierarchical clustering, the k-means problem | Chapters 7.0–7.2, Slides |

November 27 | The k-means algorithm, discussion about initialization | Chapters 7.3.0–7.3.2, Slides |

November 28 | Introduction to Clustering in Python | Clustering in Python K-Means in Python Elbow Method using SciKit |

November 30 | k-means++, choosing k | Chapter 7.3.3, Slides |

December 4 | Mathematical background for PCA | Notes sent by email |

December 5 | Singular Value Decomposition and Principal Component Analysis | Chapters 3.1–3.5, 3.8, 3.9.1, 3.9.2 (you can skip the proofs) from the book Foundations of Data Science by Blum, Hopcroft, and Kannan |

December 7 | Queues, stacks, introduction to graphs |
Notes, Section 7, Notes on graphs, book chapter on graph representaton from the book "Introduction to Algorithms" by Cormern, Leiserson, Rivest, and Stein |

December 11 | Shortest paths, breadth-first search, depth-first search, Dijkstra's algorith | Book chapter on BFS and DFS from the book "Algorithms Illuminated" by Roughgarden, book chapter on Dijkstra's algorithm from the book "Algorithms" by Dasgupta, Papadimitriou, and Vazirani, book chapter on Dijkstra's algorithm from the book "Introduction to Algorithms" by Cormern, Leiserson, Rivest, and Stein |

December 12 | Minimum spanning trees, randomized minimum cut, centrality measures | Book chapter on MST from the book "Algorithms Illuminated" by Roughgarden, book chapter on MST from the book "Introduction to Algorithms" by Cormern, Leiserson, Rivest, and Stein book chapter on the randomized algorithm for mincut from the book "Probability and Computing" by Mitzenmacher and Upfal Notes on graphs, Section 3 |

December 13 | PageRank | Chapter 5.1.0–5.1.2, 5.1.4, 5.1.5 |

December 18 | PageRank (cont.) | |

December 19 | Introduction to Graphs in Python Twitter API |
Laboratory 8: Graphs NetworkX: Network Analysis in Python Tweepy: An easy-to-use Python library for accessing the Twitter API Twitter API Documentation |

### Homeworks

- Homework 1 (due on 15/10, 23.59)
- Homework 2 (due on
~~29/10~~5/11, 23.59) - Homework 3 (due on 26/11)
- Homework 4 (due on
~~10/12~~17/12, 23.59) - Homework 5 (due on 1/1, 23.59)

**Collaboration policy (read carefully!):** You can discuss with other students of the course about the projects. However, you must understand well your solutions and the final writeup must be yours and written in isolation. In addition, even though you may discuss about how you could implement an algorithm, what type of libraries to use, and so on, the final code must be yours. You may also consult the internet for information, as long as it does not reveal the solution. If a question asks you to design and implement an algorithm for a problem, it's fine if you find information about how to resolve a problem with character encoding, for example, but it is not fine if you search for the code or the algorithm for the problem you are being asked. For the projects, you can talk with other students of the course about questions on the programming language, libraries, some API issue, and so on, but both the solutions and the programming must be yours. **If we find out that you have violated the policy and you have copied in any way you will automatically fail.** If you have any doubts about whether something is allowed or not, ask the instructor.

The same applies for **generative AI tools, such as ChatGPT, Bard, Bing**, and so on. These can be useful tools in your work and there are some homework questions in which we ask you explicitly to use them. **However, the use of such tools when it is not explicitly allowed will be treated as plagiarism and is strictly prohibited.**