0

How can I apply the model that I built against different data using stat models?

For example here I use OLS to model the data in file1. I want to use the modelX against on file2 data. Is that possible?

modelX = sm.OLS(y~ a+b+c, data=file1).fit()
modelY = sm.modelX.apply(y~ a+b+c, data=file2)

tried

import statsmodels.api as sm
import seaborn as sns
mpg = sns.load_dataset("mpg")

model = sm.OLS(mpg.weight, mpg.mpg)
results = model.fit()
results.apply(mpg.weight, mpg.mpg)

error

AttributeError: 'OLSResults' object has no attribute 'apply'
ferrelwill
  • 771
  • 2
  • 8
  • 20

0 Answers0