PatsyError: Error evaluating factor: NameError: name 'wheel' is not defined
PatsyError: Error evaluating factor: NameError: name 'wheel' is not defined
尝试使用statsmodels中的公式模块制作线性回归模型。
import statsmodels.api as sm
import statsmodels.formula.api as smf
import pandas as pd
cars = pd.concat([y_train, X_train], axis = 1)
cars.head()
model = smf.ols(formula ='price ~ symboling + wheel-base + length + width + height + curb-weight + engine-size + bore + stroke + compression-ratio + horsepower + peak-rpm + city-mpg + highway-mpg + cylinder',data=cars)
results = model.fit()
print(results.summary())
我通过使用下划线而不是原来的连字符重命名我的列 header 来解决错误。连字符一定在代码中触发了一些我一无所知的表达式。
尝试使用statsmodels中的公式模块制作线性回归模型。
import statsmodels.api as sm
import statsmodels.formula.api as smf
import pandas as pd
cars = pd.concat([y_train, X_train], axis = 1)
cars.head()
model = smf.ols(formula ='price ~ symboling + wheel-base + length + width + height + curb-weight + engine-size + bore + stroke + compression-ratio + horsepower + peak-rpm + city-mpg + highway-mpg + cylinder',data=cars)
results = model.fit()
print(results.summary())
我通过使用下划线而不是原来的连字符重命名我的列 header 来解决错误。连字符一定在代码中触发了一些我一无所知的表达式。