2

为我的 DataFrame 的子集运行配置文件报告时出现以下错误。

ValueError: Value '6.180529706513958' should be a ratio between 1 and 0.

这有效:

profile = ProfileReport(
    df, title="Profile Report of the January Conversion Dataset"
)
profile.to_file(Path("../../../products/jan_cvr_report.html"))

profile0 = ProfileReport(
    df[df['conversion']==0], title="Profile Report of the January Conversion==0 Dataset"
)
profile0.to_file(Path("../../../products/jan_cvr0_report.html"))

这不会:

profile1 = ProfileReport(
    df[df['conversion']==1], title="Profile Report of the January Conversion==1 Dataset"
)
profile1.to_file(Path("../../../products/jan_cvr1_report.html"))
4

1 回答 1

1

我发现了一个已关闭的 Github 问题,建议我开始工作。我的详细信息和堆栈跟踪就在那里。

解决方案:remove_unused_categories

df1 = df[df['conversion']==1].copy(deep=True)
df1.user_id.cat.remove_unused_categories(inplace=True)

运行上述内容后,配置文件报告工作正常。这些类非常不平衡,因此当子集到conversion=1大多数user_ids不使用的地方时。这也可以通过不将其user_id作为一个类别来解决。但是,这可能是其他类别的问题,所以我还是要分享。

于 2020-05-19T16:54:31.343 回答