对于 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()
}
关于r - azuremlsdk R : How to convert dataset into R dataframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61937349/