How to prepare data into a LibSVM format from DataFrame?

前端 未结 3 804
余生分开走
余生分开走 2020-12-13 07:17

I want to make libsvm format, so I made dataframe to the desired format, but I do not know how to convert to libsvm format. The format is as shown in the figure. I hope that

3条回答
  •  Happy的楠姐
    2020-12-13 08:00

    In order to convert an existing to a typed DataSet I suggest the following; Use the following case class:

    case class LibSvmEntry (
       value: Double,
       features: L.Vector)
    

    The you can use the map function to convert it to a LibSVM entry like so: df.map[LibSvmEntry](r: Row => /* Do your stuff here*/)

提交回复
热议问题