OLS摘要值在每次运行中都会更改

问题描述 投票:0回答:1

我是数据分析的新手。我正在运行带有多个X的OLS。该模型可以很好地生成,但是我获得了不同的R2值,并且每次运行时自变量均发生变化。

R2中的变化是很小的系数或P> | t |自变量的差异很大。这是预期的吗?如果不是,我在做什么错?

X = train[['GarageCars','YearBuilt']]
y = train["SalePrice"]
X = sm.add_constant(X) 
model_1 = sm.OLS(y, X).fit()
predictions_1 = model_1.predict(X)

X1 = test[['GarageCars','YearBuilt']]
y1 = test["SalePrice"]
X1 = sm.add_constant(X) 
predictions_2 = model_1.predict(X1)
model_1.summary()```

thanks
python data-science statsmodels
1个回答
0
投票

啊找到了。每次运行模型代码时,我都会再次拆分数据。

© www.soinside.com 2019 - 2024. All rights reserved.