Scala> Val data=https://bbs.csdn.net/topics/spark.sparkContext.
| textFile (" file:////media/sf_shared_file/train.csv ").
| map (_. The split () ", ").
| map (p=& gt; User_log (Vectors. Dense (p (0). ToDouble, p (1). ToDouble, p (2). ToDouble, p (3). ToDouble, p (4). The toString))). ToDF ()
Unspecified value parameter lable.
The map (p=& gt; User_log (Vectors. Dense (p (0). ToDouble, p (1). ToDouble, p (2). ToDouble, p (3). ToDouble, p (4). The toString))). ToDF ()
^
Class user_log
Case class user_log (the features: org. Apache. Spark. Ml. Linalg. Vector, lable: Double)
"Train". CSV:
User_id age_range gender merchant_id label
34176 6 0 944-1
34176 6 0 412-1
34176 6 0 1945-1
6 0 4752-1 34176
CodePudding user response:
The map (p=& gt; User_log ( Vectors. Dense (p (0). ToDouble, p (1). ToDouble, p (2). ToDouble, p (3). ToDouble) , p (4). The toString)))