线性回归在python statsmodel中不起作用

时间:2017-06-23 22:26:42

标签: python regression

为什么这种线性回归不起作用?

string

无法获取属性摘要?

import pandas as pd
import statsmodels.formula.api as sm

# Read data
cities = pd.read_csv('../data/useful/cities_of_census_subdivision_without_lower_mainland_and_van_island.csv')
non_cities = pd.read_csv('../data/useful/non_cities_of_census_subdivision_without_lower_mainland_and_van_island.csv')

# Fit
fit_cities = sm.ols(formula="instagram_posts ~ accommodations + visitor_centers + festivals  + attractions", data=cities)
fit_non_cities = sm.ols(formula="instagram_posts ~ accommodations + visitor_centers + festivals  + attractions", data=non_cities)

print(fit_cities.summary())
print(fit_non_cities.summary())

一段数据

line 16, in <module>
    print(fit_cities.summary())
AttributeError: 'OLS' object has no attribute 'summary'

Process finished with exit code 1

相同的代码实际上适用于另一个csv文件。这个是那一个的子集。

0 个答案:

没有答案