本文使用SparkMllib搭建简单的线性回归例子
package SparkMlibCourse3
import org.apache.log4j.{Level, Logger}
import org.apache.spark.sql.{DataFrame, SQLContext}
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.ml.feature.VectorAssembler
import org.apache.spark.ml.regression.LinearRegression
/**
* Created by zhaohui.
* 利用线性回归模型对数据进行回归预测
*/
object SparkMlibLRAdd1 {
def main(args: Array[String]): Unit = {
//设置环境
//构建Spark对象
val conf = new SparkConf().setMaster("local") setAppName ("ExampleLinearRegressionWithSGD")
val sc = new SparkContext(conf)
val sqc = new SQLContext(sc)
Logger.getRootLogger.set