Experiment 10 Code
Experiment 10 Code
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
# Print results
print("Within-class scatter matrix (S_W):\n", S_W)
print("\nBetween-class scatter matrix (S_B):\n", S_B)
print("\nTotal scatter matrix (S_T):\n", S_T)
Output:
Within-class scatter matrix (S_W):
[[57.19414039 38.01741201 16.95864185 9.00354437]
[38.01741201 89.88257294 10.62508571 14.57007861]
[16.95864185 10.62508571 8.79424214 4.69233162]
[ 9.00354437 14.57007861 4.69233162 10.66756048]]
Between-class scatter matrix (S_B):
[[ 92.80585961 -55.65287963 113.80442453 113.68762457]
[-55.65287963 60.11742706 -74.89110136 -69.48896849]
[113.80442453 -74.89110136 141.20575786 139.73748309]
[113.68762457 -69.48896849 139.73748309 139.33243952]]
Total scatter matrix (S_T):
[[150. -17.63546762 130.76306638 122.69116894]
[-17.63546762 150. -64.26601565 -54.91888988]
[130.76306638 -64.26601565 150. 144.42981471]
[122.69116894 -54.91888988 144.42981471 150. ]]