我已经提供了所有类似的问题和解决方案,但没有得到想要的输出。
我有一个 dask 延迟对象的列表。
for y in ys:
projection = Projection(data, X, y)
fi = projection.decode()
var.append(fi)
其中投影类和解码方法如下:
class Projection(object):
def __init__(self, data, X, y=0):
# data is dataframe, X is indecies of independent variables and y is index of dependent variable
self.data = data
self.X = X
self.y = y
...
...
@dask.delayed
def decode(self) -> list:
regressor = RandomForestRegressor(n_estimators=50, max_features='sqrt', n_jobs=-1, max_depth=6, verbose=0)
regressor.fit(self.X, self.y)
fi = regressor.feature_importances_
return fi
变量是:
[Delayed('decode-82afe417-9d1e-48ff-95a3-02ddc90c6970'),
Delayed('decode-0a872626-996a-4a19-8b45-b39acb44257f'),
Delayed('decode-cfa53fd4-cf5b-47f1-a672-440dc5f5ca35'),
Delayed('decode-29cf7f51-2e7a-4c9d-8ac0-bc2259d50b6f'),
Delayed('decode-2edc8324-f9df-4402-a1ed-44a6a9067f1d'),
Delayed('decode-05de7417-49a5-40b7-8098-f2aad50bd934'),
Delayed('decode-80916f08-2d28-4811-9ab4-e526af978aac'),
Delayed('decode-da4a8874-77b5-4d75-aede-c96b5e73e888'),
Delayed('decode-1c1fe7f0-a32b-4a0a-9d13-bb45710a3738')
现在我想计算这个var并想得到一个列表或数组或数据框。为此,我尝试了各种选择:
选项1
dask.compute(*var)
选项2
v = dask.array.from_array(np.array(var), chunks=(100,))
dask.array.compute(*v)
选项3
v = dask.array.from_delayed(np.array(var))
dask.array.compute(*v)
选项4
v = dask.array.from_delayed(np.array(var))
v.compute()
但在所有情况下,我要么再次获得延迟对象列表,要么超时。
选项 1 给出以下错误:
numpy.core._exceptions.MemoryError: Unable to allocate 458. MiB for an array with shape (19971, 3005) and data type int64
提前致谢。