我有一个数据集作为一个csv文件。它有大约50列,其中大部分是分类的。我计划使用一个新的测试数据集运行一个RandomForest多类分类。
这其中的痛点是处理分类变量。处理这些问题的最好方法是什么?我在星火网站http://spark.apache.org/docs/latest/ml-guide.html#example-pipeline中阅读了管道指南,它从硬编码序列中创建了一个DataFrame,它还带有一个空格分隔的字符串。这看起来非常具体,我希望在他们如何使用CSV文件的特性上实现同样的目标。
简而言之,我希望实现与链接中相同的功能,但使用CSV文件。
有什么建议吗?
编辑: Data -> 50功能,100 k行,大部分是字母数字分类,我对MLlib非常陌生,因此很难为我的数据找到合适的管道。我试着从文件中创建一个DataFrame,但是对于如何编码分类列感到困惑。我的疑虑如下
1. The example in the link above tokenizes the data ans uses it but I have a dataframe.
2. Also even if I try using a StringIndexer , should I write an indexer for every column? Shouldn't there be one method which accepts multiple columns?
3. How will I get back the label from the String Indexer for showing the prediction?
5. For new test data, how will I keep consistent encoding for every column?发布于 2015-11-30 08:39:47
我建议查看一下功能转换器http://spark.apache.org/docs/ml-features.html,特别是StringIndexer和VectorAssembler。
https://stackoverflow.com/questions/33991538
复制相似问题