【发布时间】:2019-04-11 01:46:59
【问题描述】:
假设我想在数据集的每一列上使用ft_max_abs_scaler。这是文档中的内容:
sc <- spark_connect(master = "local")
iris_tbl <- sdf_copy_to(sc, iris, name = "iris_tbl", overwrite = TRUE)
features <- c("Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width")
iris_tbl <- iris_tbl %>%
ft_vector_assembler(input_col = features,
output_col = "features_temp") %>%
ft_max_abs_scaler(input_col = "features_temp",
output_col = "features")
请注意,ft_vector_assembler 创建了一个新列 features_temp,ft_max_abs_scaler 创建了另一个新列 features。现在假设我想将向量分解成单独的列,我必须这样做:
iris_tbl <- iris_tbl %>% sdf_separate_column("features", into = features)
# result in error because column name cannot be the same
由于没有删除列的好方法,我想知道是否有更好的方法来使用 Sparklyr 进行特征转换,而无需不断创建新列。
【问题讨论】:
-
叹息......事情是 -
sdf_separate_column是一种非常糟糕的想法的定义。虽然它在玩具示例上看起来很棒,但我只是没有考虑底层系统的细节,只是没有扩展,如果你想将它与其他o.a.s.ml工具集成,它完全没用。您也可以删除列(例如transmute(...)或select(-to_drop))。
标签: r apache-spark sparklyr