J'essaye de construire un modèle linéaire simple pour prédire les valeurs d'étiquette en utilisant LinearRegressionWithSGD. Je me suis converti Dataset pour obtenir les caractéristiques et l'étiquette et encore une fois convertis en des points marqués pour faire la régressionerreur: valeur de méthode surchargée "predict" avec des alternatives/Double ne prend pas de paramètres
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"))))
Maintenant, je suis ajustement du modèle
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
Il me donne des avertissements et aussi il donne Intercept
comme 0.0 que je ne sens pas son correct. Mais quand je prédis le modèle, ça me jette une erreur.
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)
^
Aussi, si je le fais à partir here,
// 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) }
^
Je crois que les étapes sont corrects. Mais je ne sais pas pourquoi il est montrant valeur de méthode surchargée prédire avec remplacement ou Double ne prend pas de paramètres