我正在尝试编写一个简单的 R 序列聚类/分组/简化解决方案。我是一个初学者,有一段时间没有使用 R,所以请原谅简单和愚蠢的问题/解决方案。任务取自 SAP,它们代表 P2P 流程的执行。
概述:
输入:经过一些建议,我认为输入数据应该涵盖单词而不是它们的 id(我们不想比较数字而是简化单词序列)
选项 1:SAP P2P 中的步骤序列,例如:
Sequence 1:Purchase Order/NB > Goods Receipt/TA > Invoice Receipt/NA > Goods Receipt/TA
Sequence 2:Purchase Order/NB > Goods Receipt/TA > Invoice Receipt/NA
我的数据集包含大约 700 个序列(测试 100),它们既短(5 步)又长(甚至超过 50)。
问题是我(在结果解释期间)不想比较所有,即 700 个序列,但我想以某种方式区分相似的序列。通常,特别是对于长序列,在 20 步之后会发现差异,例如:
Seq1: PR > PO > GR > IR > GR > IR > GR > IR > 付款
Seq2: PR > PO > GR > IR > IR > GR > GR > IR > 付款
最后,它应该会导致发现流程执行中的低效率。我的问题是,你对我如何接近那个问题之王有什么建议吗?阅读您的评论后,我认为聚类方法不是正确的方法。我真的不在乎我们是否应该使用集群或其他东西,重要的是简化流程。
我将不胜感激任何提示,建议等。
测试数据(> 用作分隔符)。
text_data <- c("Invoice Posting (Logistics invoice) > Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/NB", "Purchase order/NB > Goods Receipt/WE",
"Purchase order/NB > Goods Receipt/WE > Goods Return/WE", "Purchase order/NB > Goods Receipt/WE > Goods Return/WE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE",
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE",
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA",
"Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/ZI > Invoice Posting (Logistics invoice) > Clearing /AB",
"Purchase order/NB > Goods Return/WE", "Purchase order/NB > Goods Return/WE > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/NB > Goods Return/WE > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /ZA",
"Purchase order/NB > Goods Return/WE > Credit Note Posting (Account maintenance) > Credit Note (Account maintenance)/AE",
"Purchase order/NB > Goods Return/WE > Credit Note Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA",
"Purchase order/NB > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ",
"Purchase order/UB", "Purchase order/UB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE",
"Purchase order/ZB", "Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Invoice Posting (Logistics invoice)",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Invoice Posting (Logistics invoice) > Clearing /ZA",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase order/ZR", "Purchase order/ZR > Goods Receipt/WE",
"Purchase order/ZR > Goods Receipt/WE > Goods Return/WE", "Purchase order/ZR > Goods Receipt/WE > Goods Return/WE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE",
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE",
"Purchase order/ZR > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Account maintenance)/AE > Invoice Posting (Account maintenance)",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note Posting (Logistics invoice, cancel) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice)",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note (Logistics invoice)/RE > Credit Note Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE",
"Purchase order/ZR > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase order/ZR > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase order/ZR > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Clearing /KZ",
"Purchase requisition/NB", "Purchase requisition/NB > PR release - MRP / RFQ / purchase order",
"Purchase requisition/NB > PR release - RFQ / purchase order",
"Purchase requisition/NB > Purchase order/NB", "Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Account maintenance) > Invoice Receipt (Account maintenance)/AE",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /AB",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Credit Note Posting (Logistics invoice, cancel) > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /AB > Credit Note (Logistics invoice, cancel)/RE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Credit Note Posting (Logistics invoice, cancel) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /ZA",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice)",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/RE > Invoice Posting (Logistics invoice) > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/ZI > Invoice Posting (Logistics invoice) > Clearing /AB",
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE",
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /AB",
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /KZ",
"Purchase requisition/NB > Purchase order/NB > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/RE > Clearing /ZA",
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE",
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Goods Receipt/WE > Invoice Posting (Logistics invoice) > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE",
"Purchase requisition/NB > Purchase order/ZB > Delivery (Stock Transfer) > Goods Issue for Stock Transfer > Invoice Posting (Logistics invoice) > Goods Receipt/WE > Invoice Receipt (Logistics invoice)/IE > Clearing /ZA",
"Purchase requisition/RV")