@ -1,207 +1,353 @@
< template >
< el -scrollbar ref = "scrollbar" height = "800px" >
<!-- < el -scrollbar ref = "scrollbar" height = "800px" > -- >
< div class = "main-top" >
< span style = "font-weight: bold; font-size: 18px;color: #3596EB; "> 任务描述 < / span >
< p style = "font-weight: 400; font-size: 12px;color: #E6E6E6; "> ( 给出任务清单参考 , 做哪些数据的统计分析 ) Lorem ipsum dolor sit amet , consectetur adipiscing elit . Aenean euismod bibendum laoreet . Proin gravida dolor sit amet lacus accumsan et viverra justo commodo . Proin sodales pulvinar sic tempor . Sociis natoque penatibus et magnis dis parturient montes , nascetur ridiculus mus . Nam fermentum , nulla luctus pharetra vulputate , felis tellus mollis orci , sed rhoncus pronin sapien nunc accuan eget . < / p >
< span style = "font-weight: bold; font-size: 18px; color: #3596eb "> 任务描述 < / span >
< p style = "font-weight: 400; font-size: 12px; color: #e6e6e6 "> ( 给出任务清单参考 , 做哪些数据的统计分析 ) Lorem ipsum dolor sit amet , consectetur adipiscing elit . Aenean euismod bibendum laoreet . Proin gravida dolor sit amet lacus accumsan et viverra justo commodo . Proin sodales pulvinar sic tempor . Sociis natoque penatibus et magnis dis parturient montes , nascetur ridiculus mus . Nam fermentum , nulla luctus pharetra vulputate , felis tellus mollis orci , sed rhoncus pronin sapien nunc accuan eget . < / p >
< / div >
< div class = "main-but" >
< el -button @click ="runResultShow=true" > < img src = "../../../assets/images/导入.png" alt = "" > 算法知识导入 < / e l - b u t t o n >
< el -button @click ="taskSubmit" > < img src = "../../../assets/images/提交.png" alt = "" > 实训任务提交 < / e l - b u t t o n >
< el -button @ click = "runResultShow = true" >
< img src = "../../../assets/images/导入.png" alt = "" / >
算法知识导入
< / e l - b u t t o n >
< el -button @click ="taskSubmit" >
< img src = "../../../assets/images/提交.png" alt = "" / >
实训任务提交
< / e l - b u t t o n >
< / div >
< div class = "app-main" >
< div class = "main-left" >
< el -scrollbar height = "550px" style = "padding: 0 10px" min -size = " 5 " >
< div >
< div class = "left-top" >
< span > 一 、 选择指标 < / span >
< / div >
< div class = "metrics" >
< el -select v-model ="input" placeholder="请选择" style="width: 180px" @change="optionData" >
< el -option
v - for = "item in options"
: key = "item.value"
: label = "item.label"
: value = "item.value"
/ >
< el -option v -for = " item in options " :key ="item.value" :label ="item.label" :value ="item.value" / >
< / e l - s e l e c t >
< / div >
< div class = "metrics-table" style = "margin-top: 10px" >
< el -table border :data ="tableData" style = "width: 100%" :header-cell-style ="headerCellStyle" @selection-change ="handleSelectionChange" >
< el -table -column type = "selection" label = "Date" align = "center" :selectable ="flag" / >
< el -table -column prop = "text" label = "指标" align = "center" / >
< el -table border :data ="tableData" style = "width: 100%" :header-cell-style ="headerCellStyle" @selection-change ="handleSelectionChange" >
< el -table -column type = "selection" label = "Date" align = "center" :selectable ="flag" / >
< el -table -column prop = "text" label = "指标" align = "center" / >
< / e l - t a b l e >
< el -button @click ="taskZB" > 确 定 < / el -button >
< / div >
< div class = "left-top" style = "margin-top: 50px">
< div class = "left-top" style = "margin-top: 50px">
< span > 二 、 数据预处理 < / span >
< / div >
< div class = "metrics" >
< el -select v-model ="input2" @change="optionData2" placeholder="请选择" style="width: 180px" >
< el -option
v - for = "item in options2"
: key = "item.value"
: label = "item.label"
: value = "item.value"
/ >
< el -option v -for = " item in options2 " :key ="item.value" :label ="item.label" :value ="item.value" / >
< / e l - s e l e c t >
< / div >
< div class = "metrics" style = "margin-top: 15px">
< div class = "metrics" style = "margin-top: 15px" >
< el -select v-model ="input3" @change="optionData2" placeholder="请选择" style="width: 180px" >
< el -option
v - for = "item in options3"
: key = "item.value"
: label = "item.label"
: value = "item.value"
/ >
< el -option v -for = " item in options3 " :key ="item.value" :label ="item.label" :value ="item.value" / >
< / e l - s e l e c t >
< / div >
< div class = "left-top" style = "margin-top: 50px" >
< span > 三 、 模型参数设置 < / span >
< / div >
< div class = "metrics-table" style = "margin-top: 10px" >
< span style = "font-weight: 400;font-size: 12px;color: #FFFFFF;" >
聚类方法 :
< / span >
< div class = "metrics" style = "margin-top:10px" >
< span style = "font-weight: 400; font-size: 12px; color: #ffffff" > 聚类方法 : < / span >
< div class = "metrics" style = "margin-top: 10px" >
< el -select v-model ="input4" placeholder="请选择" style="width: 180px" >
< el -option
v - for = "item in options4"
: key = "item.value"
: label = "item.label"
: value = "item.value"
/ >
< el -option v -for = " item in options4 " :key ="item.value" :label ="item.label" :value ="item.value" / >
< / e l - s e l e c t >
< / div >
< div style = "margin-top:10px;color:#FFFFFF" >
< span style = "font-weight: 400;font-size: 12px;color: #FFFFFF;" >
最小支持度阀值 :
< / span >
< el -input v -model = " input5 " style = "width: 160px;margin-top:5px" / > %
< div style = "margin-top: 10px; color: #ffffff" >
< span style = "font-weight: 400; font-size: 12px; color: #ffffff" > 最小支持度阀值 : < / span >
< el -input v -model = " input5 " style = "width: 160px; margin-top: 5px" / >
%
< / div >
< div style = "margin-top:10px;color:#FFFFFF" >
< span style = "font-weight: 400;font-size: 12px;color: #FFFFFF;" >
最小置信度 :
< / span >
< el -input v -model = " input6 " style = "width: 160px;margin-top:5px" / > %
< div style = "margin-top: 10px; color: #ffffff" >
< span style = "font-weight: 400; font-size: 12px; color: #ffffff" > 最小置信度 : < / span >
< el -input v -model = " input6 " style = "width: 160px; margin-top: 5px" / >
%
< / div >
< el -button @click ="computation" > 计 算 < / el -button >
< / div >
< / div >
< div style = "margin-top: auto;" >
< / e l - s c r o l l b a r >
< div style = "margin-top: auto" >
< div class = "startOver" @click ="startOver()" >
< img src = "../../../assets/images/重新开始.png" alt = "" >
< img src = "../../../assets/images/重新开始.png" alt = "" / >
< span > 重新开始 < / span >
< / div >
< / div >
< / div >
< / div >
< div class = "main-right" >
< el -scrollbar height = "500px" ref = "scrollbar" style = "padding: 20px" >
< div >
< span style = "font-weight: bold; font-size: 18px;color: #3596EB; "> 分析数据 : < / span >
< el -table :data ="tableData2" style = "width: 94%;margin-top: 10px" :header-cell-style ="headerCellStyle" height = "350" >
< el -table -column v -for = " column in tableLabel " :key ="column.prop" :prop ="column.prop" :label ="column.label" align = "center" / >
< span style = "font-weight: bold; font-size: 18px; color: #3596eb "> 分析数据 : < / span >
< el -table :data ="tableData2" style = "width: 100%; margin-top: 10px" :header-cell-style ="headerCellStyle" height = "350" >
< el -table -column v -for = " column in tableLabel " :key ="column.prop" :prop ="column.prop" :label ="column.label" align = "center" / >
< / e l - t a b l e >
<!-- < el -pagination style = "margin-top:10px" background layout = "prev, pager, next" :total ="1000" / > -- >
< / div >
< div class = "analysisResults" style = "margin-top: 20px" >
< span style = "font-weight: bold; font-size: 18px;color: #3596EB;display: block; "> 分析结果 : < / span >
< span style = "font-weight: bold; font-size: 18px; color: #3596eb; display: block "> 分析结果 : < / span >
< el -button v-if ="uplodFlag" @click="upload" > 下 载 < / el -button >
< el -table ref = "exportTableRef" :data ="tableData3" row -key = " TSuid " style = "width: 94%;margin-top: 10px" :header-cell-style ="headerCellStyle" height = "350" >
< el -table -column v -for = " column in tableLabel2 " :key ="column.prop" :prop ="column.prop" :label ="column.label" align = "center" / >
< el -table ref = "exportTableRef" :data ="tableData3" row -key = " TSuid " style = "width: 100%; margin-top: 10px" :header-cell-style ="headerCellStyle" height = "350" >
< el -table -column v -for = " column in tableLabel2 " :key ="column.prop" :prop ="column.prop" :label ="column.label" align = "center" / >
< / e l - t a b l e >
<!-- < el -pagination style = "margin-top:10px" background layout = "prev, pager, next" :total ="1000" / > -- >
< / div >
< / e l - s c r o l l b a r >
< / div >
< / div >
< / e l - s c r o l l b a r >
<!-- < / e l - s c r o l l b a r > - - >
< el -dialog
v - model = "dialogVisible"
title = "实训任务提交"
width = "600"
custom - class = "dialogClass"
: show - close = "false"
>
< el -dialog v-model ="dialogVisible" title="实训任务提交" width="400" custom-class="dialogClass" :show-close="false" >
< template # header = "{ close, titleId, titleClass }" >
< div class = "my-header" >
< span :id ="titleId" :class ="titleClass" > 实训任务提交 < / span >
< img class = "gbImg" src = "../../../assets/images/关闭.png" @click ="close" alt = "" >
< img class = "gbImg" src = "../../../assets/images/关闭.png" @click ="close" alt = "" / >
< / div >
< img class = "xtImg" src = "../../../assets/images/线条.png" alt = "" >
< img class = "xtImg" src = "../../../assets/images/线条.png" alt = "" / >
< / template >
< div class = "from-item" >
< el -form :inline ="true" label -position = " right " label -width = " 115px " :model ="form" class = "demo-form-inline" >
< el -form -item label = "聚类个数:" >
< el -input style = "width: 120px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< el -form -item label = "最大迭代次数:" >
< el -input style = "width: 120px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< / e l - f o r m >
< span style = "color:#FFFFFF;font-weight: 700;" > 各簇类特征描述 : < / span >
< el -form :inline ="true" label -position = " right " style = "margin:15px 0" label -width = " 115px " :model ="form" class = "demo-form-inline" >
< el -form -item label = "簇类1:" >
< el -input style = "width: 240px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< el -form -item label = "簇类2:" >
< el -input style = "width: 240px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< el -form -item label = "簇类3:" >
< el -input style = "width: 240px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< el -form -item label = "簇类4:" >
< el -input style = "width: 240px;" v -model = " formInline.user " clearable / >
< / e l - f o r m - i t e m >
< / e l - f o r m >
< span style = "color: #ffffff; font-weight: 700" > 最终筛选的关联子集 : < / span >
< div >
< el -checkbox v -model = " formData.value1 " label = "{'牛奶', '面包'}" size = "large" / >
< / div >
< div >
< el -checkbox v -model = " formData.value2 " label = "{'牛奶', '黄油'}" size = "large" / >
< / div >
< div >
< el -checkbox v -model = " formData.value3 " label = "{'面包', '黄油'}" size = "large" / >
< / div >
< div >
< el -checkbox v -model = " formData.value4 " label = "{'啤酒', '黄油'}" size = "large" / >
< / div >
< div >
< el -checkbox v -model = " formData.value5 " label = "{'面包', '啤酒'}" size = "large" / >
< / div >
< / div >
< template # footer >
< div class = "dialog-footer" >
< el -button @ click = "dialogVisible = false" > 确定 < / e l - b u t t o n >
< el -button type = "primary" @ click = "dialogVisible = false" >
返回
< / e l - b u t t o n >
< el -button @click ="task()" > 确 定 < / el -button >
< el -button type = "primary" @ click = "dialogVisible = false" > 返回 < / e l - b u t t o n >
< / div >
< / template >
< / e l - d i a l o g >
< pop -model
: showModel = "runResultShow"
title = "关联规则挖掘"
@ closePop = "runResultShow = false"
>
< pop -model :showModel ="runResultShow" title = "关联规则挖掘" @ closePop = "runResultShow = false" >
< template v -slot : content >
< div >
< p style = "font-weight: 700;font-size:22px" > 一 、 简介 < / p > < p > Apriori算法是一种用于挖掘数据集中频繁项集的算法 , 进而用于生成关联规则 。 这种算法在数据挖掘 、 机器学习 、 市场篮子分析等多个领域都有广泛的应用 。 < / p > < p style = "font-size:19px;font-weight:600" > 什么是关联规则挖掘 ? < / p > < p > 关联规则挖掘是数据挖掘中的一个重要分支 , 其目标是发现在一个数据集中变量间存在的有趣的关联或模式 。 < br / > 例子 : 假设在一个零售商的交易数据中 , 如果客户购买了啤酒 , 他们也很有可能购买薯片 。 这里的 “ 啤酒 ” 和 “ 薯片 ” 就形成了一个关联规则 。 < / p > < p style = "font-size:19px;font-weight:600" > 什么是频繁项集 ? < / p > < p > 频繁项集是在数据集中出现次数大于或等于最小支持度 ( Minimum Support Threshold ) 的项的集合 。 < br / > 例子 : 在超市购物数据中 , 如果 “ 牛奶 ” 和 “ 面包 ” 这一组合经常一起出现在同一个购物篮里 , 并且出现的次数超过了最小支持度 , 那么 { "牛奶" , "面包" } 就是一个频繁项集 。 < / p > < p style = "font-size:19px;font-weight:600" > 什么是支持度与置信度 ? < / p > < li > 支持度 ( Support ) : 是某个项集在所有交易中出现的频率 。 它用于衡量一个项集的普遍性 。 < br / > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 如果我们有100笔交易 , 其中有30笔交易包含了 “ 牛奶 ” , 那么 “ 牛奶 ” 的支持度就是30 % 。 < / li > < li > 置信度 ( Confidence ) : 是在A出现的情况下 , B出现的条件概率 。 < br / > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 如果在包含 “ 牛奶 ” 的所有交易中 , 有70 % 的交易也包含了 “ 面包 ” , 那么从 “ 牛奶 ” 到 “ 面包 ” 的置信度就是70 % 。 < / li >
< p style = "font-size:19px;font-weight:600" > Apriori算法的重要性 < / p > < p > Apriori算法由于其简单 、 高效的特性 , 在数据挖掘中有着广泛的应用 。 它不仅能用于挖掘数据中的隐藏模式 , 还能用于诸如产品推荐 、 用户行为分析 、 网络安全等多个应用场景 。 < br / > 例子 : 在电子商务网站中 , Apriori算法可以用于分析用户购买历史数据 , 进而实现个性化推荐 , 提升销售额和用户满意度 。 < / p > < p style = "font-size:19px;font-weight:600" > 应用场景 < / p > < p > 由于其广泛的用途和灵活性 , Apriori算法在以下几个主要领域内有着广泛的应用 : < / p > < li > 市场篮子分析 : 了解哪些产品经常被一起购买 , 以进行有效的产品布局或优惠策略 。 < / li > < li > 医疗诊断 : 分析病人的历史数据 , 找出病症和治疗方案之间的关联 。 < / li > < li > 网络安全 : 通过分析网络日志 , 找出异常模式 , 以预防或检测安全威胁 。 < / li > < p > 通过这些定义和例子 , 我们可以更全面地了解Apriori算法的基本概念 、 重要性和应用范围 , 为后续的技术解析和实战应用打下坚实的基础 。 < / p > < p style = "font-weight: 700;font-size:22px" > 二 、 理论基础 < / p > < p > 在深入探讨Apriori算法之前 , 理解其背后的理论基础是非常重要的 。 本节将详细介绍关联规则挖掘的基础概念 , 包括项集 、 支持度 、 置信度 、 提升度以及如何使用这些概念来挖掘有用的关联规则 。 < / p > < p style = "font-size:19px;font-weight:600" > 项和项集 < / p > < li > 项 ( Item ) : 在关联规则挖掘中 , 项通常指数据集中的一个元素 。 < br / > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 在一个超市的购物篮数据中 , "牛奶" 、 "面包" 、 "啤酒" 等都是单个的项 。 < / li > < li > 项集 ( Itemset ) : 是一个项的集合 , 可以包含一个或多个项 。 < br / > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : { "牛奶" , "面包" } 和 { "啤酒" , "薯片" , "面包" } 都是项集 。 < / li > < p style = "font-size:19px;font-weight:600" > 支持度 ( Support ) < / p >
< p > 支持度是一个度量 , 用于表示一个项集在整个数据集中出现的频率 。 < br / > ! file < / p > < p style = "font-size:19px;font-weight:600" > 置信度 ( Confidence ) < / p > < p > 置信度表示在包含项集X的所有事务中 , 也包含项集Y的事务的概率 。 < / p > < img src = "@/assets/images/f2001.png" alt = "" > < p style = "font-size:19px;font-weight:600" > 提升度 ( Lift ) < / p > < p > 提升度用于衡量项集X和Y的出现是否相互独立 。 < / p > < img src = "@/assets/images/f2002.png" alt = "" > < p style = "font-size:19px;font-weight:600" > Apriori原理 < / p > < p > Apriori原理是Apriori算法的核心 , 它基于一个简单但重要的观察 : 一个项集是频繁的 , 那么它的所有子集也必须是频繁的 。 < br / > 例子 : 如果 { "牛奶" , "面包" , "啤酒" } 是一个频繁项集 , 那么 { "牛奶" , "面包" } 、 { "牛奶" , "啤酒" } 和 { "面包" , "啤酒" } 也必须是频繁项集 。 < br / > 通过以上的概念和例子 , 我们应该对关联规则挖掘的基础理论有了更深入的了解 。 这为我们后续详解Apriori算法以及实际应用提供了坚实的基础 。 < / p > < p style = "font-weight: 700;font-size:22px" > 三 、 Apriori算法概述 < / p > < p > Apriori算法是由Agrawal和Srikant于1994年提出的 , 用于高效地挖掘频繁项集和生成关联规则 。 其名字 “ Apriori ” 来源于拉丁语 , 意为 “ 从先验知识 ” 。 这很好地反映了算法的核心思想 : 利用已知的频繁项集 ( 即先验知识 ) 来更有效地找到更大的频繁项集 。 < / p > < p style = "font-size:19px;font-weight:600" > 算法步骤 < / p > < img src = "@/assets/images/f2004.png" alt = "" > < p > Apriori算法的执行流程主要包含两个步骤 : < br / > & nbsp ; & nbsp ; 1. 频繁项集生成 ( Frequent Itemset Generation ) : 找出满足最小支持度阈值的所有频繁项集 。 < br / > & nbsp ; & nbsp ; 2. 关联规则生成 ( Association Rule Generation ) : 从频繁项集中生成高置信度的关联规则 。 < / p >
< p style = "font-size:19px;font-weight:600" > 频繁项集生成 < / p > < p > & nbsp ; & nbsp ; 1. 扫描数据集 , 找出所有单一项的支持度 , 并筛选出满足最小支持度的项 。 < br / > & nbsp ; & nbsp ; 2. 使用满足最小支持度的项生成新的候选项集 。 < br / > & nbsp ; & nbsp ; 3. 计算新生成的候选项集的支持度 , 并再次筛选 。 < br / > & nbsp ; & nbsp ; 4. 重复上述步骤 , 直到不能生成新的频繁项集 。 < br / > 例子 : 假设有一个购物交易数据集 , 其中包括5笔交易 。 第一步是计算所有单一商品 ( 如 “ 牛奶 ” , “ 面包 ” 等 ) 在这5笔交易中的出现次数 , 并筛选出那些出现次数达到最小支持度的商品 。 < / p > < p style = "font-size:19px;font-weight:600" > 关联规则生成 < / p > < p > & nbsp ; & nbsp ; 1. 对于每一个频繁项集 , 生成所有可能的非空子集 。 < br / > & nbsp ; & nbsp ; 2. 对每一条生成的规则 ( A \ Rightarrow B ) , 计算其置信度 。 < br / > & nbsp ; & nbsp ; 3. 如果规则的置信度满足最小置信度要求 , 则该规则为有效关联规则 。 < / p > < p > 例子 : 对于频繁项集 { "牛奶" , "面包" , "黄油" } , 可能的规则有 "牛奶, 面包 -> 黄油" , "牛奶, 黄油 -> 面包" 等 。 计算这些规则的置信度 , 并筛选出满足最小置信度的规则 。 < / p > < p style = "font-size:19px;font-weight:600" > 优缺点 < / p > < p style = "font-size:19px;font-weight:600" > 优点 < / p > < li > 简单易懂 : Apriori算法基于直观的原理 , 并且计算过程简单 。 < / li > < li > 可扩展性强 : 算法可以应用于大规模的数据集 。 < / li > < p style = "font-size:19px;font-weight:600" > 缺点 < / p > < li > 计算量大 : 在大数据集上 , 可能需要生成大量的候选项集 。 < / li > < li > 多次扫描数据 : 算法需要多次扫描数据集以计算项集的支持度 , 这在数据集很大时可能是低效的 。 < / li > < p > 例子 : 在一个包含百万级交易数据的电子商务网站中 , 使用Apriori算法可能需要消耗大量计算资源和时间 。 < br / > 通过以上的详细描述和例子 , 我们应该对Apriori算法有了全面而深入的理解 。 这为我们后续的技术解析和实战应用奠定了基础 。 < / p >
< p style = "font-weight: 700;font-size:22px" > 四 、 实战应用 < / p > < p > 在理解了Apriori算法的理论基础和工作原理之后 , 现在我们将进一步探讨其在实际场景中的应用 。 特别是在购物篮分析和推荐系统中 , Apriori算法被广泛应用 。 < br / > 为了更好地说明这一点 , 下面将通过Python展示如何实现Apriori算法 , 并用一个简单的购物数据集进行演示 。 < / p > < p style = "font-size:19px;font-weight:600" > 购物篮分析 < / p > < p > 购物篮分析 ( Market Basket Analysis ) 是一种在零售业非常流行的技术 , 用于发现顾客购买产品之间的关联规则 。 < / p > < p style = "font-size:19px;font-weight:600" > 输入和输出 < / p > < li > 输入 : 一组交易数据 , 每一笔交易包含多个购买的商品 。 < / li > < li > 输出 : 满足最小支持度和最小置信度的关联规则 。 < / li > < p style = "font-size:19px;font-weight:600" > Python实现代码 < / p >
< MdPreview v-model ="text" /><p style="font-weight: 700;font-size:22px">五、性能优化与扩展</p><p>Apriori算法虽然在多个领域有着广泛的应用, 但其在大数据集上的性能表现并不尽如人意。这是由于它需要多次扫描数据集以及生成大量的候选项集。在这一节中, 我们将讨论针对这些问题的性能优化方案和扩展方法。</p><p style="font-size:19px;font-weight:600">优化策略</p><p>优化Apriori算法的主要方法包括: </p><p style="font-size:19px;font-weight:600">减少数据扫描次数</p><p>由于Apriori算法在每一轮都需要扫描整个数据集以计算支持度, 因此一个直观的优化方式就是减少数据扫描的次数。<br />例子: 通过构建一个事务-项倒排索引,你可以在单次数据集扫描后立即找到任何项集的支持度。</p><p style="font-size:19px;font-weight:600">采用数据压缩技术</p><p>可以通过压缩事务数据来减少计算量,例如使用位向量来表示事务。<br />例子: 若数据集中有100个商品, 每一笔交易都可以通过一个100位的位向量来表示。这种方式可以显著减少数据的存储需求。</p><p style="font-size:19px;font-weight:600">使用Hashing技术</p><p>通过使用哈希表来存储候选项集和它们的计数,可以加速支持度的计算。<br />例子: 在生成候选项集时,可以使用哈希函数来将项集映射到哈希表的一个位置,并在该位置增加相应的计数。</p><p style="font-size:19px;font-weight:600">扩展方法</p><p style="font-size:19px;font-weight:600">并行化</p><p>Apriori算法可以通过数据或任务并行化进行扩展, 以利用多处理器或分布式计算环境。<br />例子: 在一个分布式系统中,可以将数据集划分为多个子集,并在各个节点上并行计算支持度和生成频繁项集。</p><p style="font-size:19px;font-weight:600" > 支 持 近 似 挖 掘 < / p > < p > 对于一些应用场景 , 完全精确的频繁项集挖掘可能不是必需的 。 在这种情况下 , 可以使用近似算法来加速计算 。 < br / > 例子 : 使用Monte Carlo方法或其他随机抽样技术 , 通过部分数据来估计整个数据集的频繁项集 。 < / p >
< p style = "font-size:19px;font-weight:600" > 集成其他数据挖掘算法 < / p > < p > Apriori算法可以与其他数据挖掘或机器学习算法结合使用 , 以解决更复杂的问题 。 < br / > 例子 : 在一个推荐系统中 , 除了使用Apriori算法找出频繁项集外 , 还可以使用聚类算法对用户进行分群 , 从而实现更个性化的推荐 。 < br / > 通过这些优化和扩展方法 , 我们不仅可以提升Apriori算法在大数据环境下的性能 , 还可以拓宽其应用范围 。 这些都为进一步的研究和应用提供了有益的方向 。 < / p > < p style = "font-weight: 700;font-size:22px" > 六 、 总结 < / p > < p > 通过本文的探讨 , 我们不仅对Apriori算法有了全面且深入的了解 , 而且掌握了它在实际问题中的应用 , 特别是在购物篮分析和推荐系统方面 。 然而 , 我们也注意到了这一算法在面对大规模数据时存在的局限性 。 < / p > < li > 支持度与置信度的平衡 : 在实际应用中 , 选择合适的支持度和置信度阈值是一门艺术 。 过低的阈值可能会导致大量不显著的关联规则 , 而过高的阈值可能会漏掉一些有用的规则 。 < / li > < li > 实时性问题 : 在动态变化的数据集上 , 如何实现Apriori算法的实时或近实时分析也是一个值得关注的问题 。 这在电子商务等快速响应的场景中尤为重要 。 < / li > < li > 多维 、 多层分析 : 现有的Apriori算法主要集中在单一的项集层面 , 未来可以考虑如何将其扩展到多维或多层的关联规则挖掘 。 < / li > < li > 算法与模型的集成 : 未来的研究趋势可能会更多地集中在将关联规则挖掘与其他机器学习模型 ( 如神经网络 、 决策树等 ) 集成 , 以解决更为复杂的问题 。 < / li >
< p > 在今后的工作中 , 探究这些技术洞见的相关性和应用价值 , 以及将Apriori算法与现代计算架构 ( 如GPU 、 分布式计算等 ) 更紧密地结合 , 将是关键的研究方向 。 < br / > 总之 , Apriori算法在数据挖掘和关联分析领域有着广阔的应用前景 。 然而 , 为了使其能够更好地适应现代数据的规模和复杂性 , 还需要在算法优化和应用扩展方面进行更多的研究和探索 。 希望本文能为您在这一领域的学习和应用提供有用的信息和启示 。 < / p >
< p style = "font-weight: 700; font-size: 22px" > 一 、 简介 < / p >
< p > Apriori算法是一种用于挖掘数据集中频繁项集的算法 , 进而用于生成关联规则 。 这种算法在数据挖掘 、 机器学习 、 市场篮子分析等多个领域都有广泛的应用 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 什么是关联规则挖掘 ? < / p >
< p >
关联规则挖掘是数据挖掘中的一个重要分支 , 其目标是发现在一个数据集中变量间存在的有趣的关联或模式 。
< br / >
例子 : 假设在一个零售商的交易数据中 , 如果客户购买了啤酒 , 他们也很有可能购买薯片 。 这里的 “ 啤酒 ” 和 “ 薯片 ” 就形成了一个关联规则 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 什么是频繁项集 ? < / p >
< p >
频繁项集是在数据集中出现次数大于或等于最小支持度 ( Minimum Support Threshold ) 的项的集合 。
< br / >
例子 : 在超市购物数据中 , 如果 “ 牛奶 ” 和 “ 面包 ” 这一组合经常一起出现在同一个购物篮里 , 并且出现的次数超过了最小支持度 , 那么 { "牛奶" , "面包" } 就是一个频繁项集 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 什么是支持度与置信度 ? < / p >
< li >
支持度 ( Support ) : 是某个项集在所有交易中出现的频率 。 它用于衡量一个项集的普遍性 。
< br / >
& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 如果我们有100笔交易 , 其中有30笔交易包含了 “ 牛奶 ” , 那么 “ 牛奶 ” 的支持度就是30 % 。
< / li >
< li >
置信度 ( Confidence ) : 是在A出现的情况下 , B出现的条件概率 。
< br / >
& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 如果在包含 “ 牛奶 ” 的所有交易中 , 有70 % 的交易也包含了 “ 面包 ” , 那么从 “ 牛奶 ” 到 “ 面包 ” 的置信度就是70 % 。
< / li >
< p style = "font-size: 19px; font-weight: 600" > Apriori算法的重要性 < / p >
< p >
Apriori算法由于其简单 、 高效的特性 , 在数据挖掘中有着广泛的应用 。 它不仅能用于挖掘数据中的隐藏模式 , 还能用于诸如产品推荐 、 用户行为分析 、 网络安全等多个应用场景 。
< br / >
例子 : 在电子商务网站中 , Apriori算法可以用于分析用户购买历史数据 , 进而实现个性化推荐 , 提升销售额和用户满意度 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 应用场景 < / p >
< p > 由于其广泛的用途和灵活性 , Apriori算法在以下几个主要领域内有着广泛的应用 : < / p >
< li > 市场篮子分析 : 了解哪些产品经常被一起购买 , 以进行有效的产品布局或优惠策略 。 < / li >
< li > 医疗诊断 : 分析病人的历史数据 , 找出病症和治疗方案之间的关联 。 < / li >
< li > 网络安全 : 通过分析网络日志 , 找出异常模式 , 以预防或检测安全威胁 。 < / li >
< p > 通过这些定义和例子 , 我们可以更全面地了解Apriori算法的基本概念 、 重要性和应用范围 , 为后续的技术解析和实战应用打下坚实的基础 。 < / p >
< p style = "font-weight: 700; font-size: 22px" > 二 、 理论基础 < / p >
< p > 在深入探讨Apriori算法之前 , 理解其背后的理论基础是非常重要的 。 本节将详细介绍关联规则挖掘的基础概念 , 包括项集 、 支持度 、 置信度 、 提升度以及如何使用这些概念来挖掘有用的关联规则 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 项和项集 < / p >
< li >
项 ( Item ) : 在关联规则挖掘中 , 项通常指数据集中的一个元素 。
< br / >
& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : 在一个超市的购物篮数据中 , "牛奶" 、 "面包" 、 "啤酒" 等都是单个的项 。
< / li >
< li >
项集 ( Itemset ) : 是一个项的集合 , 可以包含一个或多个项 。
< br / >
& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; 例子 : { "牛奶" , "面包" } 和 { "啤酒" , "薯片" , "面包" } 都是项集 。
< / li >
< p style = "font-size: 19px; font-weight: 600" > 支持度 ( Support ) < / p >
< p >
支持度是一个度量 , 用于表示一个项集在整个数据集中出现的频率 。
< br / >
! file
< / p >
< p style = "font-size: 19px; font-weight: 600" > 置信度 ( Confidence ) < / p >
< p > 置信度表示在包含项集X的所有事务中 , 也包含项集Y的事务的概率 。 < / p >
< img src = "@/assets/images/f2001.png" alt = "" / >
< p style = "font-size: 19px; font-weight: 600" > 提升度 ( Lift ) < / p >
< p > 提升度用于衡量项集X和Y的出现是否相互独立 。 < / p >
< img src = "@/assets/images/f2002.png" alt = "" / >
< p style = "font-size: 19px; font-weight: 600" > Apriori原理 < / p >
< p >
Apriori原理是Apriori算法的核心 , 它基于一个简单但重要的观察 : 一个项集是频繁的 , 那么它的所有子集也必须是频繁的 。
< br / >
例子 : 如果 { "牛奶" , "面包" , "啤酒" } 是一个频繁项集 , 那么 { "牛奶" , "面包" } 、 { "牛奶" , "啤酒" } 和 { "面包" , "啤酒" } 也必须是频繁项集 。
< br / >
通过以上的概念和例子 , 我们应该对关联规则挖掘的基础理论有了更深入的了解 。 这为我们后续详解Apriori算法以及实际应用提供了坚实的基础 。
< / p >
< p style = "font-weight: 700; font-size: 22px" > 三 、 Apriori算法概述 < / p >
< p > Apriori算法是由Agrawal和Srikant于1994年提出的 , 用于高效地挖掘频繁项集和生成关联规则 。 其名字 “ Apriori ” 来源于拉丁语 , 意为 “ 从先验知识 ” 。 这很好地反映了算法的核心思想 : 利用已知的频繁项集 ( 即先验知识 ) 来更有效地找到更大的频繁项集 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 算法步骤 < / p >
< img src = "@/assets/images/f2004.png" alt = "" / >
< p >
Apriori算法的执行流程主要包含两个步骤 :
< br / >
& nbsp ; & nbsp ; 1. 频繁项集生成 ( Frequent Itemset Generation ) : 找出满足最小支持度阈值的所有频繁项集 。
< br / >
& nbsp ; & nbsp ; 2. 关联规则生成 ( Association Rule Generation ) : 从频繁项集中生成高置信度的关联规则 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 频繁项集生成 < / p >
< p >
& nbsp ; & nbsp ; 1. 扫描数据集 , 找出所有单一项的支持度 , 并筛选出满足最小支持度的项 。
< br / >
& nbsp ; & nbsp ; 2. 使用满足最小支持度的项生成新的候选项集 。
< br / >
& nbsp ; & nbsp ; 3. 计算新生成的候选项集的支持度 , 并再次筛选 。
< br / >
& nbsp ; & nbsp ; 4. 重复上述步骤 , 直到不能生成新的频繁项集 。
< br / >
例子 : 假设有一个购物交易数据集 , 其中包括5笔交易 。 第一步是计算所有单一商品 ( 如 “ 牛奶 ” , “ 面包 ” 等 ) 在这5笔交易中的出现次数 , 并筛选出那些出现次数达到最小支持度的商品 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 关联规则生成 < / p >
< p >
& nbsp ; & nbsp ; 1. 对于每一个频繁项集 , 生成所有可能的非空子集 。
< br / >
& nbsp ; & nbsp ; 2. 对每一条生成的规则 ( A \ Rightarrow B ) , 计算其置信度 。
< br / >
& nbsp ; & nbsp ; 3. 如果规则的置信度满足最小置信度要求 , 则该规则为有效关联规则 。
< / p >
< p > 例子 : 对于频繁项集 { "牛奶" , "面包" , "黄油" } , 可能的规则有 "牛奶, 面包 -> 黄油" , "牛奶, 黄油 -> 面包" 等 。 计算这些规则的置信度 , 并筛选出满足最小置信度的规则 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 优缺点 < / p >
< p style = "font-size: 19px; font-weight: 600" > 优点 < / p >
< li > 简单易懂 : Apriori算法基于直观的原理 , 并且计算过程简单 。 < / li >
< li > 可扩展性强 : 算法可以应用于大规模的数据集 。 < / li >
< p style = "font-size: 19px; font-weight: 600" > 缺点 < / p >
< li > 计算量大 : 在大数据集上 , 可能需要生成大量的候选项集 。 < / li >
< li > 多次扫描数据 : 算法需要多次扫描数据集以计算项集的支持度 , 这在数据集很大时可能是低效的 。 < / li >
< p >
例子 : 在一个包含百万级交易数据的电子商务网站中 , 使用Apriori算法可能需要消耗大量计算资源和时间 。
< br / >
通过以上的详细描述和例子 , 我们应该对Apriori算法有了全面而深入的理解 。 这为我们后续的技术解析和实战应用奠定了基础 。
< / p >
< p style = "font-weight: 700; font-size: 22px" > 四 、 实战应用 < / p >
< p >
在理解了Apriori算法的理论基础和工作原理之后 , 现在我们将进一步探讨其在实际场景中的应用 。 特别是在购物篮分析和推荐系统中 , Apriori算法被广泛应用 。
< br / >
为了更好地说明这一点 , 下面将通过Python展示如何实现Apriori算法 , 并用一个简单的购物数据集进行演示 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 购物篮分析 < / p >
< p > 购物篮分析 ( Market Basket Analysis ) 是一种在零售业非常流行的技术 , 用于发现顾客购买产品之间的关联规则 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 输入和输出 < / p >
< li > 输入 : 一组交易数据 , 每一笔交易包含多个购买的商品 。 < / li >
< li > 输出 : 满足最小支持度和最小置信度的关联规则 。 < / li >
< p style = "font-size: 19px; font-weight: 600" > Python实现代码 < / p >
< MdPreview v -model = " text " / >
< p style = "font-weight: 700; font-size: 22px" > 五 、 性能优化与扩展 < / p >
< p > Apriori算法虽然在多个领域有着广泛的应用 , 但其在大数据集上的性能表现并不尽如人意 。 这是由于它需要多次扫描数据集以及生成大量的候选项集 。 在这一节中 , 我们将讨论针对这些问题的性能优化方案和扩展方法 。 < / p >
< p style = "font-size: 19px; font-weight: 600" > 优化策略 < / p >
< p > 优化Apriori算法的主要方法包括 : < / p >
< p style = "font-size: 19px; font-weight: 600" > 减少数据扫描次数 < / p >
< p >
由于Apriori算法在每一轮都需要扫描整个数据集以计算支持度 , 因此一个直观的优化方式就是减少数据扫描的次数 。
< br / >
例子 : 通过构建一个事务 - 项倒排索引 , 你可以在单次数据集扫描后立即找到任何项集的支持度 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 采用数据压缩技术 < / p >
< p >
可以通过压缩事务数据来减少计算量 , 例如使用位向量来表示事务 。
< br / >
例子 : 若数据集中有100个商品 , 每一笔交易都可以通过一个100位的位向量来表示 。 这种方式可以显著减少数据的存储需求 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 使用Hashing技术 < / p >
< p >
通过使用哈希表来存储候选项集和它们的计数 , 可以加速支持度的计算 。
< br / >
例子 : 在生成候选项集时 , 可以使用哈希函数来将项集映射到哈希表的一个位置 , 并在该位置增加相应的计数 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 扩展方法 < / p >
< p style = "font-size: 19px; font-weight: 600" > 并行化 < / p >
< p >
Apriori算法可以通过数据或任务并行化进行扩展 , 以利用多处理器或分布式计算环境 。
< br / >
例子 : 在一个分布式系统中 , 可以将数据集划分为多个子集 , 并在各个节点上并行计算支持度和生成频繁项集 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 支持近似挖掘 < / p >
< p >
对于一些应用场景 , 完全精确的频繁项集挖掘可能不是必需的 。 在这种情况下 , 可以使用近似算法来加速计算 。
< br / >
例子 : 使用Monte Carlo方法或其他随机抽样技术 , 通过部分数据来估计整个数据集的频繁项集 。
< / p >
< p style = "font-size: 19px; font-weight: 600" > 集成其他数据挖掘算法 < / p >
< p >
Apriori算法可以与其他数据挖掘或机器学习算法结合使用 , 以解决更复杂的问题 。
< br / >
例子 : 在一个推荐系统中 , 除了使用Apriori算法找出频繁项集外 , 还可以使用聚类算法对用户进行分群 , 从而实现更个性化的推荐 。
< br / >
通过这些优化和扩展方法 , 我们不仅可以提升Apriori算法在大数据环境下的性能 , 还可以拓宽其应用范围 。 这些都为进一步的研究和应用提供了有益的方向 。
< / p >
< p style = "font-weight: 700; font-size: 22px" > 六 、 总结 < / p >
< p > 通过本文的探讨 , 我们不仅对Apriori算法有了全面且深入的了解 , 而且掌握了它在实际问题中的应用 , 特别是在购物篮分析和推荐系统方面 。 然而 , 我们也注意到了这一算法在面对大规模数据时存在的局限性 。 < / p >
< li > 支持度与置信度的平衡 : 在实际应用中 , 选择合适的支持度和置信度阈值是一门艺术 。 过低的阈值可能会导致大量不显著的关联规则 , 而过高的阈值可能会漏掉一些有用的规则 。 < / li >
< li > 实时性问题 : 在动态变化的数据集上 , 如何实现Apriori算法的实时或近实时分析也是一个值得关注的问题 。 这在电子商务等快速响应的场景中尤为重要 。 < / li >
< li > 多维 、 多层分析 : 现有的Apriori算法主要集中在单一的项集层面 , 未来可以考虑如何将其扩展到多维或多层的关联规则挖掘 。 < / li >
< li > 算法与模型的集成 : 未来的研究趋势可能会更多地集中在将关联规则挖掘与其他机器学习模型 ( 如神经网络 、 决策树等 ) 集成 , 以解决更为复杂的问题 。 < / li >
< p >
在今后的工作中 , 探究这些技术洞见的相关性和应用价值 , 以及将Apriori算法与现代计算架构 ( 如GPU 、 分布式计算等 ) 更紧密地结合 , 将是关键的研究方向 。
< br / >
总之 , Apriori算法在数据挖掘和关联分析领域有着广阔的应用前景 。 然而 , 为了使其能够更好地适应现代数据的规模和复杂性 , 还需要在算法优化和应用扩展方面进行更多的研究和探索 。 希望本文能为您在这一领域的学习和应用提供有用的信息和启示 。
< / p >
< / div >
< / template >
< / p o p - m o d e l >
< / template >
< script setup >
import * as echarts from 'echarts' ;
import * as XLSX from 'xlsx' ;
import { MdEditor , MdPreview } from 'md-editor-v3' ;
import 'md-editor-v3/lib/style.css' ;
import ecStat from 'echarts-stat' ;
import * as API from '@/api/AI.js'
import * as echarts from "echarts" ;
import * as XLSX from "XLSX" ;
import { MdEditor , MdPreview } from "md-editor-v3" ;
import "md-editor-v3/lib/style.css" ;
import * as API from "@/api/AI.js" ;
import { getUserInfo } from "@/utils/auth" ;
import { onMounted , reactive } from 'vue' ;
import { onMounted , reactive } from "vue" ;
import popModel from "@/views/components/popModal.vue" ;
const { proxy } = getCurrentInstance ( )
const dialogVisible = ref ( false )
const runResultShow = ref ( false )
const tableLabel = reactive ( [
{ prop : 'date' , label : '' } ,
] )
const tableLabel2 = reactive ( [
{ prop : 'date' , label : '' } ,
] )
const { proxy } = getCurrentInstance ( ) ;
const formData = reactive ( {
value1 : '' ,
value2 : '' ,
value3 : '' ,
value4 : '' ,
value5 : '' ,
} )
const task = ( ) => {
dialogVisible . value = false
proxy . $modal . msgSuccess ( "提交完成!" ) ;
}
const dialogVisible = ref ( false ) ;
const runResultShow = ref ( false ) ;
const tableLabel = reactive ( [ { prop : "date" , label : "" } ] ) ;
const tableLabel2 = reactive ( [ { prop : "date" , label : "" } ] ) ;
const text = ref ( ` 首先导入必要的库:
\ ` \` \` python
from itertools import chain , combinations
@ -270,22 +416,22 @@ print("关联规则:", association_rules)
关联规则 : [ ( ( '牛奶' , ) , ( '面包' , ) , 0.6666666666666666 ) , ( ( '面包' , ) , ( '牛奶' , ) , 0.6666666666666666 ) , ... ]
\ ` \` \`
通过这个实战应用 , 我们不仅学习了如何在Python中实现Apriori算法 , 还了解了它在购物篮分析中的具体应用 。 这为进一步的研究和实际应用提供了有用的指导 。 ` );
const getList = ( ) => {
API . selectionMetrics ( { userId : JSON . parse ( getUserInfo ( ) ) . userId } ) . then ( ( res ) => {
res . data . forEach ( element => {
const getList = ( ) => {
API . selectionMetrics ( { userId : JSON . parse ( getUserInfo ( ) ) . userId } ) . then ( ( res ) => {
res . data . forEach ( ( element ) => {
options . value . push ( {
value : element ,
label : element
} )
} )
} )
}
const showChart = ref ( false )
const fileList = ref ( [ ] )
const handleChange = ( info ) => {
value : element ,
label : element ,
} ) ;
} ) ;
} ) ;
} ;
const showChart = ref ( false ) ;
const fileList = ref ( [ ] ) ;
const handleChange = ( info ) => {
fileList . value . push ( info ) ;
}
const flag = ref ( false )
} ;
const flag = ref ( false ) ;
onMounted ( ( ) => {
getList ( )
@ -304,185 +450,196 @@ const optionData=()=>{
const selectedRows = ref ( [ ] ) ;
const handleSelectionChange = ( selection ) => {
selectedRows . value = selection ;
} ;
const tableData2 = ref ( [ ] ) ;
const tableData3 = ref ( [ ] ) ;
const resTable2 = ref ( ) ;
const taskZB = ( ) => {
flag . value = true ;
if ( selectedRows . value . length === 0 ) {
return proxy . $modal . msgWarning ( "请选择指标!" ) ;
}
const sendData = {
tableName : input . value ,
userId : JSON . parse ( getUserInfo ( ) ) . userId ,
fieldList : selectedRows . value . map ( ( item ) => item . text ) ,
} ;
const tableData2 = ref ( [ ] )
const tableData3 = ref ( [ ] )
const resTable2 = ref ( )
const taskZB = ( ) => {
flag . value = true
if ( selectedRows . value . length === 0 ) {
return
}
const sendData = {
tableName : input . value ,
userId : JSON . parse ( getUserInfo ( ) ) . userId ,
fieldList : selectedRows . value . map ( item => item . text )
}
API . analysisDataDisplay ( sendData ) . then ( ( res ) => {
tableLabel . length = 0
API . analysisDataDisplay ( sendData ) . then ( ( res ) => {
tableLabel . length = 0 ;
for ( const key in res . data [ 0 ] ) {
tableLabel . push ( {
label : key ,
prop : key
} )
}
tableData2 . value = res . data
flag . value = true
} )
}
const formInline = reactive ( {
user : '' ,
region : ''
} )
const input = ref ( )
const options = ref ( [ ] )
const input2 = ref ( )
const options2 = ref ( [
label : key ,
prop : key ,
} ) ;
}
tableData2 . value = res . data ;
flag . value = true ;
} ) ;
} ;
const formInline = reactive ( {
user : "" ,
region : "" ,
} ) ;
const input = ref ( ) ;
const options = ref ( [ ] ) ;
const input2 = ref ( ) ;
const options2 = ref ( [
{
value : '数据区重' ,
label : '数据去重'
}
] )
const input3 = ref ( )
const options3 = ref ( [
value : "数据区重" ,
label : "数据去重" ,
} ,
] ) ;
const input3 = ref ( ) ;
const options3 = ref ( [
{
value : '缺失值处理--剔除数据' ,
label : '缺失值处理--剔除数据'
} , {
value : '缺失值处理--均值替换' ,
label : '缺失值处理--均值替换'
value : "缺失值处理--剔除数据" ,
label : "缺失值处理--剔除数据" ,
} ,
] )
const input4 = ref ( )
const options4 = ref ( [
{
value : 'Apriori关联算法' ,
label : 'Apriori关联算法'
value : "缺失值处理--均值替换" ,
label : "缺失值处理--均值替换" ,
} ,
] )
const input5 = ref ( )
const input6 = ref ( )
const taskSubmit = ( ) => {
dialogVisible . value = true
}
const tableData = ref ( [
] )
const headerCellStyle = ( ) => {
] ) ;
const input4 = ref ( ) ;
const options4 = ref ( [
{
value : "Apriori关联算法" ,
label : "Apriori关联算法" ,
} ,
] ) ;
const input5 = ref ( ) ;
const input6 = ref ( ) ;
const taskSubmit = ( ) => {
dialogVisible . value = true ;
} ;
const tableData = ref ( [ ] ) ;
const headerCellStyle = ( ) => {
return {
backgroundColor : "#1882DE !important" , / / 设 置 表 头 背 景 颜 色
color : "#ffffff !important" ,
} ;
}
const optionData2 = ( ) => {
if ( input2 . value && input3 . value ) {
const sendData = ref ( {
mapList : tableData2 . value ,
method : input3 . value ,
userId : JSON . parse ( getUserInfo ( ) ) . userId
} )
API . dataPreprocessing ( sendData . value ) . then ( ( res ) => {
resTable2 . value = res . data
tableData2 . value = [ ]
tableData2 . value = res . data
} ;
const optionData2 = ( ) => {
if ( tableData2 . value . length === 0 ) {
input2 . value = "" ;
input3 . value = "" ;
proxy . $modal . msgWarning ( "请先选择指标!" ) ;
return ;
}
if ( input2 . value && input3 . value ) {
const sendData = ref ( {
mapList : tableData2 . value ,
method : input3 . value ,
userId : JSON . parse ( getUserInfo ( ) ) . userId ,
} ) ;
API . dataPreprocessing ( sendData . value ) . then ( ( res ) => {
resTable2 . value = res . data ;
tableData2 . value = [ ] ;
tableData2 . value = res . data ;
proxy . $modal . msgSuccess ( "预处理成功!" ) ;
} )
} ) ;
}
}
} ;
/ / 生 产 表 格
const exportTableRef = ref ( null ) ;
const uplodFlag = ref ( false )
const computation = ( ) => {
if ( input5 . value && input6 . value && input4 . value ) {
const sendData = {
confidence : parseFloat ( input5 . value ) / 100 ,
support : parseFloat ( input6 . value ) / 100 ,
userId : JSON . parse ( getUserInfo ( ) ) . userId ,
deduplicatedDataList : resTable2 . value
const uplodFlag = ref ( false ) ;
const computation = ( ) => {
if ( resTable2 . value . length === 0 || input2 . value == "" || input3 . value == "" ) {
proxy . $modal . msgWarning ( "请先计算/对数据进行预处理!" ) ;
return ;
}
API . associationRuleMining ( sendData ) . then ( ( res ) => {
uplodFlag . value = true
tableData3 . value = [ ]
tableLabel2 . length = 0
if ( input5 . value && input6 . value && input4 . value ) {
const sendData = {
confidence : parseFloat ( input5 . value ) / 100 ,
support : parseFloat ( input6 . value ) / 100 ,
userId : JSON . parse ( getUserInfo ( ) ) . userId ,
deduplicatedDataList : resTable2 . value ,
} ;
API . associationRuleMining ( sendData ) . then ( ( res ) => {
uplodFlag . value = true ;
tableData3 . value = [ ] ;
tableLabel2 . length = 0 ;
for ( const key in res . data [ 0 ] ) {
tableLabel2 . push ( {
label : key ,
prop : key
} )
label : key ,
prop : key ,
} ) ;
}
tableData3 . value = res . data
} )
tableData3 . value = res . data ;
} ) ;
} else {
proxy . $modal . msgWarning ( "请模型参数进行设置!" ) ;
}
}
const upload = ( ) => {
} ;
const upload = ( ) => {
const tableDom = exportTableRef . value ? . $el ;
if ( ! tableDom ) {
return ;
}
const wb = XLSX . utils . table _to _book ( tableDom ) ;
XLSX . writeFile ( wb , '关联规则挖掘.xlsx' ) ;
}
const startOver = ( ) => {
input . value = ''
tableData . value = [ ]
tableData2 . value = [ ]
tableData3 . value = [ ]
input2 . value = ''
input3 . value = ''
input4 . value = ''
input5 . value = ''
input6 . value = ''
tableLabel . length = 0
tableLabel2 . length = 0
uplodFlag . value = false
}
XLSX . writeFile ( wb , "关联规则挖掘.xlsx" ) ;
} ;
const startOver = ( ) => {
input . value = "" ;
tableData . value = [ ] ;
tableData2 . value = [ ] ;
tableData3 . value = [ ] ;
input2 . value = "" ;
input3 . value = "" ;
input4 . value = "" ;
input5 . value = "" ;
input6 . value = "" ;
tableLabel . length = 0 ;
tableLabel2 . length = 0 ;
uplodFlag . value = false ;
} ;
< / script >
< style lang = "scss" scoped >
. main - top {
margin : 20 px 20 px 0 ;
margin : 20 px 20 px 0 ;
margin - top : 10 px ;
height : 85 px ;
background : # 001 d40 ;
border : 1 px solid # 0452 c6 ;
padding : 5 px 20 px ;
}
. main - but {
. main - but {
margin : 5 px 20 px 0 ;
display : flex ;
. el - button : nth - child ( 1 ) {
width : 180 px ;
height : 56 px ;
background : url ( '../../../assets/images/011.png' ) ;
color : # FFFFFF ;
border - color : # FFFFFF 00;
background : url ( "../../../assets/images/011.png" ) ;
color : # ffffff ;
border - color : # ffffff 00;
}
. el - button : nth - child ( 2 ) {
width : 180 px ;
height : 56 px ;
background : url ( '../../../assets/images/022.png' ) ;
color : # FFFFFF ;
border - color : # FFFFFF 00;
background : url ( "../../../assets/images/022.png" ) ;
color : # ffffff ;
border - color : # ffffff 00;
}
}
. app - main {
/ / b a c k g r o u n d - c o l o r : # f 5 f 5 f 5 ;
min - height : 965 px ;
/ / m i n - h e i g h t : 9 6 5 p x ;
margin : 5 px 20 px 0 ;
height : 100 % ;
display : flex ;
overflow : auto ;
/ / o v e r f l o w : a u t o ;
. main - left {
/ / 水 平 居 中
flex - direction : column ;
min - height : 965 px ;
/ / m i n - h e i g h t : 9 6 5 p x ;
display : flex ;
width : 205 px ;
/ / h e i g h t : 1 0 0 % ;
height : 100 % ;
background : # 041 c49 ;
padding : 0 px 10 px ;
/ / p a d d i n g : 0 p x 1 0 p x ;
. left - top {
padding : 10 px ;
span {
@ -491,27 +648,27 @@ margin: 20px 20px 0;
color : # 3596 eb ;
}
}
. metrics - table {
. metrics - table {
. el - button {
width : 149 px ;
height : 48 px ;
background : url ( '../../../assets/images/确定.png' ) ;
color : # FFFFFF ;
border - color : # FFFFFF 00;
background : url ( "../../../assets/images/确定.png" ) ;
color : # ffffff ;
border - color : # ffffff 00;
background - size : 100 % 100 % ;
margin : 15 px ;
}
. el - input {
-- el - input - text - color : # FFFFFF ;
-- el - input - bg - color : # 002651 ;
-- el - input - border - color : # 67 B3D 6;
. el - input {
-- el - input - text - color : # ffffff ;
-- el - input - bg - color : # 002651 ;
-- el - input - border - color : # 67 b3d 6;
}
}
. startOver {
margin - left : - 10 px ;
. startOver {
/ / m a r g i n - l e f t : - 1 0 p x ;
width : 205 px ;
height : 55 px ;
background : # 00 F4FF ;
background : # 00 f4ff ;
/ / 水 平 居 中
display : flex ;
align - items : center ;
@ -519,83 +676,86 @@ margin: 20px 20px 0;
cursor : pointer ;
}
: deep ( . el - table ) {
-- el - table - row - hover - bg - color : # 002651 ! important ;
-- el - table - border - color : # 7 AC1FF ;
. el - table _ _row {
-- el - table - row - hover - bg - color : # 002651 ! important ;
-- el - table - border - color : # 7 ac1ff ;
. el - table _ _row {
background - color : # 002652 ! important ;
color : # E6E6E6 ;
color : # e6e6e6 ;
}
}
}
}
. main - right {
width : 1639 px ;
/ / h e i g h t : 1 0 0 % ;
padding : 20 px ;
/ / p a d d i n g : 2 0 p x ;
border : 1 px solid # 0452 c6 ;
: deep ( . el - table _ _header ) {
. el - table _ _cell {
background : linear - gradient ( 0 deg , # 5304 BE 0 % , # 9126 FE 100 % ) ! important ;
: deep ( . el - table _ _header ) {
. el - table _ _cell {
background : linear - gradient ( 0 deg , # 5304 be 0 % , # 9126 fe 100 % ) ! important ;
}
}
: deep ( . el - table ) {
-- el - table - row - hover - bg - color : # 002651 ! important ;
-- el - table - row - hover - bg - color : # 002651 ! important ;
-- el - table - border - color : # 002651 ;
-- el - table - bg - color : # FFFFFF 00;
. el - table _ _row {
-- el - table - bg - color : # ffffff 00;
. el - table _ _row {
background - color : # 002652 ! important ;
color : # E6E6E 6;
color : # e6e6e 6;
}
}
}
. metrics {
: deep ( . el - input ) {
. el - input _ _wrapper {
background - color : # FFFFFF 00;
background - image : url ( '../../../assets/images/下拉框.png' ) ;
. metrics {
: deep ( . el - input ) {
. el - input _ _wrapper {
background - color : # ffffff 00;
background - image : url ( "../../../assets/images/下拉框.png" ) ;
background - size : 100 % 100 % ;
}
-- el - input - text - color : # FFFFFF ;
-- el - input - border - color : # FFFFFF 00;
-- el - input - hover - border - color : # FFFFFF 00;
-- el - input - hover - border : # FFFFFF 00;
-- el - select - border - color - hover : # FFFFFF 00;
-- el - select - input - focus - border - color : # FFFFFF 00;
-- el - input - placeholder - color : # FFFFFF ;
. el - input _ _inner {
color : # FFFFFF ;
-- el - input - text - color : # ffffff ;
-- el - input - border - color : # ffffff 00;
-- el - input - hover - border - color : # ffffff 00;
-- el - input - hover - border : # ffffff 00;
-- el - select - border - color - hover : # ffffff 00;
-- el - select - input - focus - border - color : # ffffff 00;
-- el - input - placeholder - color : # ffffff ;
. el - input _ _inner {
color : # ffffff ;
}
}
}
}
. analysisResults {
. analysisResults {
. el - button {
width : 89 px ;
height : 31 px ;
background : url ( '../../../assets/images/下载.png' ) ;
color : black ;
border - color : # FFFFFF 00;
background : url ( "../../../assets/images/下载.png" ) ;
color : black ;
border - color : # ffffff 00;
/ / b a c k g r o u n d - s i z e : 1 0 0 % 1 0 0 % ;
margin : 15 px 0 px 5 px ;
}
}
: deep ( . el - form - item _ _label ) {
color : # FFFFFF ; ;
: deep ( . el - form - item _ _label ) {
color : # ffffff ;
}
. from - item {
. from - item {
padding : 20 px ;
. el - input {
-- el - input - text - color : # FFFFFF ;
-- el - input - bg - color : # 002651 ;
-- el - input - border - color : # 67 B3D 6;
. el - input {
-- el - input - text - color : # ffffff ;
-- el - input - bg - color : # 002651 ;
-- el - input - border - color : # 67 b3d 6;
}
}
. dialog - footer {
. dialog - footer {
margin - bottom : 20 px ;
}
: deep ( . el - table _ _expand - icon ) {
color : # 9126 FE ;
. el - icon {
: deep ( . el - table _ _expand - icon ) {
color : # 9126 fe ;
. el - icon {
font - size : 16 px ;
}
}
: deep ( . el - checkbox ) {
color : # ffffff ;
}
< / style >