当运行sckitlearn plot_robust_fit.py
的改编版本时,我得到一个随机错误(并不总是在同一次迭代中)。可以下载重现所需的所有文件here。
只需运行reg.py
,您很可能会收到错误。
回溯是:
Traceback (most recent call last):
File "/Users/geoffroy/git/sfinder_2/reg/reg.py", line 118, in <module>
model.fit(X, acluster_y)
File "/Library/Python/2.6/site-packages/sklearn/pipeline.py", line 141, in fit
self.steps[-1][-1].fit(Xt, y, **fit_params)
File "/Library/Python/2.6/site-packages/sklearn/linear_model/ransac.py", line 301, in fit
y_inlier_subset)
File "/Library/Python/2.6/site-packages/sklearn/base.py", line 328, in score
return r2_score(y, self.predict(X), sample_weight=sample_weight)
File "/Library/Python/2.6/site-packages/sklearn/linear_model/base.py", line 155, in predict
return self.decision_function(X)
File "/Library/Python/2.6/site-packages/sklearn/linear_model/base.py", line 138, in decision_function
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'])
File "/Library/Python/2.6/site-packages/sklearn/utils/validation.py", line 360, in check_array
% (n_samples, shape_repr, ensure_min_samples))
ValueError: Found array with 0 sample(s) (shape=(0, 2)) while a minimum of 1 is required.
请注意,单独运行时崩溃的样本可以正常工作。即使尝试崩溃的样本也可以正常工作。
非常感谢您的帮助:)
答案 0 :(得分:0)
这个问题来自Theil-Sen和RANSCAC估算器,其中没有找到内点。最新版本的sckitlearn中引入了更加用户友好的错误。参见官方的github issue开始。