0

I trained data using LinearRegression and saved the model, now I am trying to use this in SparkStreaming and predict the data using it, but my program does not predict the data, other lines fetching data from stream and everything works in loop but prediction does not work, Can anyone help me with the prediction of data?

val conf = new SparkConf().setMaster("local[2]").setAppName("streamingApplication")    
val sc = new SparkContext(conf)
val ssc = new StreamingContext(sc,Seconds(60)) 



val finalData = data.map{
                      x => LabeledPoint(x.price , Vectors.dense(x.timestamp,x.volume,x.volume,x.price))
                    }                                   


        val model = LinearRegressionModel.load(sc, "linearReg")
        finalData.map{
            points => val prediction = model.predict(points.features)
            println(points.label)
            println(prediction)
            (points.label, prediction)
  }
Chirag
  • 56
  • 1
  • 8

0 Answers0