我试图使用回归公式Z = a X + b Y + C在三维点云中找到平面
我实现最小二乘和RANSAC的解决方案,但3个参数方程限制平面拟合到2.5D-式不能在平面上施加平行于Z轴.
我的问题是如何将平面拟合推广到完整的3d?我想添加第四个参数以获得完整的方程式X + b Y + c*Z + d如何避免平凡的(0,0,0,0)解?
谢谢!
我正在使用的代码:
from sklearn import linear_model
def local_regression_plane_ransac(neighborhood):
"""
Computes parameters for a local regression plane using RANSAC
"""
XY = neighborhood[:,:2]
Z = neighborhood[:,2]
ransac = linear_model.RANSACRegressor(
linear_model.LinearRegression(),
residual_threshold=0.1
)
ransac.fit(XY, Z)
inlier_mask = ransac.inlier_mask_
coeff = model_ransac.estimator_.coef_
intercept = model_ransac.estimator_.intercept_
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用BeautifulSoup在维基百科页面中找到一个表格,由于某种原因,我没有得到该表格.任何人都可以告诉我为什么不拿桌子?
我的代码:
import BeautifulSoup
import requests
url='https://en.wikipedia.org/wiki/List_of_National_Historic_Landmarks_in_Louisiana'
r=requests.get(url)
url=r.content
soup = BeautifulSoup(url,'html.parser')
tab=soup.find("table",{"class":"wikitable sortable jquery-tablesorter"})
print tab
Run Code Online (Sandbox Code Playgroud)
打印:无
我正在使用pymongo"insert_one",我想阻止插入具有相同"name"属性的两个文档.
谢谢!
我的代码:
client = MongoClient('mongodb://localhost:8888/db')
db = client[<db>]
heights=db.heights
post_id= heights.insert_one({"name":"Tom","height":2}).inserted_id
try:
post_id2 = heights.insert_one({"name":"Tom","height":3}).inserted_id
except pymongo.errors.DuplicateKeyError, e:
print e.error_document
print post_id
print post_id2
Run Code Online (Sandbox Code Playgroud)
输出:
56aa7ad84f9dcee972e15fb7
56aa7ad84f9dcee972e15fb8