Azure Data Studio 的机器学习扩展(预览版)Machine Learning extension for Azure Data Studio (Preview)

借助 Azure Data Studio 的机器学习扩展,你可以管理包、导入机器学习模型、作出预测以及创建笔记本,以运行 SQL 数据库试验。The Machine Learning extension for Azure Data Studio enables you to manage packages, import machine learning models, make predictions, and create notebooks to run experiments for your SQL databases. 此扩展当前处于预览状态。This extension is currently in preview.

先决条件Prerequisites

需要在运行 Azure Data Studio 的计算机上安装以下必备组件。The following prerequisites need to be installed on the computer you run Azure Data Studio.

  • Python 3Python 3. 安装 Python 后,需要在扩展设置下指定 Python 安装的本地路径。Once you have installed Python, you need to specify the local path to a Python installation under Extension Settings. 如果在 Azure Data Studio 中使用了 Python 内核笔记本,则扩展将默认使用笔记本中的路径。If you have used a Python kernel notebook in Azure Data Studio, the extension will use the path from the notebook by default.

  • 适用于 Windows、macOS 或 Linux 的 Microsoft ODBC Driver 17 for SQL ServerMicrosoft ODBC driver 17 for SQL Server for Windows, macOS, or Linux.

  • R 3.5(可选)。R 3.5 (optional). 当前不支持 3.5 以外的其他版本。Other version than 3.5 is currently not supported. 安装 R 3.5 后,需要启用 R 并在扩展设置下指定 R 安装的本地路径。Once you have installed R 3.5, you need to enable R and specify the local path to an R installation under Extension Settings. 仅当要管理数据库中的 R 包时,才需要此项。This is only required if you want to manage R packages in your database.

在 ADS 中安装 Python 3 时遇到问题?Trouble installing Python 3 from within ADS?

如果尝试安装 Python 3,但收到有关 TLS/SSL 的错误,请添加以下两个可选组件:If you attempt to install Python 3 but get an error about TLS/SSL, add these two, optional components:

示例错误:sample error:

$: ~/0.0.1/bin/python3 -m pip install --user "jupyter>=1.0.0" --extra-index-url https://prose-python-packages.azurewebsites.net
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.org/simple, https://prose-python-packages.azurewebsites.net
Requirement already satisfied: jupyter

安装以下内容:install these:

  • Homebrew(可选)。Homebrew (optional). 安装 homebrew,然后从命令行运行 brew updateInstall homebrew, then run brew update from the command line.

  • openssl(可选)。openssl (optional). 接下来运行 brew install opensslNext run brew install openssl.

安装扩展Install the extension

若要在 Azure Data Studio 中安装机器学习扩展,请按照以下步骤操作。To install the Machine Learning extension in Azure Data Studio, follow the steps below.

  1. 在 Azure Data Studio 中打开扩展管理器。Open the extensions manager in Azure Data Studio. 可以选择扩展图标,也可以在“视图”菜单中选择“扩展”。You can either select the extensions icon or select Extensions in the View menu.

  2. 选择“机器学习”扩展并查看其详细信息。Select the Machine Learning extension and view its details.

  3. 选择“安装” 。Select Install.

  4. 选择“重载”以启用扩展。Select Reload to enable the extension. 仅在首次安装扩展时才需要此步骤。This is only required the first time you install an extension).

扩展设置Extension settings

若要更改机器学习扩展的设置,请按照以下步骤操作。To change the settings for the Machine Learning extension, follow the steps below.

  1. 在 Azure Data Studio 中打开扩展管理器。Open the extension manager in Azure Data Studio. 可以选择扩展图标,也可以在“视图”菜单中选择“扩展”。You can either select the extensions icon or select Extensions in the View menu.

  2. 在“已启用”的扩展下找到“机器学习”扩展 。Find the Machine Learning extension under enabled extensions.

  3. 选择“管理”图标。Select on the Manage icon.

  4. 选择“扩展设置”图标。Select on the Extension Settings icon.

扩展设置如下所示:The extensions settings look like this:

机器学习扩展设置

启用 PythonEnable Python

若要在数据库中使用机器学习扩展以及 Python 包管理,请按照以下步骤操作。To use the Machine Learning extension as well as the Python package management in your database, follow the steps below.

重要

即使不希望在数据库功能中使用 Python 包管理,机器学习扩展也需要启用 Python 并将其配置为可使用大多数功能。The Machine Learning extension requires Python to be enabled and configured to most functionality to work, even if you do not wish to use the Python package management in database functionality.

  1. 确保“机器学习: 启用 Python”已启用。Ensure that Machine Learning: Enable Python is enabled. 默认情况下,此设置处于启用状态。This setting is enabled by default.

  2. 在“机器学习: Python 路径”下提供预先存在的 Python 安装的路径。Provide the path to your pre-existing Python installation under Machine Learning: Python Path. 这可以是 Python 可执行文件的完整路径,也可以是该可执行文件所在的文件夹。This can either be the full path to the Python executable or the folder the executable is in. 如果在 Azure Data Studio 中使用了 Python 内核笔记本,则扩展将默认使用笔记本中的路径。If you have used a Python kernel notebook in Azure Data Studio, the extension will use the path from the notebook by default.

启用 REnable R

若要在数据库中使用机器学习扩展进行 R 包管理,请按照以下步骤操作。To use the Machine Learning extension for R package management in your database, follow the steps below.

  1. 确保“机器学习: 启用 R”已启用。Ensure that Machine Learning: Enable R is enabled. 默认情况下,此设置处于禁用状态。This setting is disabled by default.

  2. 在“机器学习: R 路径”下提供预先存在的 R 安装的路径。Provide the path to your pre-existing R installation under Machine Learning: R Path. 这必须是 R 可执行文件的完整路径。This has to be the full path to the R executable.

使用机器学习扩展Use the Machine Learning extension

若要在 Azure Data Studio 中使用机器学习扩展,请按照以下步骤操作。To use the Machine Learning extension in Azure Data Studio, follow the steps below.

  1. 在 Azure Data Studio 中打开“连接”Viewlet。Open the Connections viewlet in Azure Data Studio.

  2. 右键选择服务器,并选择“管理”。Right Select on your server and select Manage.

  3. 选择左侧“常规”下的菜单中的“机器学习” 。Select Machine Learning in the left side menu under General.

单击“下一步”下的链接,了解如何使用机器学习扩展在数据库中管理包、作出预测以及导入模型。Follow the links under Next steps to see how you can use the Machine Learning extension for manage packages, make predictions, and import models in your database.

后续步骤Next steps