Frozenset不会在Spyder Variable Explorer中显示其内容 [英] Frozenset doesn't display its contents in Spyder Variable Explorer

查看:1010
本文介绍了Frozenset不会在Spyder Variable Explorer中显示其内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Spyder中打开规则时,对市场购物篮优化数据集应用了先验算法后,没有显示frozenset({'light cream', 'chicken'})而是显示了frozenset object of builtins module

After applying apriori algorithm to Market Basket Optimization data set when I open the rule in Spyder, instead of showing frozenset({'light cream', 'chicken'}) shows frozenset object of builtins module

我的代码:

import pandas as pd

# Read dataset
dataset = pd.read_csv('Market_Basket_Optimisation.csv', header = None)
transactions = []
for i in range(0, 7501):
transactions.append([str(dataset.values[i,j]) for j in range(0, 20)])

# Train model
from apyori import apriori
rules = apriori(transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)

# To get the output 
results = list(rules)

数据集

图片供参考:

第一种情况

第二种情况

推荐答案

(这里是[Spyder维护人员])简短答案:此问题的原因很简单:我们不知道在我们的变量浏览器中不支持frozenset.这就是为什么不显示它们的原因,除非您关闭名为Exclude unsupported data types的选项,然后将它们显示为通用对象.

(Spyder maintainer here) Short answer: The reason for this problem is very simple: we don't support frozenset's in our Variable Explorer. That's why they are not displayed unless you turn off the option called Exclude unsupported data types, and after that they are shown as generic objects.

长答案:我们不能简单地使用对象的repr在变量浏览器中显示该对象.这是因为,如果您的对象非常复杂(即,元素太多或由具有长repr的对象组成),则Spyder控制台将挂起,尝试计算其repr.我们了解了经过多年支持复杂的科学工作流程后的艰辛努力.

Long answer: We can't simply use the repr of an object to display that in the Variable Explorer. That's because if your object is quite complex (i.e. it has too many elements or it's composed of objects with long repr's), the Spyder console hangs trying to compute its repr. We learned that the hard way after many years of supporting complex scientific workflows.

因此,对于每个类型对象,我们需要决定如何在变量资源管理器中显示它.例如,我们显示数据框的列名称以及列表和字典的前十个元素.我们已经有一个小型库来执行此操作,但是每当人们希望看到新类型的对象时,我们都需要对其进行扩展.

So for each type object we need to decide how it's going to be displayed in the Variable Explorer. For example, we show Column names for Dataframes and the ten first elements of lists and dicts. We already have a small library to do that, but we need to expand it every time people wants to see new type objects.

注意:我们计划通过Spyder 4(将于2019年发布)中的插件扩展该过程.

Note: We plan to do that process extendible by plugins in Spyder 4 (to be released in 2019).

这篇关于Frozenset不会在Spyder Variable Explorer中显示其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