python3 Apriori的GUI实现
Apriori简介
!未能实现txt文件的导入
代码如下:
# -*- coding: utf-8 -*-
import numpy as np
import tkinter
from tkinter import scrolledtext
def loadDataSet():
dataset = [['鱼', '熟食', '水果'], ['水果', '净菜', '鱼'], ['家禽', '水果', '油', '调味料', '净菜'], ['家禽', '熟食', '油', '净菜'],
['家禽', '水果', '蔬菜', '调味料'], ['熟食', '鱼', '蔬菜', '油'], ['熟食', '蔬菜', '调味料'], ['油', '蔬菜', '调味料', '净菜'],
['蔬菜', '水果', '净菜', '鱼'], ['水果', '调味料', '油', '鱼', '净菜'], ['家禽', '净菜', '油', '调味料', '水果'],
['熟食', '水果', '蔬菜']]
return dataset
def createC1(dataSet):
C1 = []
for transaction in dataSet:
for item in transaction:
if not [item] in C1:
C1.append([item])
C1.sort()
# 映射为frozenset唯一性的,可使用其构造字典
return list(map(frozenset, C1))
# 从候选K项集到频繁K项集(支持度计算)
def scanD