Blackhole数据分析
Blackhole数据分析概述
当前全球的数据每年都在快速增长,面对大数据时代,我们创建了Blackhole(一个高性能异构大数据分析和机器学习加速库),利用CPU和GPU来加速计算。Blackhole基于Python,具有类似pandas和scikit-learn的接口,基于Apache Arrow内存数据格式构建,并且可以从单节点扩展到多GPU多节点。Blackhole可以轻松地集成到全球最受欢迎的基于Python的数据科学工作流中。Blackhole囊括了从数据预处理到机器学习再到深度学习整个流程,实现了端到端数据科学全流程加速,并且通过Arrow,Spark用户可以轻松地将数据移至Blackhole平台进行加速。当前,我们支持部分CPU和GPU兼容的接口。
要使用Blackhole的数据分析模块,只需要替换pandas import: # import pandas as pd import blackhole.gibbons as pd 只需要更改一行代码就能加速pandas工作流 Blackhole提供一种便捷的方法来加速pandas的notebook、scripts, 和libraries。不同于其他分布式的数据分析Dataframe库,Blackhole和与现有pandas无缝兼容。即使使用DataFrame构造函数也是相同的。 import blackhole.gibbons as pd import numpy as np frame_data = np.random.randint(0, 100, size=(210, 28)) df = pd.DataFrame(frame_data) 要使用Blackhole,不需要使用分布式,不需要指定如何分发数据,就能得到高性能和大数据的处理能力。事实上,可以继续使用以前的pandas notebook,同时体验Blackhole的速度相当快,即使是在一台机器上。一旦更改了导入语句,就可以像使用pandas使用Blackhole了.
Blackhole数据分析主要特性
- 易用的API接口: Blackhole提供了非常类似Pandas的API。
- 高性能数据分析: Blackhole利用单机CPU和GPU进行并行及混合计算,享有单机使用的便利性和媲美分布式计算的性能。
- 超大数据分析: Blackhole可以将数据以与内存相同的格式存储在磁盘上,从而将磁盘上的数据通过memory map内存映射的方式按需加载,实现out of memory超越内存限制的数据处理。
- 高效数据存储 Blackhole采用列式存储的方式,一方面在存储上节约空间、减少IO,另一方面依靠列式数据结构进行计算操作上的优化。
- 混合计算 Blackhole支持混合计算。混合计算将部分子任务调度到GPU上训练、其余在CPU训练,CPU和GPU训练的模型最终合并。
Blackhole用户指南
Blackhole数据分析提供了非常类似Pandas的API,目前已经对齐了90%以上的方法和属性,详细使用手册可以参考Pandas的文档,用法几乎是一致的,只需要替换pandas import。
Blackhole API参考文档
针对使用过程中,Blackhole和Pandas的部分方法和属性存在的差异,以及API参考情况,下面根据DataFrame,Series,IO,模块方法四部分分别详细列出了其具体的参考文档和当前实现的差异。
- DataFrame支持的APIs
- Series支持的APIs
- IO相关的APIs
-
DataFrame支持的APIs
下表列出了已实现和未实现的方法,并指出了当前和pandas的方法存在的差异。如果您需要一个列为未实现的操作,可以向我们反馈。 下表的结构如下:第一列包含方法名,第二列是对应的文档链接,第三列是一个标志,表示是否存在左列中方法的Blackhole实现。`Y`代表是完全支持,`N`代表不支持,`P`代表部分支持(意思是一些参数可能还不受支持),`D`表示代理到pandas实现DataFrame 方法 pandas文档链接实现形式? (Y/N/P/D)当前实现和pandas的存在的差异T
T Y abs
abs Y add
add Y add_prefix
add_prefix Y add_suffix
add_suffix Y agg
/aggregate
agg / aggregate Y all
all Y any
any Y append
append Y apply
apply P 支持大部分自定义函数 部分复杂函数如:lambda x : x.corr(),目前暂时不支持 applymap
applymap Y asfreq
asfreq D asof
asof D assign
assign N astype
astype Y 目前不支持category类型 at
at Y at_time
at_time Y axes
axes Y between_time
between_time D bfill
bfill D blocks
blocks D bool
bool Y boxplot
boxplot D clip
clip D clip_lower
clip_lower D clip_upper
clip_upper D combine
combine D combine_first
combine_first D copy
copy Y corr
corr P 目前只支持默认的pearson计算方法,且不支持min_periods参数 corrwith
corrwith D count
count Y cov
cov P 不支持min_periods参数 cummax
cummax D cummin
cummin D cumprod
cumprod D cumsum
cumsum D describe
describe Y diff
diff Y div
div Y See add
divide
divide Y See add
dot
dot Y drop
drop Y droplevel
droplevel Y drop_duplicates
drop_duplicates D dropna
dropna Y dtypes
dtypes Y duplicated
duplicated Y empty
empty Y eq
eq Y See add
equals
equals Y eval
eval Y ewm
ewm D expanding
expanding D explode
explode D ffill
ffill D fillna
fillna Y filter
filter Y first
first D first_valid_index
first_valid_index D floordiv
floordiv Y See add
from_dict
from_dict Y from_items
from_items Y from_records
from_records Y ge
ge Y See add
get
get Y groupby
groupby Y 目前还不支持所有的操作,支持大部分reduction类的操作 gt
gt Y See add
head
head Y hist
hist D iat
iat Y idxmax
idxmax Y idxmin
idxmin Y iloc
iloc Y infer_objects
infer_objects D info
info Y insert
insert Y interpolate
interpolate D isin
isin D isna
isna Y isnull
isnull Y items
items Y iteritems
iteritems Y iterrows
iterrows Y itertuples
itertuples Y join
join Y keys
keys Y kurt
kurt Y kurtosis
kurtosis Y last
last D last_valid_index
last_valid_index D le
le Y See add
loc
loc Y lookup
lookup D lt
lt Y See add
mad
mad Y mask
mask D max
max Y mean
mean Y median
median Y melt
melt D memory_usage
memory_usage Y merge
merge P 目前不支持指定基于不同frame的不同名的列进行join min
min Y mod
mod Y mode
mode Y mul
mul Y See add
multiply
multiply Y See add
ndim
ndim Y ne
ne Y See add
nlargest
nlargest Y notna
notna Y notnull
notnull Y nsmallest
nsmallest Y nunique
nunique Y pct_change
pct_change D pipe
pipe D pivot
pivot D pivot_table
pivot_table D plot
plot D pop
pop Y pow
pow Y See add
prod
prod Y product
product Y quantile
quantile Y query
query D radd
radd Y See add
rank
rank D rdiv
rdiv Y See add
reindex
reindex D reindex_like
reindex_like D rename
rename Y rename_axis
rename_axis Y reorder_levels
reorder_levels D replace
replace Y resample
resample Y reset_index
reset_index Y rfloordiv
rfloordiv Y See add
rmod
rmod Y See add
rmul
rmul Y See add
rolling
rolling D round
round Y rpow
rpow Y See add
rsub
rsub Y See add
rtruediv
rtruediv Y See add
sample
sample Y select_dtypes
select_dtypes Y sem
sem D set_axis
set_axis Y set_index
set_index Y shape
shape Y shift
shift D size
size Y skew
skew Y slice_shift
slice_shift D sort_index
sort_index Y sort_values
sort_values Y 目前只支持na_position为first sparse
sparse N squeeze
squeeze D stack
stack D std
std Y style
style D sub
sub Y See add
subtract
subtract Y See add
sum
sum Y swapaxes
swapaxes Y swaplevel
swaplevel Y tail
tail Y take
take Y to_clipboard
to_clipboard D to_csv
to_csv D to_dense
to_dense D to_dict
to_dict D to_excel
to_excel D to_feather
to_feather D to_gbq
to_gbq D to_hdf
to_hdf D to_html
to_html D to_json
to_json D to_latex
to_latex D to_msgpack
to_msgpack D to_parquet
to_parquet D to_period
to_period D to_pickle
to_pickle D to_records
to_records D to_sparse
to_sparse D to_sql
to_sql Y to_stata
to_stata D to_string
to_string D to_timestamp
to_timestamp D to_xarray
to_xarray D transform
transform Y transpose
transpose Y truediv
truediv Y See add
truncate
truncate Y tshift
tshift D tz_convert
tz_convert D tz_localize
tz_localize D unstack
unstack D update
update D values
values Y var
var Y where
where D Series支持的APIs
下表列出了已实现和未实现的方法,并指出了当前和pandas的方法存在的差异。如果您需要一个列为未实现的操作,可以向我们反馈。 下表的结构如下:第一列包含方法名,第二列是一个标志,表示是否存在左列中方法的Blackhole实现。`Y`代表是完全支持,`N`代表不支持,`P`代表部分支持(意思是一些参数可能还不受支持),`D`表示代理到pandas实现Series 方法 实现形式? (Y/N/P/D)abs
Y add
Y add_prefix
Y add_suffix
Y agg
Y aggregate
Y align
D all
Y any
Y append
Y apply
Y argmax
Y argmin
Y argsort
D array
D asfreq
D asobject
D asof
Y astype
Y at
Y at_time
D axes
Y base
D between
D between_time
D bfill
D blocks
D bool
Y cat
D clip
D clip_lower
D clip_upper
D combine
D combine_first
D compress
D copy
Y corr
Y count
Y cov
Y cummax
D cummin
D cumprod
D cumsum
D data
D describe
Y diff
Y div
Y divide
Y divmod
Y dot
Y drop
Y drop_duplicates
Y droplevel
Y dropna
Y dt
Y dtype
Y dtypes
Y duplicated
Y empty
Y eq
Y equals
Y ewm
D expanding
D explode
D factorize
D ffill
Y fillna
Y filter
Y first
D first_valid_index
D flags
D floordiv
Y from_array
D ftype
Y ftypes
Y ge
Y get
Y get_dtype_counts
Y get_value
D get_values
D groupby
D gt
Y hasnans
Y head
Y hist
D iat
Y idxmax
Y idxmin
Y iloc
Y imag
D index
Y infer_objects
D interpolate
D is_monotonic
Y is_monotonic_decreasing
Y is_monotonic_increasing
Y is_unique
Y isin
Y isna
Y isnull
Y item
Y items
Y itemsize
D iteritems
Y keys
Y kurt
Y kurtosis
Y last
D last_valid_index
D le
Y loc
Y lt
Y mad
Y map
Y mask
D max
Y mean
Y median
Y memory_usage
Y min
Y mod
Y mode
Y mul
Y multiply
Y name
Y nbytes
D ndim
Y ne
Y nlargest
Y nonzero
Y notna
Y notnull
Y nsmallest
Y nunique
Y pct_change
D pipe
Y plot
D pop
Y pow
Y prod
Y product
D ptp
D put
D quantile
Y radd
Y rank
Y ravel
Y rdiv
Y rdivmod
Y real
D reindex
Y reindex_like
Y rename
Y rename_axis
Y reorder_levels
D repeat
Y replace
Y resample
Y reset_index
Y rfloordiv
Y rmod
Y rmul
Y rolling
Y round
Y rpow
Y rsub
Y rtruediv
Y sample
Y searchsorted
Y sem
D set_axis
Y set_value
D shape
Y shift
D size
Y skew
Y slice_shift
D sort_index
Y sort_values
Y sparse
Y squeeze
Y std
Y str
Y strides
D sub
Y subtract
Y sum
Y swapaxes
Y swaplevel
Y tail
Y take
Y to_clipboard
D to_csv
D to_dense
D to_dict
D to_excel
D to_frame
Y to_hdf
D to_json
D to_latex
D to_list
D to_msgpack
D to_numpy
D to_period
D to_pickle
D to_sparse
D to_sql
Y to_string
D to_timestamp
D to_xarray
D tolist
D transform
Y transpose
Y truediv
Y truncate
Y tshift
Y tz_convert
Y tz_localize
Y unique
Y unstack
Y update
Y valid
D value_counts
Y values
Y var
Y view
D where
D IO相关的APIs
Blackhole的`read_csv`方法基于多线程并行加速,结合`out of core`支持大数据量读取。其他的IO方法大部分基于代理实现,意味着其利用单线程进行串行读取,如果遇到上述方法存在性能问题,可以反馈给我们。 下表的结构如下:第一列包含方法名,第二列是一个标志,表示是否存在左列中方法的Blackhole实现。\`Y\`代表是完全支持,\`N\`代表不支持,\`P\`代表部分支持(意思是一些参数可能还不受支持),\`D\`表示代理到pandas实现IO 方法 实现类型? (Y/N/P/D) 实现差异 read_csv P mangle_dupe_cols只能为True, na values目前不支持dict类型, parse_date目前不支持list类型 read_table D read_parquet D read_json D read_html D read_clipboard D read_excel D read_pickle N read_sql D 模块下的APIs
当你 `import blackhole.gibbons as pd` 时,以下方法包含在模块空间下,`pd.`, e.g. `pd.concat`。当有对当前未实现的需求时,可以反馈给我们。 下表的结构如下:第一列包含方法名,第二列是一个标志,表示是否存在左列中方法的Blackhole实现。\`Y\`代表是完全支持,\`N\`代表不支持,\`P\`代表部分支持(意思是一些参数可能还不受支持),\`D\`表示代理到pandas实现 Utility 方法 实现类型? (Y/N/P/D)实现差异pd.concat P 目前支持axis,join和ignore参数,其余参数暂不支持 pd.eval N pd.unique Y pd.value_counts
Y pd.cut N pd.to_numeric P 目前仅支持对于非series和frame的转换 pd.factorize N pd.qcut N pd.match
N pd.to_datetime Y pd.get_dummies Y pd.date_range Y pd.bdate_range N pd.to_timedelta D pd.options
N pd.datetime
N
- Panel
- Index
- MultiIndex
- CategoricalIndex
- DatetimeIndex
- Timedelta
- Timestamp
- NaT
- PeriodIndex
- Categorical
- Interval
- UInt8Dtype
- UInt16Dtype
- UInt32Dtype
- UInt64Dtype
- SparseDtype
- Int8Dtype
- Int16Dtype
- Int32Dtype
- Int64Dtype
- CategoricalDtype
- DatetimeTZDtype
- IntervalDtype
- PeriodDtype
- RangeIndex
- Int64Index
- UInt64Index
- Float64Index
- TimedeltaIndex
- IntervalIndex
- IndexSlice
- TimeGrouper
- Grouper
- array
- Period
- DateOffset
- ExcelWriter
- SparseArray
- SparseSeries
- SparseDataFrame