Recap: Bird Songs
Part of the Unsupervised Learning section of Coddy's Machine Learning journey. Lesson 28 of 51.
Challenge
MediumA birdwatcher recorded 160 songs from four species, 7 measurements each. Squeeze them into one map, like the wines that opened this chapter.
- Scale the measurements and fit a
PCA()that keeps every component; keep itsfit_transformoutput inpoints. - Print the share of spread the first two components keep, 3 decimals, and how many components reach 90%.
- Scatter the first two components, one group per species labelled with its name, and a legend. Show it.
For another birdwatcher:
First two keep: 0.818
Components for 90%: 4Coddy describes your map. Which two species sing most alike?
Try it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
# A birdwatcher's recordings: 7 measurements for each of 160 songs, and the singer's species
songs = pd.read_csv("songs.csv")
X = songs.drop(columns="species")
fig, ax = plt.subplots()
ax.set_title("Bird Songs in 2D")
ax.set_xlabel("First component")
ax.set_ylabel("Second component")
# Write your code below
All lessons in Unsupervised Learning
1Finding Groups
Learning Without LabelsMeasuring SimilarityK-Means by HandK-Means in scikit-learnRecap: Gym Members7PCA in Practice
Seeing 64 DimensionsComponents as PatternsCompress and RebuildPCA Before a ModelRecap: Face Scanner10Project: Digit Explorer
Look at the DigitsShrink with PCACluster the DigitsName the ClustersFind the Odd OnesPractice on your own: Online Python compiler