1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
"""Visualize the curse-of-dimensionality.
It presents a saturated design in 1, 2 and 3 dimensions for a
given discretization.
"""
import matplotlib.pyplot as plt
import numpy as np
disc = 10
x = np.linspace(0, 1, disc)
y = np.linspace(0, 1, disc)
z = np.linspace(0, 1, disc)
xx, yy, zz = np.meshgrid(x, y, z)
fig = plt.figure(figsize=(12, 4))
ax = fig.add_subplot(131)
ax.set_aspect('equal')
ax.scatter(xx, yy * 0)
ax.set_xlabel(r'$x_1$')
ax.get_yaxis().set_visible(False)
ax = fig.add_subplot(132)
ax.set_aspect('equal')
ax.scatter(xx, yy)
ax.set_xlabel(r'$x_1$')
ax.set_ylabel(r'$x_2$')
ax = fig.add_subplot(133, projection='3d')
ax.scatter(xx, yy, zz)
ax.set_xlabel(r'$x_1$')
ax.set_ylabel(r'$x_2$')
ax.set_zlabel(r'$x_3$')
plt.tight_layout(pad=2)
plt.show()
|