0

我正在使用 statsmodels 来训练线性分位数回归。我有不同的功能组合需要尝试和训练,但好像 statsmodels 只允许模型中包含一定数量的功能。我在下面附上了一个虚拟示例。

# Construct dummy data:
df_dum = pd.DataFrame(columns=['y'])
df_dum['y'] = np.random.normal(size=10)
cols = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10','x11','x12','x13','x14','x15','x16','x17','x18','x19','x20','x21','x22','x23','x24']

for i in range(len(cols)):
    df_dum[cols[i]] = np.random.normal(size=10)

# specify feature constellations
feat1 = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10']
feat2 = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10','x11','x12','x13','x14','x15']

mod1 = sm.QuantReg(df_dum['y'], df_dum[feat1]).fit(0.50)
mod2 = sm.QuantReg(df_dum['y'], df_dum[feat2]).fit(0.50)

这里mod1运行没有问题,但mod2给了我错误: ValueError: operands could not be broadcast together with shapes (15,) (10,) 。所以好像 statsmodels 记住了以前模型的特征数量?

4

0 回答 0