VectorIndexer学习笔记

VectorIndexer学习笔记

val indexer = new VectorIndexer()
  .setInputCol("features")
  .setOutputCol("indexed")
  .setMaxCategories(2)
  .fit(data).transform(data)
indexer.show(false)
spark.stop()

输出结果如下
在这里插入图片描述
结果分析
特征向量包含3个特征:0,1,2
特征0对应的值有4(1,2,3,5)个,大于设置的2,不进行转换
特征1对应的值有2(1,5)个,不大于设置的2,进行转换:
    1 -> 0
    5 -> 1
特征2对应的值有4(6,7,8,9)个,大于设置的2,不进行转换:

猜你喜欢

转载自blog.csdn.net/qq_29573903/article/details/84764391