I have a dataset like
import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.api as sm
data = pd.DataFrame({'a':[4,3,4,6,6,3,2], 'b':[12,14,11,15,14,15,10]}
test = data.iloc[:4]
train = data.iloc[4:]
and I built the linear model for the train data
model = smf.ols("a ~ b", data = data)
print(model.fit().summary())
Now what I want to do is get the adjusted R^2 value based on the test data. Is there a simple command for this? I've been trying to build it from scratch and keep getting an error.
What I've been trying:
model.predict(test.b)
but it complains about the shape. Based on this: https://www.statsmodels.org/stable/examples/notebooks/generated/predict.html
I tried the following
X = sm.add_constant(test.b)
model.predict(X)
Now the error is
ValueError: shapes (200,2) and (200,2) not aligned: 2 (dim 1) != 200 (dim 0)
The shape matches but then there's this thing I don't understand about the "dim". But I thought I matched as well as I could the example in the link so I'm just not sure what's up.