数据挖掘Apriori算法C++实现(3)
时间:2025-04-20
时间:2025-04-20
- --
{
public:
void init(string fileName); //初始化,输入数据源,得到原始数据集、频繁1项集
void apri_gen();//连接频繁k项集、并且直接剪枝,得到频繁k+1项集,加入到频繁项集集合frequentvec中float calculateSup(vector<int> judge_item); //求候选项的支持度
vector<int> mergeItem(vector<int> vect1,vector<int> vect2,int round); //判断两个项是否可以合并成一个新的项集做为新的候选项,能则合并,不能的返回空容器
void showItem();//输出频繁项集
private:
vector<set<int>> dataNumVec;//原始数据集转换出来的、数据项用代号来表示的数据
map<string,int> reflection; //原始数据中各个不同的元素的代号映射,数据元素从1开始编号
int trancount; //原始数据项数量
vector<vector<pair<vector<int>,float>>> frequentvec; //频繁项集集合,储存各项以及其支持度
double minsup; //设置最小支持度和最小置信度
};
运行结果:
效果对比:
改进后14.496;14.549;14.577
改进前20.165;20.463;20.383
效率提升28.1%
- . -word资料-
上一篇:并列句详解与复习含中考真题解析
下一篇:私人定制计划书