资源简介
Java语言实现的Apriori算法,数据可由excel数据表格提供,eclipse导入即可运行
代码片段和文件信息
package asocciationRule.apriori;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class AprioriAlgorithm {
private Map> txDatabase; // 事务数据库
private Float minSup; // 最小支持度
private Float minConf; // 最小置信度
private Integer txDatabaseCount; // 事务数据库中的事务数
private Map>> freqItemSet; // 频繁项集集合
private Map Set>> assiciationRules; // 频繁关联规则集合
public AprioriAlgorithm(Map> txDatabase Float minSup
Float minConf) {
this.txDatabase = txDatabase;
this.minSup = minSup;
this.minConf = minConf;
this.txDatabaseCount = this.txDatabase.size();
freqItemSet = new TreeMap>>();
assiciationRules = new HashMap Set>>();
}
public Map Float> getFreq1ItemSet() {//zzx 生成一阶频繁项集
Map Float> freq1ItemSetMap = new HashMap Float>();
Map Integer> candFreq1ItemSet = this.getCandFreq1ItemSet();
Iterator Integer>> it = candFreq1ItemSet
.entrySet().iterator();
while (it.hasNext()) {
Map.Entry Integer> entry = it.next();
// 计算支持度
Float supported = new Float(entry.getValue().toString())
/ new Float(txDatabaseCount);
if (supported >= minSup) {
freq1ItemSetMap.put(entry.getKey() supported);
}
}
return freq1ItemSetMap;
}
public Map Integer> getCandFreq1ItemSet() {
Map Integer> candFreq1ItemSetMap = new HashMap Integer>();
Iterator>> it = txDatabase.entrySet()
.iterator();
// 统计支持数,生成候选频繁1-项集
while (it.hasNext()) {
Map.Entry> entry = it.next();
Set itemSet = entry.getValue();
for (String item : itemSet) {
Set key = new HashSet();
key.add(item.trim());
if (!candFreq1ItemSetMap.containsKey(key)) {
Integer value = 1;
candFreq1ItemSetMap.put(key value);
} else {
Integer value = 1 + candFreq1ItemSetMap.get(key);
candFreq1ItemSetMap.put(key value);
}
}
}
return candFreq1ItemSetMap;
}
/*
* zzx生成m+1阶候选项集
*/
public Set> aprioriGen(int m Set> freqMItemSet) {
Set> candFreqKItemSet = new HashSet>();
Iterator> it = freqMItemSet.iterator();
Set originalItemSet = null;
while (it.hasNext()) {
originalItemSet = it.next();
Iterator> itr = this.getIterator(originalItemSetfreqMItemSet);
while (itr.hasNext()) {
Set identicalSet = new HashSet(); // 两个项集相同元素的集合(集合的交运算)
identicalSet.addAll(originalItemSet);
Set set = itr.next();
identicalSet.retainAll(set); // identicalSet中剩下的元素是identicalSet与set集合中相同的元素
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9780 2016-03-23 20:58 apriori\AprioriAlgorithm.java
文件 2248 2014-09-15 15:15 apriori\ProperSubsetCombination.java
文件 2242 2014-09-15 15:15 apriori\TestAprioriAlgorithm.java
目录 0 2018-10-27 21:30 apriori\
- 上一篇:计算机专业毕业设计-外文翻译
- 下一篇:java文件资源管理器
相关资源
- java文件资源管理器
- Java TCP/IP Socket编程·源代码
- Java2Pas(JAVA转Delphi工具)
- JS 生成MD5值和JAVA生成MD5值自己测试过
- 北大青鸟ACCP6.0S2宠物商店项目java官方
- mysql-connector-java-5.1.39.jar资源
- 数据库实验8 java连接数据库(JDBC代码
- 操作系统os页面置换算法java实现Cloc
- java小区物业管理系统
- JavaWeb开发实战宝典源码(全)
- 数据库课程设计-报刊订阅系统-Java语
- 网吧自动计费管理系统
- JSP JAVA网吧计费管理系统 源代码
- jsp飞机票订票系统
- Java写的UML活动图
- 局域网聊天系统 含 数据库
- 航空票务管理系统 含 数据库
- 小区物业管理系统 含 数据库
- 学生信息管理系统 实现学生的添加删
- java 图形界面小时钟
- 基于java的web浏览器
- JSP+Sevlet+javabean实现网站商品分类
- JAVA-WEB单点登录
- 基于Java的网络相册的开题报告
- JAVA连接SQLServer2000的jar包
- 百度贴吧java爬虫
- java做的打电话系统
- 哈夫曼编码实现压缩解压缩java
- java获取话筒音频并保存源代码
- JAVA魔板游戏 课程设计报告
评论
共有 条评论