我正在使用科学的空间,以找到最适合的平面上的三维点列表。它通常适用于其他列表,但这个给我带来了一些麻烦.
代码(py):
from skspatial.objects import Plane
from skspatial.objects import Points
from skspatial.objects import Point
from skspatial.plotting import plot_3d
points_list = [[2018.0, 3.0, -3.0], [2016.0, 3.0, -7.0], [2014.0, 27.0, 7.0], [2013.0, 3.0, -1.5], [2012.0, 4.5, 2.0], [2012.0, 16.5, 3.5], [2012.0, 18.0, 5.5], [2010.0, 13.5, 1.0], [2010.0, 21.0, -3.0], [2009.0, 30.0, 4.5]]
plot_3d(
Points(points_list).plotter(c='k',s=15,depthshade=True),
Plane.best_fit(points_list).plotter(alpha=0.2, lims_x=(-5, 5), lims_y=(-5, 5))
)[0].show()参考:结果地块
无论如何,数据列表几乎是平坦的,但是科学空间返回的平面是绝对不合理的。我只是做错了什么,还是发生了其他事情?我在网上环顾了一下,但找不到类似的东西。谢谢!!
发布于 2022-04-29 04:56:41
我是scikit- start的作者(我想从"Hi“开始,但是StackOverflow似乎会自动删除它)。我只是碰巧注意到了这个问题,这就是为什么我反应晚了。如果您的包有其他问题,请在GitHub回购上创建一个问题,我会尽快回复您。
我同意这架最适合的飞机在你的阴谋中看上去不对。但请注意斧头的范围。X轴从2008年到2018年,范围为10,y轴从5到30,范围为25。但是z轴从-1000到1000,范围是2000.
Z轴的范围是如此之大,它使你的观点看起来是平坦的,而在现实中,它们根本不是平坦的。
尝试更改z轴限制,以获得与x和y轴更相似的范围:
_, ax = plot_3d(
Points(points_list).plotter(c='k',s=15, depthshade=True),
Plane.best_fit(points_list).plotter(alpha=0.2, lims_x=(-10, 10), lims_y=(-10, 10), color='b'),
)
ax.set_zlim([-10, 10])

现在看起来更可信的是,这是最适合的平面。
https://stackoverflow.com/questions/68961407
复制相似问题