We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
源代码:
def generateTransitionMatrix(samples): pairSamples = samples.flatMap(lambda x: generate_pair(x)) pairCountMap = pairSamples.countByValue() pairTotalCount = 0 transitionCountMatrix = defaultdict(dict) itemCountMap = defaultdict(int) for key, cnt in pairCountMap.items(): key1, key2 = key # 此处是否应该改为 += cnt transitionCountMatrix[key1][key2] = cnt itemCountMap[key1] += cnt pairTotalCount += cnt ......
修改:
for key, cnt in pairCountMap.items(): key1, key2 = key if key1 not in transitionCountMatrix or key2 not in transitionCountMatrix[key1]: transitionCountMatrix[key1][key2] = cnt else: transitionCountMatrix[key1][key2] += cnt itemCountMap[key1] += cnt pairTotalCount += cnt
The text was updated successfully, but these errors were encountered:
No branches or pull requests
源代码:
修改:
The text was updated successfully, but these errors were encountered: