# Agenda

- Traditional Programming vs ML

- Types of Machine Learning 

    - Supervised Learning 
    
    - Unsupervised Learning
    
    - Reinforcement Learning
    
- Learning problem definition and formalization

# Traditional Programming vs ML



[Image Source](https://github.com/rasbt/stat479-machine-learning-fs19/blob/master/01_overview/01-ml-overview__notes.pdf)

A More formal definition of ML: 

> A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E. (Tom Mitchell)



[Image Source](http://adilmoujahid.com/posts/2016/06/introduction-deep-learning-python-caffe/?utm_content=buffer82f2c&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer)

E: Collected and labeled dataset of dogs and cats

T: To classify whether a photo has a cat or dog

P: Accuracy of the classification

[Your Turn!](https://forms.gle/2RwC8opUi6bDVpER6)

# Types of Machine Learning 




## Supervised Learning



[Image Source](https://python.astrotech.io/_images/iris-dataset.png)


```python
import numpy as np

import pandas as pd

from sklearn.datasets import load_iris

data,target = load_iris(return_X_y=True, as_frame= True)

iris_df = pd.concat([data,target], axis = 1,)

iris_df.head()
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>sepal length (cm)</th>
      <th>sepal width (cm)</th>
      <th>petal length (cm)</th>
      <th>petal width (cm)</th>
      <th>target</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>5.1</td>
      <td>3.5</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>0</td>
    </tr>
    <tr>
      <th>1</th>
      <td>4.9</td>
      <td>3.0</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>0</td>
    </tr>
    <tr>
      <th>2</th>
      <td>4.7</td>
      <td>3.2</td>
      <td>1.3</td>
      <td>0.2</td>
      <td>0</td>
    </tr>
    <tr>
      <th>3</th>
      <td>4.6</td>
      <td>3.1</td>
      <td>1.5</td>
      <td>0.2</td>
      <td>0</td>
    </tr>
    <tr>
      <th>4</th>
      <td>5.0</td>
      <td>3.6</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>0</td>
    </tr>
  </tbody>
</table>
</div>





## Unsupervised Learning

__Clustering__



[Image Source](https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/)

__Dimension Reduction__





[Image Source](https://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html)


```python
from sklearn import datasets
import matplotlib.pyplot as plt
digits = datasets.load_digits(n_class=6)
num = np.random.randint(0, 1000)

img = digits.data[num]

plt.imshow(img.reshape(8,8), cmap ="gray" )

print(img, digits.target[num])
```

__Anomally Detection__



[Image Source](https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/)

## Reinforcement Learning



[Types of ML](https://forms.gle/twHHWvgNk5QhMsEs7)

## Building ML Systems



[Image Source](https://github.com/rasbt/stat479-machine-learning-fs19/blob/master/01_overview/01-ml-overview__notes.pdf)

## More Explicitly: Components of ML Systems

- Define Problem to be solved.

- Collect data.

- Choose an algorithm class.

- Choose an optimization metric for the learning model.

- Choose a metric for evaluation.

__Note!__

- optimization and model evaluation are different tasks!

    - For optimization you might want to maximize log-Likelihood, or minimize mean squared errors, maximize information gain etc.

    - For model evaluation, you might want to check: accuracy, precision, recall etc.


# Supervised Learning in depth

## Notation and Conventions
For the features we will use $\mathbf{X}$

$$ \begin{equation*}
\mathbf{X} = 
\begin{pmatrix}
x_{1,1} & x_{1,2} & \cdots & x_{1,p} \\
x_{2,1} & x_{2,2} & \cdots & x_{2,p} \\
\vdots  & \vdots  & \ddots & \vdots  \\
x_{N,1} & x_{N,2} & \cdots & x_{N,p} 
\end{pmatrix}
\end{equation*}
$$

and for the target we will use $\mathbf{y}$:

$$ 
\begin{align}
    y &= \begin{bmatrix}
           y_{1} \\
           y_{2} \\
           \vdots \\
           y_{N}
         \end{bmatrix}
  \end{align}
$$


```python
## show data

## show target
```

## Formulation of the problem

Suppose we observe

- a quantitative response $\mathbf{Y}$

- predictors (features) $X_{1}, X_{2}, \cdots, X_{p}$

- We assume that there is some relationship between $\mathbf{Y}$ and $\mathbf{X} = (X_{1}, X_{2}, \cdots, X_{p})$


$$ \mathbf{Y} = f(\mathbf{X}) + \varepsilon$$

Problem: $f$ is unknown! (How many different functions can exists?)



[Image Source](https://faculty.marshall.usc.edu/gareth-james/ISL/ISLR%20Seventh%20Printing.pdf)

## How to Estimate f?

- Parametric
- Non-Parametric Models



__Parametric Models__

- Assumes a certain format for $f$. For example linear models: $f(X) = \beta_{1}X_{1} + \cdots + \beta_{p}X_{p}$

- Simplifies the problem

- Usually a little bit naive to capture complicated relations. 

- Either not flexible enough (lead to underfitting) or too flexible (lead to overfitting).



__Non-Parametric Models__

- No assumptions about the form of $f$

- Usually more flexible to detect true relation between $X$ and $y$.

- Needs a very large number of observations otherwise they might overfit.

## Some examples of ML algorithms we will cover in this class

- Linear Models

- Tree based models

- Ensemble Models

- Instance-based models

- K-Means, Hierarchical Models

- Dimension Reduction Algorithms

- Artificial Neural Networks

Review of today's lecture

- We've seen the differences between traditional programming vs ML.

- We've discussed different types of ML: Especially three types

    - Supervised 
    - Unsupervised
    - Reinforcement
 
- We learned the components of ML workflow.

- We learnt formulation of ML problem in supervised setting.

[Week-2 Exit Ticket](https://forms.gle/Upqvu9AVxeomzt7E6)

# Extra Resources

[Dimension Reduction](https://www.youtube.com/watch?v=wvsE8jm1GzE&ab_channel=GoogleDevelopers)

[Sebastian Raschka - Introduction to ML](https://github.com/rasbt/stat479-machine-learning-fs19/blob/master/01_overview/01-ml-overview__notes.pdf)

cac03b93e8f84d29bf505df5c39b69719362d532
ipynb
Jupyter Notebook
lectures/week-2/Lecture/Week-2-Machine Learning Problems 09-08.ipynb
dbbabcock/UMBC_DATA602
ac268b1d413c3779ab99a79b22389d226007311d
MIT
2020-09-03T04:18:46.000Z
2021-10-22T03:20:04.000Z
lectures/week-2/Lecture/Week-2-Machine Learning Problems 09-08.ipynb
dbbabcock/UMBC_DATA602
ac268b1d413c3779ab99a79b22389d226007311d
MIT
lectures/week-2/Lecture/Week-2-Machine Learning Problems 09-08.ipynb
dbbabcock/UMBC_DATA602
ac268b1d413c3779ab99a79b22389d226007311d
MIT
2020-09-03T12:12:38.000Z
2021-08-30T21:57:14.000Z
Qwen/Qwen-72B
1. YES
2. YES