Why does Qhull error when computing convex hull of a few points?

丶灬走出姿态 提交于 2019-12-23 14:12:44

问题


I'm trying to compute the convex hull of 9 points in 10 dimensional space. Through the scipy interface, I'm calling scipy.spatial.ConvexHull(points) and getting QH6214 qhull input error: not enough points(9) to construct initial simplex (need 12)

I think the definition of convex hull is well defined regardless of the dimension. What is going on here? Is there a different function I can call that might fix this?


回答1:


Maybe projecting the points on a hyperplane before computing the hull will do the trick.

Use for example the Principal Component Analysis class sklearn.decomposition.PCA from the scikit-learn toolkit, to reduce dimension.

vertices = np.random.randn(9, 10)
from sklearn.decomposition import PCA
model = PCA(n_components=8).fit(vertices)

You can now transform back and forth from your vertices to the projected using model.transform and model.inverse_transform.

proj_vertices = model.transform(vertices)
hull_kinda = ConvexHull(proj_vertices)
hull_kinda.simplices

This outputs something like this

array([[6, 4, 3, 8, 0, 7, 5, 1],
       [2, 4, 3, 8, 0, 7, 5, 1],
       [2, 6, 3, 8, 0, 7, 5, 1],
       [2, 6, 4, 8, 0, 7, 5, 1],
       [2, 6, 4, 3, 0, 7, 5, 1],
       [2, 6, 4, 3, 8, 7, 5, 1],
       [2, 6, 4, 3, 8, 0, 5, 1],
       [2, 6, 4, 3, 8, 0, 7, 1],
       [2, 6, 4, 3, 8, 0, 7, 5]], dtype=int32)

Use now the model.inverse_transform to get the simplices back in your 10 dimensions.



来源:https://stackoverflow.com/questions/26408110/why-does-qhull-error-when-computing-convex-hull-of-a-few-points

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!