RidgeRegressionModel¶
-
类
pyspark.mllib.regression。
RidgeRegressionModel
( 权重:pyspark.mllib.linalg.Vector,拦截:浮动 ) ¶ -
从最小二乘线性回归模型推导出符合一个l2惩罚项。
例子
> > >从pyspark.mllib.linalg进口SparseVector> > >从pyspark.mllib.regression进口LabeledPoint> > >数据=(…LabeledPoint(0.0,(0.0]),…LabeledPoint(1.0,(1.0]),…LabeledPoint(3.0,(2.0]),…LabeledPoint(2.0,(3.0])…]> > >lrm=RidgeRegressionWithSGD。火车(sc。并行化(数据),迭代=10,…initialWeights=np。数组([1.0)))> > >腹肌(lrm。预测(np。数组([0.0)))- - - - - -0)<0.5真正的> > >腹肌(lrm。预测(np。数组([1.0)))- - - - - -1)<0.5真正的> > >腹肌(lrm。预测(SparseVector(1,{0:1.0}))- - - - - -1)<0.5真正的> > >腹肌(lrm。预测(sc。并行化([[1.0]]))。收集()(0]- - - - - -1)<0.5真正的> > >进口操作系统,tempfile> > >路径=tempfile。mkdtemp()> > >lrm。保存(sc,路径)> > >sameModel=RidgeRegressionModel。负载(sc,路径)> > >腹肌(sameModel。预测(np。数组([0.0)))- - - - - -0)<0.5真正的> > >腹肌(sameModel。预测(np。数组([1.0)))- - - - - -1)<0.5真正的> > >腹肌(sameModel。预测(SparseVector(1,{0:1.0}))- - - - - -1)<0.5真正的> > >从shutil进口rmtree> > >试一试:…rmtree(路径)…除了BaseException:…通过> > >数据=(…LabeledPoint(0.0,SparseVector(1,{0:0.0})),…LabeledPoint(1.0,SparseVector(1,{0:1.0})),…LabeledPoint(3.0,SparseVector(1,{0:2.0})),…LabeledPoint(2.0,SparseVector(1,{0:3.0}))…]> > >lrm=LinearRegressionWithSGD。火车(sc。并行化(数据),迭代=10,…initialWeights=np。数组([1.0)))> > >腹肌(lrm。预测(np。数组([0.0)))- - - - - -0)<0.5真正的> > >腹肌(lrm。预测(SparseVector(1,{0:1.0}))- - - - - -1)<0.5真正的> > >lrm=RidgeRegressionWithSGD。火车(sc。并行化(数据),迭代=10,一步=1.0,…regParam=0.01,miniBatchFraction=1.0,initialWeights=np。数组([1.0]),拦截=真正的,…validateData=真正的)> > >腹肌(lrm。预测(np。数组([0.0)))- - - - - -0)<0.5真正的> > >腹肌(lrm。预测(SparseVector(1,{0:1.0}))- - - - - -1)<0.5真正的
方法
负载
(sc路径)加载RidgeRegressionMode。
预测
(x)预测因变量的值给定的向量或一个向量的抽样,其中包含独立变量的值。
保存
(sc路径)节省RidgeRegressionMode。
属性
截距计算模型。
权重计算为每个特性。
方法的文档
-
classmethod
负载
( sc:pyspark.context.SparkContext,路径:str )→pyspark.mllib.regression.RidgeRegressionModel ¶ -
加载RidgeRegressionMode。
-
预测
( x:联盟(VectorLike,pyspark.rdd.RDD(VectorLike]] )→联盟(浮动,pyspark.rdd.RDD(浮动] ] ¶ -
预测因变量的值给定的向量或一个向量的抽样,其中包含独立变量的值。
-
保存
( sc:pyspark.context.SparkContext,路径:str )→没有¶ -
节省RidgeRegressionMode。
属性的文档
-
拦截
¶ -
截距计算模型。
-
权重
¶ -
权重计算为每个特性。
-
classmethod