【发布时间】:2020-06-08 19:00:21
【问题描述】:
我正在尝试使用 apyori 模块运行关联规则。 我的“项目”是各种手术(行 = 患者病例),正如您在下面的数据框示例中看到的那样。 Apyori 未能捕捉到正确的标签,它似乎正在用字母切割标签。我过去从未见过这样的行为。除非我遗漏了什么,否则我的数据集已正确格式化以供 apyori 使用。任何时候进行的手术不超过 2 次。
这是我得到的一个例子:
RelationRecord(items=frozenset({'v', '_'}), support=0.10309278350515463, ordered_statistics=[OrderedStatistic(items_base=frozenset(), items_add=frozenset({'v', '_'}), confidence=0.10309278350515463, lift=1.0), OrderedStatistic(items_base=frozenset({'_'}), items_add=frozenset({'v'}), confidence=0.10638297872340426, lift=1.0319148936170213), OrderedStatistic(items_base=frozenset({'v'}), items_add=frozenset({'_'}), confidence=1.0, lift=1.0319148936170213)]) Support: 0.10309278350515463 Confidence: frozenset({'v', '_'}) Lift:
0.10309278350515463
frozenset 坏了... 这是我的输入 dataframe.head():
sm-to-sm_bowel_anastom small_bowel_incision_nec sm_bowel_exteriorization \
0 0 0 0
1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 0
incisional_hernia_repair colonoscopy anal_anastomosis \
0 0 0 0
1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 0
c.a.t._scan_of_abdomen open_sigmoidectomy_nec small_bowel_suture_nec \
0 0 0 0
1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 0
lap_pt_ex_lrg_intest_nec ... abdperneal_res_rectm_nos \
0 0 ... 0
1 0 ... 0
2 0 ... 0
3 0 ... 0
4 0 ... 0
5 0 ... 0
6 0 ... 0
7 0 ... 0
8 0 ... 0
9 0 ... 0
ureteral_catheterization cv_cath_plcmt_w_guidance \
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 0 0
9 0 0
clos_large_bowel_biopsy lap_right_hemicolectomy continent_ileostomy \
0 0 0 0
1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 1
insert_endotracheal_tube mult_seg_sm_bowel_excis \
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 0 0
9 0 0
small-to-large_bowel_nec opn_lft_hemicolectmy_nec
0 1 1
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 1 0
7 0 0
8 0 0
9 0 0
[10 rows x 97 columns]
我这样运行规则:
from apyori import apriori as ap
rulez = ap(ohe_df, min_support = 0.1, min_length = 2,use_colnames=True)
我只有 2 次手术同时进行,所以我不希望有 >2 项的组合。
frozenset 发生了什么?
谢谢
【问题讨论】: