- 发行说明
- 入门指南
- 安装
- 配置
- 集成
- 身份验证
- Working with Apps and Discovery Accelerators
- AppOne 菜单和仪表板
- AppOne 设置
- TemplateOne 1.0.0 菜单和仪表板
- TemplateOne 1.0.0 设置
- TemplateOne menus and dashboards
- TemplateOne 2021.4.0 设置
- Purchase to Pay Discovery Accelerator 菜单和仪表板
- 购买到付款 Discovery Accelerator 设置
- Order to cash Discovery Accelerator 菜单和仪表板
- “订单到现金” Discovery Accelerator 设置
- Basic Connector for AppOne
- SAP Connectors
- 适用于 AppOne 的 SAP 订单到现金连接器
- 适用于 AppOne 的 SAP 采购到付款连接器
- SAP Connector for Purchase to Pay Discovery Accelerator
- SAP Connector for Order-to-Cash Discovery Accelerator
- Superadmin
- 仪表板和图表
- 表格和表格项目
- 应用程序完整性
- How to ....
- 使用 SQL 连接器
- Introduction to SQL connectors
- Setting up a SQL connector
- CData Sync extractions
- Running a SQL connector
- Editing transformations
- 释放 SQL 连接器
- Scheduling data extraction
- Structure of transformations
- Using SQL connectors for released apps
- Generating a cache with scripts
- Setting up a local test environment
- Separate development and production environments
- 实用资源
Process Mining 用户指南
简介
此示例说明如何将 UiPath Process Mining 平台与外部 R 脚本接口,以实现外部数据处理。
安装 R
请按照以下步骤操作,以便能够在平台中使用 R 脚本。
| 步骤 | 操作 |
|---|---|
| 1 | 从以下位置下载最新版本的 R 包 https://cran.r-project.org/bin/windows/base/。 |
| 2 | 在服务器上安装 R。 注意:这必须是安装UiPath Process Mining 的服务器。 |
| 3 | 找到安装目录并找到 Rscript.exe 的路径。 例如:C:/Apps/Rscript.exe |
R 已安装在服务器上,开发者可以使用连接字符串连接到它。
需要安装路径才能为 R 脚本创建连接字符串。
从一些虚拟数据开始,以测试您的工作区设置。例如,使用示例:创建 Python 脚本中所述的“Hello World”示例。然后,虚拟 R 脚本将包含: write("Hello world!", stderr()); quit("default", 1)
简要概述
在此示例中,将创建一个 R 脚本,用于根据追踪对案例进行聚类。
步骤
- 设置服务器设置;
- 编写脚本。
- 设置数据源;
- 设置脚本数据源;
设置服务器设置
通用脚本数据源需要用于要运行的所有外部流程的处理程序。
请按照以下步骤为 R 脚本添加脚本处理程序。
| 步骤 | 操作 |
|---|---|
| 1 | 转到“超级管理员设置”选项卡。 |
| 2 | 添加一个字段 GenericScriptHandlers,并将一个具有一个键“r”的对象作为值,该键将 Python 可执行文件的路径作为值。例如:"GenericScriptHandlers": {"r": "C:/Apps/Rscript.exe",} |
| 3 | 单击“保存”。 |
编写脚本
在文本编辑器中,新建一个空白文本文件,然后输入以下代码。
# get command line arguments
args <- commandArgs(trailingOnly=TRUE)
inputfile <- args[1]
# read csv file
input <- file(inputfile, 'r')
df <- read.table(input, header=TRUE, sep=";")
# pre-processing
df <- table(df)
df <- as.data.frame.matrix(df)
df <- df[, sapply(data.frame(df), function(df) c(length(unique(df)))) > 1] #remove columns with unique value
# cluster
df <- scale(df)
kc <- kmeans(df, centers = 5)
cluster <- kc$cluster
# output
resultdata <- cbind(rownames(df), cluster)
colnames(resultdata)[1] <- 'Case ID'
write.table(resultdata, row.names = FALSE, sep=";", qmethod = "double")
# get command line arguments
args <- commandArgs(trailingOnly=TRUE)
inputfile <- args[1]
# read csv file
input <- file(inputfile, 'r')
df <- read.table(input, header=TRUE, sep=";")
# pre-processing
df <- table(df)
df <- as.data.frame.matrix(df)
df <- df[, sapply(data.frame(df), function(df) c(length(unique(df)))) > 1] #remove columns with unique value
# cluster
df <- scale(df)
kc <- kmeans(df, centers = 5)
cluster <- kc$cluster
# output
resultdata <- cbind(rownames(df), cluster)
colnames(resultdata)[1] <- 'Case ID'
write.table(resultdata, row.names = FALSE, sep=";", qmethod = "double")
请按照以下步骤操作。
| 步骤 | 操作 |
|---|---|
| 1 | 将文本文件另存为script.r 。 |
| 2 | 将script.r文件上传到您的工作区。 |
设置数据源
要定义输入数据,请创建一个用于生成.CSV等字符串的属性。它应放置在“全局”表中,因为它将用作表格定义中的输入。
可以使用csvtable函数来定义输入数据。
在此示例中,我们有一个包含“事件”表的应用程序。请参见下图。
请按照以下步骤创建从“全局”表格到“事件”的查找表达式R_input_data 。
| 步骤 | 操作 |
|---|---|
| 1 | 在开发环境中打开应用程序,然后转到“数据”选项卡。 |
| 2 | 选择“全局表”。右键单击表格项目列表中的“全局”表格,然后选择“新建表达式…” 。 |
| 3 | 将类型设置为查找(查找) 。 |
| 4 | 选择“事件”作为输入表。 |
| 5 | 输入以下表达式: csvtable( 'CaseID', records.text(Case_ID) , 'Activity', records.text(Activity) ) |
| 6 | 在名称字段中输入R_input_data 。 |
| 7 | 单击“确定”以在“全局”表中保存表达式属性。 |
系统将在“全局”表中创建表达式属性。请参见下图。
设置脚本数据源
接下来,在将调用脚本的应用程序中设置一个数据源表。
请按照以下步骤设置脚本数据源。
| 步骤 | 操作 |
|---|---|
| 1 | 在“数据”选项卡中,新建“连接字符串表”。 |
| 2 | 将New_table重命名为RscriptExample 。 |
| 3 | 右键单击RscriptExample表格,然后单击“高级”>“选项…” 。 |
| 4 | 在“表格选项”对话框中,将“表格范围”设置为“工作区” 。 |
| 5 | 双击RscriptExample表格以打开“编辑连接字符串表格”窗口。 |
| 6 | 输入以下内容作为“连接字符串” : ``'driver={mvscript |
| 7 | 输入以下内容作为查询: '' +'&scriptFile=' + urlencode("script.r") +'&inputData=' + urlencode(R_input_data)请参见下图。 |
| 8 | 单击“确定” ,然后单击“是”以重新加载数据。 |
加载数据时,系统会检测新属性。单击“是” (2x),然后单击“确定” 。
Rscript_example表现在具有两个数据源属性: Case_ID和cluster 。
请参见下图。
在查询字段中定义 R 脚本
您还可以在“编辑连接字符串”对话框的“查询” 字段中定义 R 脚本,而不是使用包含 R 脚本的单独文件。在这种情况下,您可以使用scriptText参数而不是scriptFile参数。
请参见下图。