为什么在计算几个点的凸包时Qhull会出错?

时间:2014-10-16 15:22:18

标签: scipy qhull

我正在尝试计算10维空间中9点的凸包。通过scipy界面,我正在调用scipy.spatial.ConvexHull(points)并获取QH6214 qhull input error: not enough points(9) to construct initial simplex (need 12)

我认为无论尺寸如何,凸包的定义都很明确。这里发生了什么?是否有我可以调用的不同功能可以解决这个问题?

1 个答案:

答案 0 :(得分:2)

在计算船体之前,可能会在超平面上投射点就可以了。

使用sklearn.decomposition.PCA工具包中的主成分分析类scikit-learn来减少维度。

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

现在,您可以使用model.transformmodel.inverse_transform从顶点前后转换为投影。

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

这会输出类似的东西

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)

现在使用model.inverse_transform将简单版本放回10维。