BDS 761: Data Science and Machine Learning I


drawing

Topic 1: Introduction

This topic:¶

  1. Motivation
  2. Syllabus
  3. Software installation

Reading:

  • https://jupyter.org/try-jupyter/notebooks/?path=notebooks/Intro.ipynb
  • https://herbsutter.com/welcome-to-the-jungle/
  • http://www.incompleteideas.net/IncIdeas/BitterLesson.html
  • Google Machine Learning Crash Course: https://developers.google.com/machine-learning/crash-course/ml-intro

I. Motivation¶

Real Solutions from A.I.¶

drawing

Machine Learning:¶

  1. Classification - determining what something is, given features
  2. Regression - determining future value, cost, sea level, from past data
  3. Clustering - finding subgroups
  4. Dimensionality Reduction - find the meaningful variations in the data

drawing
https://github.com/mlds-lab/COMPSCI-589

What are these pictures depicting?

What Machine Learning methods have you heard of?

Modern AI¶

A narrow class of model types have achieved all the successes charted above.

drawing

Learning" - means learning from data, a subcategory of Data Science

What does Data Science mean?

Data-driven science?

Methods for processing and exploiting big data?

Zooming in...¶

Nearer points represent more similar methods...

drawing

“Convolutional Neural Networks” - used for highly-accurate image classification. Dominate current healthcare use (e.g., detecting tumors)

“Transformers” - currently used for Large Language Models (LLMs) because they can handle very large (complex) models LLMs are the basis for ChatGPT (2022) and the most recent phase of the “Artificial Intelligence boom”

CNN's¶

drawing

LLM's: chatbots¶

drawing

LLM's: software¶

drawing

(running jupyter extension in vscode, using github copilot extension)

Peek inside: Feature engineering¶

From another perspective, Deep Learning brought a huge leap forward because the hardest part of machine learning was able to be mostly automated, by using lots of data

drawing

deep network as a shallow machine learning model (logistic regression typically) plus a bunch of preceding layers for representation learning

Why it works - Theory¶

An artificial neural network is a universal function approximator, a sufficiently complex (i.e. deep) network can find any parametric relation between input data and desired behavior, as long as one exists.

drawing

Q: How do we know a function exists?¶

A: If a human can do it...¶

At least humans can label training data for us...

Then we can assume a “function” exists which we can approximate with a sufficiently-complex network. The more complex the network, the more:

  • Data
  • Processing power

are required to “fit” the approximation.

Data: opportunity and challenge¶

Winning methods need to be able to handle increasingly cast dataset sizes

drawing

Hardware: solution and Constraint¶

The supposed end of Moore's Law

drawing

CPU's stopped getting faster clock speeds around 3GHZ

Countered by increasing number of cores on chip

99% Parallelism¶

100x increase in compute (due to more cores) in 20 years (since clock speed stopped)

To take advantage of this gain, need algorithms and techniques that can scale well

Good: matrix multiplication, gradient descent

Bad: triangular solve, Newton's method

The Bitter Lesson¶

"The biggest lesson that can be read from 70 years of AI research is that general methods that leverage computation are ultimately the most effective, and by a large margin. The ultimate reason for this is Moore's law, or rather its generalization of continued exponentially falling cost per unit of computation."

Rich Sutton, 2019

http://www.incompleteideas.net/IncIdeas/BitterLesson.html

A.I. Exercise: Hugging Face¶

https://huggingface.co/google --> https://huggingface.co/google-bert/bert-base-cased

--> Use this model --> google Colab

Create a new cell and run the examples from above model webpage such as:

from transformers import pipeline
unmasker = pipeline('fill-mask', model='bert-base-cased')
unmasker("Hello I'm a [MASK] model.")

Inside the pipeline¶

  • A tokenizer in charge of mapping raw textual input to token --> string (or other data format) processing
  • A model to make predictions from the inputs --> linear algebra
  • Some (optional) post processing for enhancing model’s output --> conversion to strings, or class probabilities, or ...
drawing

https://huggingface.co/learn/nlp-course/chapter2/2

Inside the Model¶

print(unmasker.model) --> a more-complicated version of:

drawing

Inside the GPU¶

General Matrix Multiplication (GEMM) ~ $C = \alpha AB + \beta C$

drawing

https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html

Course Theme¶

We will focus largely on regression and related methods

  • which form the basis for modern AI (CNN's, LLM's,... )
  • and how to scale them to large datasets and parallel computing

also some scalable clustering, dimensionality reduction, and graph methods

General Topic List¶

We will focus on methods and tools in the following broad areas

  1. Introduction to Statistical Learning
  2. Scaling Matrix computations
  3. Regression and Classification
  4. Graph and Network Algorithms
  5. Embedding methods
  6. Mathematical Optimization
  7. Introduction to Deep Learning
  8. Language Modeling

Objectives of this class¶

  • Be able to use "core" AI libraries, tools, and computing hardware in your research
  • Understand how SOTA AI methods are built starting from simple regression
  • Be able to implement basic processing and important machine learning algorithms from "scratch"
  • Generally understand research publications in AI field

II. Syllabus Discussion¶

  • Homework and readings will be provided at end of class or via announcement later that evening. Due in one week. Points deducted if late.
  • No particular textbook needed
  • A laptop is needed to participate in class.
  • Attendance not mandatory (?). Will try to record classes. Please do not come to class with anything contagious.
  • Academic integrity - can discuss verbally. Do not share work or copy fellow students' writing or code. Be very careful about basing your work on code from internet.
  • Office hours TBD.

