我正在尝试实施 Apriori 算法。为此,我需要从长度为 k 的项集(作为字典 L 给出)生成长度为 k+1 的项集。生成组合时必须遵循先验原则。原理说明:只有在输入 L 中存在其所有子集时,才能生成长度为 k+1 的集合。
我有一本字典,我需要从中生成项集。
我目前的尝试是这样的:
import itertools as it
def generateItemsets(Lk,k):
comb = sum(Lk.keys(), tuple())
Ck = set(it.combinations(comb, k))
return Ck
Run Code Online (Sandbox Code Playgroud)
但是该功能需要永远并在错误处中断:超出IOPub数据速率。
示例 1:
Input (dictionary): {(150,): 2, (160,): 3, (170,): 3, (180,): 3}
Output (set): {(150, 160), (150, 170), (150, 180), (160, 170), (160, 180), (170, 180)}
Run Code Online (Sandbox Code Playgroud)
更新 1
该数据集包含近 16000 笔交易。它看起来像这样:
[![数据集][1]][1]
独特的项目范围从 0-999
如您所见,该函数将被赋予一个输入 L_k,它应该输出 C_k+1。输入 L_k 是一个像 ({(301,350): 46, (966,970): 612, (310,350): 216, (548, 550): …
我正在我的机器上设置 flutter。但是,当我尝试使用安装 cocoapods 时
sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210324-1667-1wwdce5.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi... yes
checking for ffi_prep_closure_loc() in -lffi... yes
checking for ffi_prep_cif_var()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
creating extconf.h
creating Makefile
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/ext/ffi_c
make "DESTDIR=" …
Run Code Online (Sandbox Code Playgroud) 我是 Golang 新手,在尝试实现一个简单的客户端服务器模型时,我在 :=syntax 的左侧收到此错误预期标识符:
kvs.listener, err := net.Listen("tcp", ":9999")
Run Code Online (Sandbox Code Playgroud)
具体来说,错误是在kvs下。
我不知道为什么会发生这种情况。如果我用一个简单的 ln (即没有结构)替换 kvs.listener ,错误就会消失。有人可以帮我解决这个问题吗?
谢谢!