跳过内容

对大型数据集进行概要分析

默认情况下,ydata-profiling 会全面总结输入数据集,以便为数据分析提供最多的见解。对于小型数据集,这些计算可以*准*实时执行。对于大型数据集,可能需要预先决定要进行哪些计算。计算是否能扩展到大型数据集不仅取决于数据集的精确大小,还取决于其复杂性以及是否提供了快速计算方法。如果概要分析的计算时间成为瓶颈,ydata-profiling 提供了几种替代方案来解决此问题。

在全托管系统中进行扩展

是否正在寻找一个能够为大型数据集进行概要分析扩展的全托管系统?注册 Fabric 社区,进行分布式数据概要分析。

Pyspark

Spark

最小模式

此模式在 v4.0.0 版本中引入

ydata-profiling 现在支持 Spark Dataframes 概要分析。您可以在此处找到集成的示例。

支持的功能: - 单变量分析 - 数据集头部和尾部样本 - 相关矩阵:Pearson 和 Spearman

即将推出 - 缺失值分析 - 交互 - 改进的直方图计算

请密切关注 GitHub 页面,以了解 Pyspark Dataframes 支持的实施更新。

最小模式

最小模式

此模式在 v2.4.0 版本中引入

ydata-profiling 包含一个最小配置文件,默认情况下会关闭最昂贵的计算。对于大型数据集,这是推荐的起点。

profile = ProfileReport(large_dataset, minimal=True)
profile.to_file("output.html")

此配置文件位于此处:config_minimal.yaml。有关设置和配置的更多详细信息,请参阅 ../advanced_usage/available_settings

采样数据集

处理超大型数据集的另一种方法是使用其一部分来生成概要分析报告。许多用户反映,这是一种在保持代表性的同时缩减计算时间的良好方法。

采样大型数据集
1
2
3
4
5
# Sample 10.000 rows
sample = large_dataset.sample(10000)

profile = ProfileReport(sample, minimal=True)
profile.to_file("output.html")

报告的读者可能想知道,概要分析是使用数据样本生成的。这可以通过向报告添加描述来完成(详情请参阅 metadata)。

对数据集进行 5% 的采样
1
2
3
4
5
description = "Disclaimer: this profiling report was generated using a sample of 5% of the original dataset."
sample = large_dataset.sample(frac=0.05)

profile = sample.profile_report(dataset={"description": description}, minimal=True)
profile.to_file("output.html")

禁用昂贵计算

为了减轻超大型数据集的计算负担,但仍保留可能来自其中的一些感兴趣的信息,某些计算可以仅针对特定列进行筛选。特别是,可以将目标列表提供给“交互”,这样只计算与这些特定变量的交互。

禁用昂贵计算
from ydata_profiling import ProfileReport
import pandas as pd

# Reading the data
data = pd.read_csv(
    "https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv"
)

# Creating the profile without specifying the data source, to allow editing the configuration
profile = ProfileReport()
profile.config.interactions.targets = ["Name", "Sex", "Age"]

# Assigning a DataFrame and exporting to a file, triggering computation
profile.df = data
profile.to_file("report.html")

控制此项的设置 ìnteractions.targets 可以通过多种接口(配置文件或环境变量)进行更改。详情请参阅 ../advanced_usage/changing_settings

并发

ydata-profiling 是一个正在积极开发中的项目。其中一个非常需要的功能是添加一个可扩展的后端,例如 ModinDask

请密切关注 GitHub 页面,以了解并发和高度可扩展后端的实施更新。特别是,Spark 后端的开发目前正在进行中