"PCA projects in the directions of largest variance, but doesn't care about classes labels (unsupervised learning).\n",
"\n",
"LDA finds a suitable direction to separate the classes (supervised learning)."
]
},
{
"cell_type": "markdown",
"id": "e5c261d2",
"metadata": {},
"source": [
"## Exercices\n",
"\n",
"- check other synthetic datasets for clustering: https://scikit-learn.org/stable/datasets/sample_generators.html#generators-for-classification-and-clustering"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:code id:866dca52 tags:
``` python
importnumpyasnp
importscipy.spatial.distanceasssd
importsklearn.discriminant_analysisassda
importsklearn.metricsassm
importmatplotlib.pyplotasplt
```
%% Cell type:markdown id:16450559 tags:
We generate samples that are divides in groups, each following a certain distribution.
%% Cell type:code id:a4614df7 tags:
``` python
# sample properties
d=4# number of dimensions
c=3# number of classes
n=30# number of samples per class
# properties of groups (TO DO: play with variance scaling)
# means
m_gp=np.zeros([c,d])
m_gp[:,0]=np.linspace(0,1,c)# difference in mean between groups along 1st dimension
# standard deviations
std_gp=np.ones([c,d])
std_gp[:,0]*=0.2# along dimension 0
std_gp[:,1:]*=2.0# along dimension 1 (and higher if there are)
PCA projects in the directions of largest variance, but doesn't care about classes labels (unsupervised learning).
LDA finds a suitable direction to separate the classes (supervised learning).
%% Cell type:markdown id:e5c261d2 tags:
## Exercices
- check other synthetic datasets for clustering: https://scikit-learn.org/stable/datasets/sample_generators.html#generators-for-classification-and-clustering