简体   繁体   English

在 Azure ML 中安装 R 包

[英]Install R Packages in Azure ML

Its my 1st time using Azure ML and I am having a rough time.这是我第一次使用Azure ML ,我过得很艰难。 I need to install multiple R packages that are not provided by default in Azure ML .我需要安装Azure ML默认不提供的多个R packages To make it simple, lets assume that I only need to install the forecast package.为简单起见,假设我只需要安装forecast包。

Based on what is written here , I also need to plan the installation of the dependencies of the forecast package .根据这里写的内容,我还需要规划forecast package的依赖项的安装。 However, based on the documentation , the forecast package has almost a dozen dependencies.但是,根据文档forecast package几乎有十几个依赖项。 Furthermore, these dependencies probably have dependencies that are not installed by default in Azure ML .此外,这些依赖项可能具有默认情况下未安装在Azure ML中的依赖项。 In addition, it does not seem quite right to upload a zip file in Azure ML and to try to make all the dependencies work out.此外,在 Azure ML 中上传 zip 文件并尝试使所有依赖项都正常工作似乎不太正确。

Is there any other way to install the forecast package that is easier and simpler than what I found online?有没有比我在网上找到的更简单、更简单的安装forecast package的方法? What do companies do?公司做什么? Uploading a zip file does not seem viable!上传 zip 文件似乎不可行!

Unfortunately yes. 不幸的是。 You can do 2 things. 您可以做两件事。

  1. First figure out which of the dependencies are already installed in azureml. 首先确定azureml中已经安装了哪些依赖项。 See this blogpost 看到这个博客文章

    Use Execute R script task in AML studio and copy paste the below script: 在AML Studio中使用Execute R脚本任务,然后复制粘贴以下脚本:

     out <- data.frame(installed.packages(,,,fields=”Description”)) maml.mapOutputPort(“out”) 
  2. Collect all depended packages (imports and linkingto) and add these to the zip file (in the correct order) and follow the information in the blogpost you linked to. 收集所有依赖的程序包(导入和linkingto),并将它们添加到zip文件中(以正确的顺序),并遵循链接到的博客文章中的信息。

I use option 1, since that limits the amount of packages needed. 我使用选项1,因为这限制了所需的软件包数量。 But be aware of version differences on azureML and cran. 但是请注意azureML和cran的版本差异。

You can use miniCRAN ( https://cran.r-project.org/web/packages/miniCRAN/index.html ) to build the zip file with all dependencies included then upload the zip file and use it to install your required packages. 您可以使用miniCRAN( https://cran.r-project.org/web/packages/miniCRAN/index.html )构建包含所有依赖项的zip文件,然后上传zip文件并使用它来安装所需的软件包。 It also allows you to choose the target platform (type="win.binary") and R version (RVersion="3.1") which are crucial when using Azure ML. 它还允许您选择目标平台(type =“ win.binary”)和R版本(RVersion =“ 3.1”),这些平台在使用Azure ML时至关重要。 There is a tutorial here ( http://blog.revolutionanalytics.com/2015/10/using-minicran-in-azure-ml.html ) that outlines the steps. 这里有一个概述步骤的教程( http://blog.revolutionanalytics.com/2015/10/using-minicran-in-azure-ml.html )。

There is another simple solution to upload custom package on Azure ML Studio. 还有另一种简单的解决方案,可以在Azure ML Studio上上传自定义程序包。 I have used quanteda as example. 我以quanteda为例。 Empty the installed packages folder. 清空已安装的软件包文件夹。 . It is needed to avoid the confusion between the packages that already were in the local environment and these ones who has recently been installed. 需要避免本地环境中已有的软件包与最近安装的软件包之间的混淆。 Next, install the package. 接下来,安装软件包。 During the installation it is important to keep of the packages being installed and the order of installation (as these packages may also have their own dependencies). 在安装过程中,重要的是要保持软件包的安装和安装顺序(因为这些软件包也可能有其自己的依赖性)。

 - le package ‘chron’ a été décompressé et les sommes MD5 ont été
   vérifiées avec succés 
 - le package ‘RColorBrewer’ a été décompressé et
   les sommes MD5 ont été vérifiées avec succés
 - ...
 - le package ‘quanteda’ a été décompressé et les
   sommes MD5 ont été vérifiées avec succés

Find all the relevant packages in the same folder as mentioned above: the C:\\Users\\\\Documents\\R\\win-library\\. 在上述同一文件夹中找到所有相关的软件包:C:\\ Users \\\\ Documents \\ R \\ win-library \\。 It is then needed to compress each package separately. 然后需要分别压缩每个程序包。 To save time you may create a simple batch file the will zip (using 7z application) each folder in the directory (for /d %%X in (*) do "c:\\Program Files\\7-Zip\\7z.exe" a "%%X.zip" "%%X\\"). 为了节省时间,您可以创建一个简单的批处理文件,该文件将对目录中的每个文件夹(使用(*)中的/ d %% X)进行压缩(使用7z应用程序),执行“ c:\\ Program Files \\ 7-Zip \\ 7z.exe”一个“ %% X.zip”“ %% X \\”)。

Then put all the archives into one and upload it on the Azure ML environment. 然后将所有存档放入一个文件夹,然后将其上传到Azure ML环境。 NOTE: most of the packages that quanteda depends on are already installed on the Azure virtual machine so there is no need to install them manually. 注意:Quanteda依赖的大多数程序包已经安装在Azure虚拟机上,因此无需手动安装它们。 However, for the others, it is necessary to install them manually before installing the quanteda. 但是,对于其他组件,有必要在安装Quanteda之前手动安装它们。 You may either compare the list of dependencies with the available packages list or upload everything and add the packages step by step and look through the output log. 您可以将依赖项列表与可用的软件包列表进行比较,也可以上传所有内容,然后逐步添加软件包并浏览输出日志。 For instance, if you install quanteda directly without installing its dependencies (install.packages("src/quanteda.zip", lib = ".", repos = NULL, verbose = TRUE)) with generate the following error: 例如,如果直接安装Quanteda而不安装其依赖项(install.packages(“ src / quanteda.zip”,lib =“。”,repos = NULL,verbose = TRUE)),则会生成以下错误:

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
there is no package called 'ca'

Now it's evident that all the packages that go before 'ca' are already pre-installed. 现在很明显,所有在“ ca”之前的软件包都已预安装。 So, adding additional installation will solve the issue. 因此,添加其他安装将解决此问题。 Thus, to install the quanteda the following commands are needed: 因此,要安装Quanteda,需要以下命令:

install.packages("src/ca.zip", lib = ".", repos = NULL, verbose = TRUE)
install.packages("src/quanteda.zip", lib = ".", repos = NULL, verbose = TRUE)
library(quanteda, lib.loc=".", verbose=TRUE)

You are now able to use your custom packages. 现在,您可以使用自定义程序包了。

there is a much simpler way!有一个更简单的方法! create your script with the installs使用安装创建脚本

eg my script called eli_test_01.R has:例如,我的名为 eli_test_01.R 的脚本有:

install.packages("popbio") install.packages("popbio")

then go to the terminal and use sudo to run the scrip: sudo Rscript eli_test_01.R然后转到终端并使用 sudo 运行脚本: sudo Rscript eli_test_01.R

the sit back坐下来

Eli伊莱

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM