Я пытаюсь построить простую линейную модель для прогнозирования значений меток с помощью LinearRegressionWithSGD. Я преобразовал набор данных, чтобы получить функции и метки, и снова преобразовал в точки с метками, чтобы выполнить регрессию.
val train = dftrain.withColumn("label", dftrain("col2")).select("features", "label")
val test = dftest.withColumn("label", dftest("col2")).select("features", "label")
val realout = train.rdd.map(row => LabeledPoint(row.getAs[Double]("label"),DenseVector.fromML(row.getAs[org.apache.spark.ml.linalg.DenseVector]("features"))))
val realout1 = test.rdd.map(row => LabeledPoint(row.getAs[Double]("label"),DenseVector.fromML(row.getAs[org.apache.spark.ml.linalg.DenseVector]("features"))))
Сейчас примеряю модель
val numIterations = 100
val stepSize = 0.00000001
//fitting the model with converted Labeled points Train Data
val model = LinearRegressionWithSGD.train(realout, numIterations, stepSize)
17/08/09 12:16:15 WARN LinearRegressionWithSGD: The input data is not directly c ached, which may hurt performance if its parent RDDs are also uncached. 17/08/09 12:16:17 WARN BLAS: Failed to load implementation from: com.github.fomm il.netlib.NativeSystemBLAS 17/08/09 12:16:17 WARN BLAS: Failed to load implementation from: com.github.fomm il.netlib.NativeRefBLAS 17/08/09 12:16:17 WARN LinearRegressionWithSGD: The input data was not directly cached, which may hurt performance if its parent RDDs are also uncached. model: org.apache.spark.mllib.regression.LinearRegressionModel = org.apache.spar k.mllib.regression.LinearRegressionModel: intercept = 0.0, numFeatures = 1
Это дает мне некоторые предупреждения, а также дает Intercept
как 0,0, что я не считаю правильным. Но когда я предсказываю модель, она выдает мне ошибку.
val prediction = model.predict(realout1)
<console>:98: error: overloaded method value predict with alternatives:
(testData: org.apache.spark.api.java.JavaRDD[org.apache.spark.mllib.linalg.Vec
tor])org.apache.spark.api.java.JavaRDD[Double] <and>
(testData: org.apache.spark.mllib.linalg.Vector)Double <and>
(testData: org.apache.spark.rdd.RDD[org.apache.spark.mllib.linalg.Vector])org.
apache.spark.rdd.RDD[Double]
cannot be applied to (org.apache.spark.rdd.RDD[org.apache.spark.mllib.regressio
n.LabeledPoint])
val prediction = model.predict(realout1)
^
Также, если я сделаю это из здесь,
// Evaluate model on training examples and compute training error
val valuesAndPreds = realout.map { point => val prediction = model.predict(point.features) (point.label, prediction) }
<console>:90: error: Double does not take parameters
val valuesAndPreds = realout.map { point => val prediction = model.predic
t(point.features) (point.label, prediction) }
^
Я считаю шаги правильными. Но я понятия не имею, почему он показывает значение перегруженного метода прогнозируется с помощью альтернативы или Double не принимает параметры