使用Spark ML处理数据框中的多个特征

我在跟随这个教程 https://mapr.com/blog/churn-prediction-sparkml/ 时发现,csv结构需要手动编写如下:

val schema = StructType(Array(    StructField("state", StringType, true),    StructField("len", IntegerType, true),    StructField("acode", StringType, true),    StructField("intlplan", StringType, true),    StructField("vplan", StringType, true),    StructField("numvmail", DoubleType, true),    StructField("tdmins", DoubleType, true),    StructField("tdcalls", DoubleType, true),    StructField("tdcharge", DoubleType, true),    StructField("temins", DoubleType, true),    StructField("tecalls", DoubleType, true),    StructField("techarge", DoubleType, true),    StructField("tnmins", DoubleType, true),    StructField("tncalls", DoubleType, true),    StructField("tncharge", DoubleType, true),    StructField("timins", DoubleType, true),    StructField("ticalls", DoubleType, true),    StructField("ticharge", DoubleType, true),    StructField("numcs", DoubleType, true),    StructField("churn", StringType, true)

然而,我的数据集有335个特征,我不想全部手动编写…有没有简单的方法来获取这些特征并相应地定义架构?


回答:

我在这里找到了解决方案: https://dzone.com/articles/using-apache-spark-dataframes-for-processing-of-ta 比我想象的要简单

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注