Vectors.dense()

    import org.apache.spark.mllib.linalg.Vectors
    import org.apache.spark.mllib.stat.Statistics

    val rdd = sc.makeRDD(Array(Array(1.0,10.1,2.5),Array(2.0,5.2,3.8)))
    val rdd2 = sc.makeRDD(Array(1.2,2.3,3.4))

    val data = rdd.map(f=>Vectors.dense(f))
    println("data: \n" +data)
    val stat = Statistics.colStats(data)

    println("stat: \n"+stat) 
    println("min:" +stat.min)//min,max等等都是向量,2个Array时,min:[1.0,5.2,2.5]

    println("max:" +stat.max)//max:[2.0,10.1,3.8]

你可能感兴趣的:(Vectors.dense())