我尝试使用MICE module of statsmodels来估算我的数据集。然而,我总是在一些我不理解的维度上得到错误。
以下是可重现的代码:
# Impute missing values using MICE
import random
import pandas as pd
import numpy as np
import statsmodels.imputation.mice as mice
df = pd.DataFrame(np.random.randn(50, 4), columns=list('ABCD'))
ix = [(row, col) for row in range(df.shape[0]) for col in range(df.shape[1])]
for row, col in random.sample(ix, int(round(.1*len(ix)))):
df.iat[row, col] = np.nan
imp = mice.MICEData(df)
imp.update_all(10)我得到的错误是:
ValueError: shape mismatch: value array of shape (2,1)
could not be broadcast to indexing result of shape (2,)发布于 2018-03-22 05:02:55
我认为这是一个已知的错误:https://github.com/statsmodels/statsmodels/issues/4129看起来像是在他们的源代码库中修复了它,但还没有发布。您可以尝试获取它们的主分支并手动安装:http://www.statsmodels.org/dev/install.html
https://stackoverflow.com/questions/49408522
复制相似问题