2016-05-31 87 views
3

我试图帮助一个正试图在信号中使用LinearRegression的朋友。数据包含20,000条记录和两列(时间和脉冲),我在Databricks的社区中运行它。我的方法非常简单且有偏见我知道,我尝试添加更多人造功能,为此,我创建了这个简单且有用的功能。使用线性回归时的断言错误

def featuresCreator(x, grad, acc): 
    if (grad > 0): 
    return [x ** grad] 
    else: 
    return [x ** grad] + featuresCreator(x, grad - acc, acc) 

featuresUDF = udf(lambda x, grad, acc: DenseVector(featuresCreator(x, grad, acc)), VectorUDT()) 

我认为有几次供电和值的范围之内就会帮助我过度拟合回归,这就是为什么我跑这样做的原因。

xf = df.select(featuresUDF(col("tiempo"), lit(12), lit(0.1)).alias("features"), col(" pulso").alias("label")) 

一切都很好的DataFrame只有2列的特色之一,另一个标签。当我尝试在数据上使用LinearRegression时,问题就来了。

lr = LinearRegression().setFeaturesCol("features").setLabelCol("label").setMaxIter(200) 
lrm = lr.fit(xf) 

这里程序爆炸并显示以下异常。

java.lang.AssertionError: assertion failed: lapack.dppsv returned 5.

有什么办法解决这个问题吗?或者我做错了什么?

+1

这个错误通常意味着你传递了一个不可解的矩阵。 – zero323

+0

所以它与矢量的长度无关? –

+1

编号检查信息代码:http://www.netlib.org/lapack/explore-html/d3/d62/dppsv_8f.html:_ A的第i个命令的主要未成年人不是 正确的,因此分解不能成为 已完成,并且该解决方案尚未计算_ – zero323

回答

3

这个错误通常意味着你传递了一个不可解的矩阵。

因此,实际上它是不相关的矢量

Check INFO codes: netlib.org/lapack/explore-html/d3/d62/dppsv_8f.html: the leading minor of order i of A is not positive definite, so the factorization could not be completed, and the solution has not been computed

1

这个问题可以通过求解器参数进行线性回归可以解决的长度。

val lf=new LinearRegression().setSolver("l-bfgs") 

默认情况下是正常的。