r - azuremlsdk R : How to convert dataset into R dataframe?

标签 r azure azure-machine-learning-service

对于 AzureML Python SDK,我们可以使用 get_by_name() 返回数据集。

import azuremlsdk
mydata = get_by_name(myworkspace, 'mydata')

我可以通过.to_pandas_dataframe()方法获取mydata的panda dataframe

mydata.to_pandas_dataframe()

对于 R 等价物,我被困在这里

mydata <- azuremlsdk::get_dataset_by_name(myworkspace, 'mydata')

问题是,R 有哪些选项可以让我获得表格,例如 csv 或 tibble 形式的表格?

我注意到 R 的 AzureML SDK 的文档记录不如 Python,这使得迁移到 AzureML 对于我们的 R 代码库来说非常具有挑战性。

最佳答案

Azure 机器学习数据集允许您将数据集中的所有记录加载到数据框中,然后将当前数据集转换为包含 CSV 文件或 Parquet 文件的 FileDataset。

load_dataset_into_data_frame() => 将数据集中的所有记录加载到数据框中。

convert_to_dataset_with_csv_files() => 将当前数据集转换为包含 CSV 文件的 FileDataset。

convert_to_dataset_with_parquet_files() => 将当前数据集转换为包含 Parquet 文件的 FileDataset。

示例:将数据转换为数据帧。

#' Load all records from the dataset into a dataframe.
#'
#' @description
#' Load all records from the dataset into a dataframe.
#'
#' @param dataset The Tabular Dataset object.
#' @return A dataframe.
#' @export
#' @md
load_dataset_into_data_frame <- function(dataset)   {
  dataset$to_pandas_data_frame()
}

#' Convert the current dataset into a FileDataset containing CSV files.
#'
#' @description
#' Convert the current dataset into a FileDataset containing CSV files.
#'
#' @param dataset The Tabular Dataset object.
#' @param separator The separator to use to separate values in the resulting file.
#' @return A new FileDataset object with a set of CSV files containing the data
#' in this dataset.
#' @export
#' @md

convert_to_dataset_with_csv_files <- function(dataset, separator = ",") {
  dataset$to_csv_files(separator)
}

#' Convert the current dataset into a FileDataset containing Parquet files.
#'
#' @description
#' Convert the current dataset into a FileDataset containing Parquet files.
#' The resulting dataset will contain one or more Parquet files, each corresponding
#' to a partition of data from the current dataset. These files are not materialized
#' until they are downloaded or read from.
#'
#' @param dataset The Tabular Dataset object.
#' @return A new FileDataset object with a set of Parquet files containing the
#' data in this dataset.
#' @export
#' @md
convert_to_dataset_with_parquet_files <- function(dataset) {
  dataset$to_parquet_files()
}

引用: Azuremlsdk - working with datasets

关于r - azuremlsdk R : How to convert dataset into R dataframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61937349/

相关文章:

R:计算余弦相似度的正确方法?

R 使用变量的值作为数据框列名

azure - 如何通过 Azure 设置 MongoLab

c# - OData 错误响应缺少异常详细信息 C#

azure - 如何查看对预测结果影响最大的列?

Azure:决策林模型评分问题

r - 如何禁用 RMD 文件中代码区域的拼写检查(Markdown、knitr、R)

azure - 使用 Azure CLI 创建 ML 环境时,并不总是会构建它

azure - 将 azure ml studio 设计器项目导出为 jupyter 笔记本?

r - 手动颜色和条件填充而不覆盖geom_point中的position_dodge?