Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
probml
GitHub Repository: probml/pyprobml
Path: blob/master/notebooks/book1/16/curse_dimensionality_plot.ipynb
1192 views
Kernel: Unknown Kernel
# Show the curse of dimensionality. import numpy as np import matplotlib.pyplot as plt try: import probml_utils as pml except ModuleNotFoundError: %pip install -qq git+https://github.com/probml/probml-utils.git import probml_utils as pml ds = [1.0, 3.0, 5.0, 7.0, 10.0] s = np.linspace(0, 1, 100) for d in ds: y = s ** (1 / d) plt.plot(s, y, "b-") plt.text(0.3, 0.3 ** (1 / d), "d=%d" % d) plt.xlabel("Fraction of data in neighborhood") plt.ylabel("Edge length of cube") pml.savefig("curseDimensionality.pdf") plt.show()