Lab assignment for the Machine Learning course at Universidad Carlos III de Madrid. Unsupervised learning techniques applied to state and action space data from a control environment (pendulum-like system with x/y position and angular velocity).
UC3M · Robotics Engineering · 2024
K-Means applied to both state space (x, y, angular velocity) and action space data. Parameters tuned via elbow method and silhouette analysis.
| Space | Best k | Silhouette Score |
|---|---|---|
| State | 8 | 0.387 |
| Action | 4 | 0.447 |
Agglomerative clustering with ward, complete and average linkage methods. Best parameters selected via silhouette score.
| Space | Linkage | Best k | Silhouette Score |
|---|---|---|---|
| State | average | 3 | 0.332 |
| Action | ward | 5 | 0.423 |
Dimensionality reduction on the state space. With 3 components, explained variance is distributed as PC1: 38.6% / PC2: 34.0% / PC3: 27.4% — all 3 are needed to reach 95%. 2D vs 3D comparison shows the spiral structure is preserved after reduction.
| File | Description |
|---|---|
states_data.csv |
State space: x position, y position, angular velocity |
actions_data.csv |
Action space: control input values |
pip install numpy pandas matplotlib scikit-learn scipy seabornEach script is self-contained. Run any exercise independently:
python exercise11.py # K-Means on state space
python exercise12.py # K-Means on action space
python exercise13.py # Cluster visualization
python exercise21.py # Hierarchical clustering on state space
python exercise22.py # Hierarchical clustering on action space
python exercise23.py # Dendrogram visualization
python exercise31.py # PCA variance analysis
python exercise32.py # PCA 2D/3D comparisonMake sure states_data.csv and actions_data.csv are in the same directory as the scripts.
Jorge Serrano Navas · Lucas Kohley Aguilar
UC3M · 2024