Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Dask读取和分区数据帧,最大限度地减少峰值内存使用_Python_Dask_Lightgbm_Dask Dataframe - Fatal编程技术网

Python Dask读取和分区数据帧,最大限度地减少峰值内存使用

Python Dask读取和分区数据帧,最大限度地减少峰值内存使用,python,dask,lightgbm,dask-dataframe,Python,Dask,Lightgbm,Dask Dataframe,我有一个dataframe-esque数据集,具有以下结构,存储为磁盘上的大量csv文件: [ target_col | timestamp_col | feature_1 | feature_2 | ... | feature_10000 ] int32 int64 float64 float64 float64 我想将此数据加载到dask数据帧中,并将其拆分为“X\u列、X\u测试、y\u列、y\u测试”样式的分区,其

我有一个dataframe-esque数据集,具有以下结构,存储为磁盘上的大量csv文件:

[ target_col | timestamp_col | feature_1 | feature_2 | ... | feature_10000 ]
     int32         int64         float64    float64             float64
我想将此数据加载到dask数据帧中,并将其拆分为“
X\u列、X\u测试、y\u列、y\u测试
”样式的分区,其中对
时间戳
列进行列/测试拆分,
X
数据帧由除
目标列
之外的所有列组成。当然,
y
数据帧仅由
目标列组成

我还想将此数据加载到LightGBM数据集中(尽管这是一个选项)

以下是我目前掌握的情况:

with Client() as client:

    files = glob.glob(os.path.join(LOCAL_PATH, 'data/*'))
    data = dd.read_csv(files[0:], dtype=col_dtypes)

    train = data.loc[data.timestamp_col < 1591010111]
    test = data.loc[data.timestamp_col > 1591010111]


    train = train.persist()
    x_cols = [c for c in train.columns if c not in ['target_col', 'timestamp_col']]

    X_train = train[x_cols]
    y_train = train['target_col']

    X_test = test[x_cols]
    y_test = test['target_col']

    print('Loading data into lightgbm.datasets...')
    train = lightgbm.Dataset(X_train.compute(), label=y_train.compute())
    
    test = lightgbm.Dataset(X_test.compute(), label=y_test.compute())
以Client()作为客户端的
:
files=glob.glob(os.path.join(LOCAL_path,'data/*'))
数据=dd.read\u csv(文件[0:],数据类型=col\u数据类型)
列车=data.loc[data.timestamp\u col<1591010111]
测试=data.loc[data.timestamp\u col>1591010111]
train=train.persist()
x_cols=[c表示列中的c,如果c不在['target_col','timestamp_col']]
X_列=列[X_列]
y_列=列['target_col']
X_测试=测试[X_cols]
y_测试=测试['target_col']
打印('正在将数据加载到lightgbm.dataset…')
train=lightgbm.Dataset(X_train.compute(),label=y_train.compute())
test=lightgbm.Dataset(X_test.compute(),label=y_test.compute())
然而,这有非常高的峰值内存使用率(远远大于数据集的总大小),我认为我在这里使用Dask的效率并不是最高的。有没有更好的方法做到这一点,更好的方法是“降低峰值内存使用率”