首页 > 代码库 > apriori片段代码
apriori片段代码
def data_probytime(data): timemark = ‘‘ for i in range(len(data)): lis = [] a = data[i][0] if timemark == a: continue else: timemark = a for j in range(i, len(data)): b = data[j][0] (time1, time2) = judge_time(a, b) days = timedelta(days=0) if time2 - time1 <= days: for item in data[i][1:]: if item not in lis: lis.append(item) for item2 in data[j][1:]: if item2 not in lis: lis.append(item2) else: for item3 in data[i][1:]: if item3 not in lis: lis.append(item3) yield lis
def data_probytime(data):
timemark =
‘‘
for
i
inrange(len(data)):
lis = []
a = data[i][
0]
if
timemark == a:
continue
else
:
timemark = a
for
j
inrange(i, len(data)):
b = data[j][
0]
(time1, time2) = judge_time(a, b)
days = timedelta(days=
0)
if
time2 - time1 <= days:
for
item
indata[i][
1:]:
if
item
notin
lis:
lis.append(item)
for
item2
indata[j][
1:]:
if
item2
notin
lis:
lis.append(item2)
else
:
for
item3
indata[i][
1:]:
if
item3
notin
lis:
lis.append(item3)
yield
lis
1 <?xml version="1.0" encoding="utf-8"?> 2 <KNOWNLADGESYSTEM> name="设备风险知识系统"> 3 <FKU name=‘设备风险知识系统‘hastarget=‘false‘> 4 <FKU name=‘隐患类别‘hastarget=‘true‘> 5 <FKU name=‘线路‘hastarget=‘truee‘> 6 <TARGETRES risk_factor="道岔"></TARGETRES> 7 </FKU> 8 <TARGETRES risk_factor="不良"></TARGETRES> 9 <TARGETRES risk_factor="报警"></TARGETRES> 10 <TARGETRES risk_factor="折断"></TARGETRES> 11 </FKU> 12 </FKU> 13 ... 14 15 <SKULIST> 16 <SKU name=‘隐患类别‘ resulttype unit=‘设备‘> 17 <VARLIST> 18 <VAR name=‘隐患定位‘type=‘SKU‘/> 19 <VAR name=‘隐患描述‘type=‘SKU‘> 20 <VALUE>道岔</<VALUE> 21 <VALUE>螺栓</<VALUE> 22 </VAR> 23 </VARLIST> 24 <BODY> 25 <RVALUE>发生概率:”螺栓”问题*0.9</RVALUE> 26 <SENTENCE type=‘rule‘> 27 <IF> 28 <PREM varname=‘道岔‘ rel="=="opval="松动"/> 29 </IF> 30 <THEN> 31 <SENTENCE type=‘exp‘> 32 <LVALUE>事故发生</LVALUE> 33 <RVALUE>p*0.9</RVALUE> 34 </SENTENCE> 35 </THEN> 36 </SENTENCE> 37 </BODY> 38 </SKU> 39 </SKULIST> 40 </KNOWNLADGESYSTEM>
apriori片段代码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。