LinearRegressionWithSGD ¶
-
class
pyspark.mllib.regression.
LinearRegressionWithSGD
[source] ¶ -
使用随机梯度下降训练一个无正则化的线性回归模型。
新增于版本 0.9.0。
自版本 2.0.0 起已弃用: 使用
pyspark.ml.regression.LinearRegression
。方法
train
(数据[, 迭代次数, 步长, …])使用随机梯度下降(SGD)训练线性回归模型。
方法文档
-
classmethod
train
( data : pyspark.rdd.RDD [ pyspark.mllib.regression.LabeledPoint ] , iterations : int = 100 , step : float = 1.0 , miniBatchFraction : float = 1.0 , initialWeights : Optional [ VectorLike ] = None , regParam : float = 0.0 , regType : Optional [ str ] = None , intercept : bool = False , validateData : bool = True , convergenceTol : float = 0.001 ) → pyspark.mllib.regression.LinearRegressionModel [source] ¶ -
使用随机梯度下降(SGD)训练线性回归模型。这解决了最小二乘回归公式
f(权重) = 1/(2n) ||A 权重 - y||^2
即均方误差。这里数据矩阵有 n 行,输入的 RDD 包含 A 的每一行及其对应的右侧标签 y。 请参阅文档以了解精确的公式。
新增于版本 0.9.0。
- Parameters
-
-
data
pyspark.RDD
-
训练数据,一个 LabeledPoint 的 RDD。
- iterations int, optional
-
迭代次数。 (默认值:100)
- step float, optional
-
SGD中使用的步长参数。 (默认值:1.0)
- miniBatchFraction float, optional
-
每次SGD迭代使用的数据比例。 (默认值:1.0)
-
initialWeights
pyspark.mllib.linalg.Vector
or convertible, optional -
初始权重。 (默认值:无)
- regParam float, optional
-
正则化参数。 (默认值:0.0)
- regType str, optional
-
用于训练我们模型的正则化器类型。 支持的值:
-
“l1” 用于使用L1正则化
-
“l2” 用于使用L2正则化
-
None 表示不使用正则化(默认)
-
- intercept bool, optional
-
布尔参数,指示是否使用增强表示进行训练数据(即,是否激活偏置特征)。 (默认值:False)
- validateData bool, optional
-
布尔参数,指示算法是否应在训练前验证数据。 (默认值:True)
- convergenceTol float, optional
-
决定迭代终止的条件。 (默认值: 0.001)
-
data
-
classmethod