Course Information¶

  • Labs/Participation/Homework - 10%
  • Quizzes - 10%
  • Midterm - 30%
  • Final Exam - 30%
  • Final Project - 20%

Course Info Notes:¶

  • CAN use AI on homework, project, but need to know the material. AI can make you smarter or dumber...
  • Exams will be closed book
  • Participation: weekly (decently formatted) jupyter notebook including participation in class
  • Add homework to same notebook and turn in

Final Project¶

  • Research interest or provided topic
  • Dataset must be novel or challenging
  • Final (brief) report and presentation
  • Encouraged to present externally

Example: taking a working AI model, making it robust versus degredation by generating degraded training data

Prerequisites¶

  • Programming skills in Python and numpy

  • Linear Algebra

  • Basic Probability & Statistics

Books¶

There is no required text. There is a vast supply of free resources online. Suggestions:

  • Introduction to Applied Linear Algebra, Boyd & Vendenberghe 2018, http://vmls-book.stanford.edu/

  • Speech and Language Processing, 3e, Jurafsky & Martin 2024. https://web.stanford.edu/~jurafsky/slp3/

Some python and linear algebra review material:

  • https://www.keithdillon.com/index.php/bootcamp/
  • https://www.keithdillon.com/classes/UMMC/BDS754-01/FLASHCARDS_basics.slides.html#/
  • https://www.keithdillon.com/classes/UMMC/BDS754-01/Numpy_practice.html

Academic Integrity, etc.¶

  • See student handbook. This is your contract.
  • Fairness will not be sacrificied for other noble causes
  • Big source of drama: students skipping class or not doing homework then being unhappy with exams they could not handle as a result

III. Software Installation¶

Jupyter - "notebooks" for inline code + LaTex math + markup, etc.¶

A single document containing a series of "cells". Each containing code which can be run, or images and other documentation.

drawing

Will execute code and display result below, or render markup etc.

Jupyter can also run R or Julia, Matlab, SQL, etc. (with increasing difficulty).

In [1]:
import datetime

print("This code is run right now (" + str(datetime.datetime.now()) + ")")

'hi'
This code is run right now (2025-08-26 14:41:26.932482)
Out[1]:
'hi'
In [3]:
x=1+2+2

print(x)
5
In [4]:
import numpy as np
In [9]:
np.random.randn(2,5)
Out[9]:
array([[ 1.24350758,  1.99906955, -0.3226366 , -0.98266019, -0.1309466 ],
       [-0.85026968, -0.35865037,  0.70637075,  1.06492839,  0.35220974]])
In [12]:
np.ones((2,2))
Out[12]:
array([[1., 1.],
       [1., 1.]])

Installation¶

First project: get Jupyter running and be able to import listed tools

Easiest to install via Anaconda. Preferrably Python 3.

https://www.anaconda.com/download/

Highly recomended to make a separate environment for class - hot open source tools change fast and deprecate (i.e. break) old features constantly

conda create env -m MY_ENV_FALL_2026
conda activate MY_ENV_FALL_2026
conda install jupyter matplotlib numpy scipy pytorch cupy...

Many other packages...

Plan B: Cloud-based Notebooks¶

Google CoLab: https://colab.research.google.com/notebooks/welcome.ipynb

Kaggle Kernel: https://www.kaggle.com/kernels

Python Help Tips¶

  • Get help on a function or object via [shift] + [tab] after the opening parenthesis function(
drawing
  • Can also get help by executing function?
drawing

First GPU program: CuPy¶

Plug-in replacement of array programming

Behind the scenes it will transfer data to GPU and back.

  • an open-source library with NumPy syntax that increases speed by doing matrix operations on NVIDIA GPUs.
  • accelerated with the CUDA platform from NVIDIA
  • also uses CUDA-related libraries, including cuBLAS, cuDNN, cuRAND, cuSOLVER, cuSPARSE, and NCCL
  • interface is highly compatible with NumPy; in most cases it can be used as a drop-in replacement.
  • supports various methods, data types, indexing, broadcasting, and more.
pip install cupy
pip install cupy-cuda12x


https://github.com/cupy/cupy

https://docs.cupy.dev/en/stable/user_guide/basic.html

In [6]:
import numpy as np

a = np.arange(0,1000)
b = np.ones(1000)
a[:10], b[:10], (a+b)[:10]
Out[6]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
 array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]),
 array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10.]))
In [1]:
import cupy as np # <--- replacing numpy with cupy

print('GPU available:', np.is_available()) # True if GPU execution is available

# same numpy code as above
a = np.arange(0,1000)
b = np.ones(1000)
a[:10], b[:10], (a+b)[:10]
GPU available: True
Out[1]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
 array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]),
 array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10.]))

PyTorch¶

Python-based scientific computing package targeted at deep learning, "tensor mathematics", and automatic differentiation on GPUs.

drawing

https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py

https://pytorch.org/docs/stable/torch.html

In [1]:
import torch as t
print(t.__version__)
device = "cuda" if t.cuda.is_available() else "cpu"
print(device)
2.6.0
In [ ]:
a = t.arange(0, 1000)
b = t.ones(1000)
a[:10], b[:10], (a+b)[:10]