【问题标题】:Python bcubed clustering metric- TypeError: unsupported operand type(s) for &: 'dict' and 'dict'Python bcubed clustering metric-TypeError:&:'dict'和'dict'不支持的操作数类型
【发布时间】:2021-05-28 11:30:09
【问题描述】:
我想用 bcubed 指标评估我的聚类算法
dict_ac = labels_actual.to_dict()
dict_br = pd.DataFrame(labels_br).to_dict()
precision = bcubed.precision(dict_br, dict_ac)
但是有错误
TypeError: unsupported operand type(s) for &: 'dict' and 'dict'
【问题讨论】:
标签:
python
cluster-analysis
metrics
【解决方案1】:
你能分享你的整个代码吗?错误似乎不在这三行中。
另外,您真的确定要使用“&”运算符(根据您使用的错误)这是一个 bitwise 运算符,这意味着它已被使用相互比较位。
您的意思是使用“and”运算符吗?
例子:
# example of "&" operator
byte1 = 0b00001111
byte2 = 0b00100100
byte3 = byte2 & byte1
# byte3 will be 00000100
# example of the and operator:
if 1=1 and 2=2:
# do something
# example of using + (adding two strings)
string1 = "Bananas are "
string2 = "yellow!"
string3 = string1 + string2
# string3 will be "Bananas are yellow!"