使用 LinearRegression 时出现断言错误
Assertion Error while using LinearRegression
我试图帮助一位试图在信号中使用 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())
我认为在 运行ge 值范围内多次为该功能提供动力将帮助我 过度拟合 回归,这就是我 运行这个。
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.
有什么办法可以解决吗?还是我做错了什么?
此错误通常意味着您传递了一个不可解的矩阵。
所以实际上它与向量的长度无关
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
这个问题可以使用线性回归的求解器参数来解决。
val lf=new LinearRegression().setSolver("l-bfgs")
默认是正常的
我试图帮助一位试图在信号中使用 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())
我认为在 运行ge 值范围内多次为该功能提供动力将帮助我 过度拟合 回归,这就是我 运行这个。
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.
有什么办法可以解决吗?还是我做错了什么?
此错误通常意味着您传递了一个不可解的矩阵。
所以实际上它与向量的长度无关
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
这个问题可以使用线性回归的求解器参数来解决。
val lf=new LinearRegression().setSolver("l-bfgs")
默认是正常的