使用cuDF的GPU加速交叉筛选
项目描述
cuxfilter
cuxfilter ( ku-cross-filter ) 是一个将网络可视化与GPU加速交叉筛选连接起来的 RAPIDS 框架。受原始版本的javascript版本 的启发,它通过 cuDF 实现了对超过1亿行的表格数据集的交互式和超快速的多维筛选。
RAIDS可视化
cuxfilter 是“RAPIDS可视化”团队的核心项目之一。我们牢记 @lmeyerov 提出的“一个滑块胜过一千个查询”的公理,希望通过易于使用的Python笔记本界面实现快速的数据探索分析。
由于网络上有很多出色的可视化库,我们的基本原则不是创建自己的可视化库,而是通过更快的加速、更大的数据集和更好的开发人员UX来增强其他库。 基本上,我们希望消除将多个图表连接到GPU后端的烦恼,让您能够更快地进行数据可视化探索。
顺便说一句,cuxfilter最佳用于交互式地处理大型(1百万+)的表格数据集。GPU很快,但访问这种加速需要一些架构开销,这对小型数据集来说并不值得。
有关更详细的要求,请参阅以下内容。
cuxfilter 架构
当前版本的cuxfilter利用jupyter笔记本和bokeh服务器来降低架构和安装的复杂性。
开源项目
cuxfilter的实现离不开这些优秀的开源项目
原始的cuxfilter和Mortgage Viz演示在哪里?
cuxfilter的原始版本(0.2),最著名的是为Mortgage Viz演示提供后端支持,已移至GTC-2018-mortgage-visualization分支
。由于它具有更复杂的后端和javascript API,我们决定在这里更多地关注以笔记簿为中心的精简版本。
使用方法
示例1
import cuxfilter
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'
from cuxfilter.sampledata import datasets_check
datasets_check('auto_accidents', base_dir=DATA_DIR)
cux_df = cuxfilter.DataFrame.from_arrow(DATA_DIR+'/auto_accidents.arrow')
cux_df.data['ST_CASE'] = cux_df.data['ST_CASE'].astype('float64')
label_map = {1: 'Sunday', 2: 'Monday', 3: 'Tuesday', 4: 'Wednesday', 5: 'Thursday', 6: 'Friday', 7: 'Saturday', 9: 'Unknown'}
cux_df.data['DAY_WEEK_STR'] = cux_df.data.DAY_WEEK.map(label_map)
gtc_demo_red_blue_palette = [ "#3182bd", "#6baed6", "#7b8ed8", "#e26798", "#ff0068" , "#323232" ]
#declare charts
chart1 = cuxfilter.charts.scatter(x='dropoff_x', y='dropoff_y', aggregate_col='DAY_WEEK', aggregate_fn='mean',
color_palette=gtc_demo_red_blue_palette, tile_provider='CartoLight', unselected_alpha=0.2,
pixel_shade_type='linear')
chart2 = cuxfilter.charts.multi_select('YEAR')
chart3 = cuxfilter.charts.bar('DAY_WEEK_STR')
chart4 = cuxfilter.charts.bar('MONTH')
#declare dashboard
d = cux_df.dashboard([chart1, chart3, chart4], sidebar=[chart2], layout=cuxfilter.layouts.feature_and_double_base, title='Auto Accident Dataset')
# run the dashboard as a webapp:
# Bokeh and Datashader based charts also have a `save` tool on the side toolbar, which can download and save the individual chart when interacting with the dashboard.
# d.show('jupyter-notebook/lab-url')
#run the dashboard within the notebook cell
d.app()
示例2
import cuxfilter
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'
from cuxfilter.sampledata import datasets_check
datasets_check('mortgage', base_dir=DATA_DIR)
cux_df = cuxfilter.DataFrame.from_arrow(DATA_DIR + '/146M_predictions_v2.arrow')
geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
chart0 = cuxfilter.charts.choropleth( x='zip', color_column='delinquency_12_prediction', color_aggregate_fn='mean',
elevation_column='current_actual_upb', elevation_factor=0.00001, elevation_aggregate_fn='sum',
geoJSONSource=geoJSONSource
)
chart2 = cuxfilter.charts.bar('delinquency_12_prediction',data_points=50)
chart3 = cuxfilter.charts.range_slider('borrower_credit_score',data_points=50)
chart1 = cuxfilter.charts.drop_down('dti')
#declare dashboard
d = cux_df.dashboard([chart0, chart2],sidebar=[chart3, chart1], layout=cuxfilter.layouts.feature_and_double_base,theme = cuxfilter.themes.dark, title='Mortgage Dashboard')
# run the dashboard within the notebook cell
# Bokeh and Datashader based charts also have a `save` tool on the side toolbar, which can download and save the individual chart when interacting with the dashboard.
# d.app()
#run the dashboard as a webapp:
# if running on a port other than localhost:8888, run d.show(jupyter-notebook-lab-url:port)
d.show()
文档
完整文档可以在RAPIDS文档页面上找到。
故障排除帮助可以在我们的故障排除页面上找到。
一般依赖项
- python
- cudf
- datashader
- cupy
- panel
- bokeh
- pyproj
- geopandas
- pyppeteer
- jupyter-server-proxy
快速开始
请参阅Docker演示仓库,选择基于您运行的NVIDIA CUDA版本的标签。这提供了一个带有示例笔记簿和数据的可运行Docker容器,展示了您如何利用cuxfilter、cuDF和其他RAPIDS库。
安装
CUDA/GPU要求
- CUDA 11.2+
- NVIDIA驱动程序450.80.02+
- Pascal架构或更好(计算能力 >=6.0)
Conda
cuxfilter可以通过conda(miniconda或完整的Anaconda发行版)从rapidsai
通道安装
对于夜间版本 cuxfilter版本 == 24.08
# for CUDA 12.0
conda install -c rapidsai-nightly -c conda-forge -c nvidia \
cuxfilter=24.08 python=3.11 cuda-version=12.0
# for CUDA 11.8
conda install -c rapidsai-nightly -c conda-forge -c nvidia \
cuxfilter=24.08 python=3.11 cuda-version=11.8
对于cuxfilter的稳定版本
# for CUDA 12.0
conda install -c rapidsai -c conda-forge -c nvidia \
cuxfilter python=3.11 cuda-version=12.0
# for CUDA 11.8
conda install -c rapidsai -c conda-forge -c nvidia \
cuxfilter python=3.11 cuda-version=11.8
注意:cuxfilter仅在Linux上受支持,并且支持Python 3.8及以后的版本。
PyPI
使用pip从PyPI安装cuxfilter
# for CUDA 12.0
pip install cuxfilter-cu12 -extra-index-url=https://pypi.nvidia.com
# for CUDA 11.8
pip install cuxfilter-cu11 -extra-index-url=https://pypi.nvidia.com
有关更多操作系统和版本信息,请参阅RAPIDS版本选择器。
从源代码构建/安装
请参阅构建说明。
故障排除
jupyter lab中的bokeh服务器
要在jupyter lab中运行bokeh服务器,请安装jupyterlab依赖项
conda install -c conda-forge jupyterlab
jupyter labextension install @pyviz/jupyterlab_pyviz
jupyter labextension install jupyterlab_bokeh
下载数据集
- 自动下载数据集
python/notebooks
中的笔记本已经有一个检查函数,该函数验证示例数据集是否已下载,如果尚未下载,则下载它。
- 手动下载
在您想要保存数据集的目录中,执行以下操作
注意:交通事故数据集从2012-2014年的坐标数据已损坏
#go the the environment where cuxfilter is installed. Skip if in a docker container
source activate test_env
#download and extract the datasets
curl https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2015-01.csv --create-dirs -o ./nyc_taxi.csv
curl https://data.rapids.ai/viz-data/146M_predictions_v2.arrow.gz --create-dirs -o ./146M_predictions_v2.arrow.gz
curl https://data.rapids.ai/viz-data/auto_accidents.arrow.gz --create-dirs -o ./auto_accidents.arrow.gz
python -c "from cuxfilter.sampledata import datasets_check; datasets_check(base_dir='./')"
指南和布局模板
目前支持的布局模板和示例代码可以在布局页面上找到。
目前支持的图表
库 | 图表类型 |
---|---|
bokeh | 条形图 |
datashader | 散点图、散点图地理、线、堆叠线、热图、图形 |
面板小部件 | 范围滑块、日期范围滑块、浮点滑块、整数滑块、下拉列表、多选、卡片、数字 |
自定义 | 查看数据帧 |
deckgl | 面状图(3D和2D) |
贡献开发者指南
cuxfilter像一个连接库,它很容易添加对新库的支持。在python/cuxfilter/charts/core
目录中包含所有核心图表类,可以继承并用于实现一些(可视相关)函数,并在cuxfilter中直接支持仪表板。
您可以在bokeh和cudatashader目录中查看实现可视化库的示例。如果您想添加图表,请通过打开特性请求问题或提交PR来告知我们。
有关更多详细信息,请查看贡献指南。
未来工作
cuxfilter开发处于早期阶段且正在继续。有关我们下一步计划的详细信息,请访问项目页面。
项目详情
cuxfilter_cu12-24.8.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 615bfcfba7e5d7504188ea17e7fbdbb2aec0a8c8d39890954d68c96fa36536e1 |
|
MD5 | 1cddc8c756ca304ddd2fb37b3d108136 |
|
BLAKE2b-256 | dee1ee919050283a342a27cf3273827d160541aa0ea285dd99ed53ab20d532f4 |